204E PR POSN 1 handles semicolon, comma 2061 PR POSN 2 handles "'" 2089 INPUT can be embedded items in INPUT statement 20C1 IN ITEM 1 deals with embedded items 21B2 IN NEXT 2 handles any more position controls 28AB FN SKPOVR skips all control codes 295A SFA LOOP skips all control codes CONTROL CHARACTERS WITH OPERANDS ROUTINE see 0A75 PO 2 OPER control codes/keys see control characters control variable of FOR ... NEXT loop see 1D93 FOR, 1DAB NEXT coordinates see DISPLAY AREA; of arc see 247D CD PRMS1 COORDS system variable 5C7D Bytes: 2 Holds the X (hi) and Y (lo) pixel coordinates of the last point plotted or drawn on the screen. Sometimes read as two1-byte values. Written by: 235A C ARC GE1 0DAF CL ALL 22E5 PLOT SUB Read by: 23C1 DR PRMS (twice) 2439 ARC START (twice) 245F ARC END (twice) 24DF D L STEP Rems: 233B C R GRE 1 parameters copied to 2382 DRAW point coordinates held by, on entry 24B7 DRAW LINE coordinates of line start held in 24CB DL LARGER saved in H'L' COPY key (FF) see also commands, functions and operators, KEYBOARD SCANNING The Z key in K mode produces the command COPY, which accepts no parameters. The command is read by 1B29 STMT L 1 referring through the syntax offset table 1A48 to the syntax parameter table 1A7A.1AD6 P COPY causes a jump via 1C10 CLASS 00 and 1C16 JUMP C R tothe executive routine 0EAC COPY. COPY subroutine 0EAC Called only from the statement loop, through the syntax parameter table 1A7A; the executive routine for the COPY command. Outputs a copy of the main screen - the top 16h/22d lines - to the ZX printer, if connected. The printer buffer isn't used - the pixel bytes are sent direct to the printer fromthe screen. Because of the eccentric layout of the display area thisisn't straightforward; see DISPLAY AREA. The printer must be fedfirst with the 20h/32d pixel bytes of the first row of the firstline of characters, then the second row to eighth row of the first line, then the first row of the second line, etc. The actual output of a row of 20h/32d pixel bytes_is straightforward; it is achieved by a call to 0EF4 COPY LINE withthe first pixel address in HL. The pixel line number is also given in B, but this is only so that the printer can be slowed down at the end of each line of characters. COPY is concerned mainly with getting HL right for each pixel line. The start of each pixel row is 100h/256d on from the onebefore, see DISPLAY AREA. After eight pixel rows have been output, the start of the first pixel row of the next line must be found. Add 20h to the lo byte of the last line start. The lo bytes of the starts of character rows are always: 00h for the first line in a third 20h " " second " " " " etc E0h " " eighth " " " " so adding 20h will make a carry only on the eighth line. Subtract the new lo byte from itself, with_reversed carry from the addition; this gives 00000000b - 00000000b - 0 = 00000000b after the eighth, or PQRS0000b - PQRS0000b - 1 = 11111111b after all the others. AND this with 11111000b/F8h, giving 00000000b after the eighth line, but 11111000b/F8h after each of the others; add this to the hi byte. The hi byte has gone up by one for each pixel row, so will have gone up by 8 after the eighth. Adding F8 is the same as subtracting 8, so it is set back to its start value each timeuntil the end of the third is reached. Now it is allowed to remain incremented by eight, giving the start address of the next third. Input parameters: none. Action: disable the interrupt - make a pixel line counter B0h/176d; the number of pixel lines in 16h/22d screen lines - make a pointer 4000h; the first address of the displayarea. _0EB2_COPY_1: call 0EF4 COPY LINE to output 20h bytes - recover the pointer - increment its hi byte; ie add 100h for the next pixel row - AND the result with 00000111b/07 to get the remainder on dividing by eight - if this doesn't make zero jump on to COPY 2 - (the hi byte is a multiple of eight, eight pixel rows have been output) add 20h to the hi byte - reverse the carry flag - make a byte 00 if the addition made carry, FF if not - AND this byte with F8h/minus 08; making zero if there was carry - add the result to the hi byte; start on a new third ifthere was carry, see above. _0EC9_COPY_2: loop back to COPY 1 counting down the pixelline counter. Exit: into 0EDA COPY END in 0ECD COPY BUFF, which switches off the motor, enables the interrupt and clears the printer buffer. Output parameters: none. COPY BUFF subroutine 0ECD Prints out the contents of the printer buffer, 256d bytes; they are the eight rows of pixel bytes, 32d in each row, of a single line of print. Input parameters: none. Action: disable the interrupt - make a pointer 5B00; the start of the print buffer - make a pixel line counter 08. _0ED3_COPY_3: call 0EF4 COPY LINE to output 32d pixel bytes - loop back to COPY 3 counting down the pixel line counter. _0EDA_COPY_END: output 00000100b/04 to port FB to stop the motor - enable the interrupt. Exit: into 0EDF CLEAR PRB, which zeroes all the bytes of the printer buffer and resets the print position svs. Output parameters: none. Called by: 0B7F PR ALL 1303 MAIN 4 Exit from: 0A4F PO ENTER COPY END 0EDA (0ECD COPY BUFF) Jumps from: 0EC9 COPY 2 copying over An expression used only at 117C ED C DONE, meaning copying the edit line or INPUT expression to the lower screen. COPY LINE subroutine 0EF4 see also ports Sends a line of 20h/32d pixel bytes to the ZX printer. Input parameters: HL holds a pointer to the first pixel byte; this may be in the display area or the printer buffer - B holds the number of the pixel row, counted from eight down to one. Action: set the carry flag if the row number is two or less - make a row flag byte with SBC A,A; FFh if the carry was set, otherwise zero - AND 00000010b/02 makes 02 if carry was set, otherwise zero - output the row flag byte to port FB; zero does nothing, 02 slows the printer motor for the last two lines. _0EFD_COPY_L_1: call 1F54 BREAK KEY - if there is no BREAK jump on to COPY L 2 - (BREAK pressed) output 04 to port FB; it stops the motor - enable the interrupt - call 0EDF CLEAR PRB to zero the print buffer - exit to "BREAK - CONT repeats". _0F0C_COPY_L_2: get a byte from port FB and double it - if this sets the hi bit, return; the printer isn't connected - if the doubling made NC, loop back waiting to COPY L 1; the printer is connected but not outputting its "ready" signal - (printer ready) make a byte counter 20h/32d. _0F14_COPY_L_3: get a pixel byte - move on the pixel byte pointer - make a bit counter 08 for the eight individual pixels of the byte. _0F18_COPY_L_4: shift the row flag byte once to the left,with its hi bit going into the carry - shift the pixel byte once to the left, with the carry from the last shift into its lo bit and its hi bit going into the carry - shift the row flag byte back to the right, with its hibit coming from the carry: the flag remains as it was, except that the latest bit from the pixel byte to be printed goes into its hi bit. _0F1E_COPY_L_5: input from port FB - if bit zero is zero jump back to COPY L 5; wait till the printer is ready - output the row flag; with hi bit set for a "dot" pixeland clear for a "blank" pixel - jump back to COPY L 4 counting the bit counter down tozero - (eight bits output) decrement the byte counter - if it isn't yet zero jump back to COPY L 3 for the next pixel byte. Exit: RET. Output parameters: none. Called from: 0EB2 COPY 1 0ED3 COPY 3 COPY L 1 0EFD (0EF4 COPY LINE) Jumps from: 0F0C COPY L 2 COPY L 2 0F0C (0EF4 COPY LINE) Jumps from: 0EFD COPY L 1 COPY L 3 0F14 (0EF4 COPY LINE) Jumps from: 0F1E COPY L 5 COPY L 4 0F18 (0EF4 COPY LINE) Jumps from: 0F1E COPY L 5 COPY L 5 0F1E (0EF4 COPY LINE) Exit from: 0F18 COPY L 4 (0EF4 COPY LINE) Jumps from: auto COPY 1 0EB2 (0EAC COPY) Jumps from: 0EC9 COPY 2 COPY 2 0EC9 (0EAC COPY) Jumps from: 0EB2 COPY 1 COPY 3 0ED3 (0ECD COPY BUFF) Jumps from: auto COS key (B3) see also commands, functions and operators, KEYBOARD SCANNING, 022C extended mode table (b) The W key in E mode without shift produces the function COS; it requires one numeric operand X, and the value of the function is the cosine of X. On execution, 24FB SCANNING quickly leads to 26DF S NEGATE. This converts the key code B3 first to 04, then to E0, and adds the priority 10h/16d. Code and priority 10E0 are now pushed on to the machine stack (270D S PUSH PO) while the expression following COS is evaluated. When the code is taken off the stack (2734 S LOOP), it is converted (2773 S TIGHTER) from E0 to 20, the calculator offset for 37AA cos. cos subroutine 37AA Called from 0028 FP CALC with the literal 20; the executive routine of the COS function. Also called through the calculator in ROM to calculate TAN, and in figuring the parameters for arc drawing. Can be called from m/c either through the calculator or directly. Given X, returns COS X. X must be in radians, see under 3783 get-argt. X is first converted to a "reduced argument" V by 3783 get-argt and then its absolute value is taken. In this form V measures the angle not in degrees or radians but as a fraction of a right angle. V is the acute angle whose COS is equal to COSX, in absolute values; mem-0 will hold one if V represents an obtuse angle, which will have a negative cosine, and zero if V represents an acute angle. V is then changed to its complementary angle, 1 - V with these units, or pi/2 - X in the original units: COS V = SIN (1 - V). So the sign is adjusted according to the value in mem-0 and the remainder of the calculation performed by the sin subroutine. Input parameters: X must be the last number on the calculator stack, even for direct calls. Action: use the calculator with get-argt and abs, to findABS V - if V > 1 (obtuse angle), exit to C ENT with ABS V - 1,the acute angle whose SIN is equal to COS V in absolute values, and one in mem-0 for a negative result - (acute angle) exit with 1 - ABS V and zero in mem-0. Exit: to 37B7 C ENT, which finds SIN (1 - V). See under 37B5 sin. Output parameters: HL and DE still point to the end of the calculator stack - the last value is the "reduced argument", with its sign corrected - mem-0 to mem-2 have been corrupted; mem-3 to mem-5 undisturbed. Called from: 23C1 DR PRMS 37DA tan Rems: 3449 series-06 indirectly used to calculate cos 3783 GET ARGT transforms argument to fraction of 90 deg 37B7 C ENT common to cos and sin CO TEMP A 2257 (09F4 PRINT OUT) Jumps from: 2246 CO TEMP 9 (twice) CO TEMP B 2258 (09F4 PRINT OUT) Jumps from: 2246 CO TEMP 9 CO TEMP C 2273 (09F4 PRINT OUT) Jumps from: 2211 CO TEMP 5 CO TEMP D 227D (09F4 PRINT OUT) Jumps from: 2273 CO TEMP C