The INK to OVER commands are executed by changing individual items of the permanent attributes kept in 5C8D ATTR P and putting the result in ATTR T, or for INVERSE and BRIGHT simply by changing P FLAG. Input parameters: none - the lo byte of 5C74 T ADDR, which holds the next address in the parameter table, is used as an index for the six INK to OVER commands Action: zero bit zero of 5C3C TV FLAG to signal "main screen" - call 0D4D TEMPS to put the ATTR P attributes in ATTR T; any permanent attributes which aren't changed by execution will be used as they stand - drop the return to the statement loop; return will be to 1B76 STMT RET - take 13h from 5C74 T ADDR lo; it held EC -> F1 for thesix INK to OVER parameter calls, so subtracting 13h gives D9 -> DE, the token codes for INK to OVER - call 21FC CO TEMP 4 to convert these to the control codes 10h -> 15h, read the parameter zero, one or 8 from the BASIC and output control code and parameter through the current channel; nothing happens immediately on screen as a result, but if the upper or lower screen channel is open this makes the required changes in ATTR T/MASK T - call 1BEE CHECK END to report "Nonsense in BASIC" if this isn't the end of the statement; remember we are handling INK to OVER as free-standing commands - copy ATTR T/MASK T to ATTR P/MASK P; the two bytes arehandled together as a single sv - get the byte from 5C91 P FLAG; it controls "PAPER and INK 9", INVERSE and OVER, its even bits flag the temporary attributes, its odd bits the permanent ones - rotate it one bit to the left; putting the temporary attributes in the "permanent" position - XOR/AND/XOR the original byte with the result, using the mask 10101010b/AAh; the mask causes copying where it has zero "holes", in its even bits, so the temporary attributes fromthe original are copied back to the new byte. See masks. Exit: RET to 1B76 STMT RET, to read the next statement. Output parameters: none. Called from syntax parameter table by: 1AEB P INK 1AEC P PAPER 1AED P FLASH 1AEE P BRIGHT 1AEF P INVERSE 1AF0 P OVER CLASS 08 subroutine 1C7A (also EXPT 2NUM) A "command class" subroutine, called from the syntax parameter table 1A7A by 1B55 GET PARAM in the statement loop. Called for commands which must be immediately followed in the BASIC line by two numeric parameters, separated by a comma: POKEand OUT. Also, as EXPT 2NUM, used as an exit routine when two numeric expressions are to be read from BASIC. Input parameters: none - the BASIC pointer 5C5D CH ADD is on the start of the first numeric expression. Action: call 1C82 CLASS 06 (EXPT 1NUM) to get the value of the first expression - if the next code isn't 2C comma report "Nonsense in BASIC" - move on the pointer. Exit: into EXPT 1NUM again for the second expression. Output parameters: as for CLASS 06. Called from syntax parameter table by: 1AB1 P POKE 1AF1 P OUT Exit as EXPT 2NUM from: 1C79 NEXT 2NUM 1CD6 CL 09 1 (1CBE CLASS 09) CLASS 09 subroutine 1CBE A "command class" subroutine, called from the syntax parameter table 1A7A by 1B55 GET PARAM in the statement loop. Called for commands which must be followed in the BASIC line by two numeric parameters, separated by a comma, and which draw on the screen; PLOT, DRAW, CIRCLE. These mustn't change the attributes where they mark the screen, unless instructions are included in the command; so the "default" commands PAPER 8; FLASH 8; BRIGHT 8 and NOT PAPER 9 are executed before any such instructions are looked for, and before the parameters are picked up. INK 8 isn't executed. The effect is complicated. All_controls embedded in the DRAW etc command will be implemented, including INK. However, any_command except an INK command affecting the whole screen, for example PAPER 0:, won't affect DRAW etc unless it is otherwise implemented, eg by CLS; in other commands of the PRINTtype, INK to OVER commands are executed in the printed area of the screen even though the rest of the screen hasn't yet been changed. Input parameters: none. Action: in syntax checking, jump on to CL 09 1 - zero bit zero of TV FLAG; "upper screen" - call 0D4D TEMPS to make 5C8F ATTR T hold the "permanent" values - OR 5C90 MASK T with 11111000b/F8h; leaving the INK part unchanged but putting ones in PAPER, BRIGHT and FLASH - this means they won't be changed on screen - zero bit 6 of 5C91 P FLAG; this ensures that P FLAG doesn't call for PAPER 9 (contrast) - read the next code in BASIC. _1CD6_CL_09_1: call 21E2 CO TEMP to execute any embedded INK to OVER commands found in the DRAW etc command. Exit: into 1C7A EXPT 2NUM, to get two coordinates on to the calculator stack; the third coordinate of CIRCLE, and of DRAW if any, is handled by the executive routines. Output parameters: none. Called from syntax parameter table by: 1AC1 P PLOT 1AD2 P DRAW 1AE7 P CIRCLE CLASS 0A subroutine 1C8C (also EXPT EXP) see also strings A "command class" subroutine, called from the syntax parameter table 1A7A by 1B55 GET PARAM in the statement loop. Called for commands which must be followed by a string expression in the BASIC line. Also called direct as EXPT EXP from 0605 SAVE ETC to get the file name from the BASIC line. Input parameters: none - the BASIC pointer in 5C5D CH ADD is on the start of the expression. Action: call 24FB SCANNING to read the expression - if bit 6 of FLAGS isn't zero report "Nonsense in BASIC"; it must be a string. Exit: RET. Output parameters; HL points to the first byte of the string parameters on the calculator stack - DE holds the stack end. Called from syntax parameter table by: 1AFC P OPEN 1B06 P FORMAT 1B0A P MOVE (twice) 1B10 P ERASE Called as EXPT EXP from: 0605 SAVE ETC CLASS 0B subroutine 1CDB A "command class" subroutine, called from the syntax parameter table 1A7A; unlike most of the other CLASS subroutinesit jumps straight out to 0605 SAVE ETC, the executive routine for the four SAVE/LOAD commands. Called from syntax parameter table by: 1ADF P SAVE 1AE0 P LOAD 1AE1 P VERIFY 1AE2 P MERGE CL ATTR subroutine 0E88 see also colours, DISPLAY AREA Given the address of a line start in the display area - calculates the address of the corresponding attribute byte in the attributes area - calculates the number of attribute bytes from this one to the end of the attributes area inclusive, used as a counter in scrolling or rewriting the attribute bytes. It is occasionally useful for m/c programmers, but note the slightly off-beat input parameters. 1. The line starts in the display area have 40h, 48h or 50hfor their hi byte (for each of the thirds), and 00, 20h, 40h, ... E0h for their low byte. In the attributes area the line start addresses are 5800, 5820, ... 58E0 in the first third, 5900, ... 59E0 in the second, and 5A00, ... 5AE0 in the last; so the lo byte is already correct for the attributes area. See DISPLAY AREA for the display addresses and colours for the attributes. For the hi byte, the input parameter value is 08 more than the line start, ie 48h, 50h or 58h; for the corresponding attribute hi byte 58h, 59h or 5Ah we require to calculate LET H = 57h + (H - 40h)/8. The first seven lines of the subroutine perform some simple "one-byte arithmetic". Ignore the confusing notes! Transform the equation above: LET H = H/8 + 57h - 40h/8 = H/8 + 4Fh = H/8 - 1 + 50h. Divide H by 8, subtract one and OR the result with 01010000b/50h to produce the required hi byte. 2. The calculation of the number of remaining attribute bytes starts with the line number B, counted from the bottom of the screen; it is simply 20h * B, because there are 20h/32d bytes in each attribute line. Its maximum value is 24 * 32 = 768d, too big for one-byte arithmetic but easily accomodated in two bytes. Input parameters: HL holds the line start, the address ofthe first pixel byte of the character, plus 800h; on both calls 8 pixel-line loops have been completed. [The notes call this, a little fancifully, the "ninth pixel byte address" - it is where the ninth pixel byte would be if there was one] - B holds the screen line number; one -> 18h/24d, from the bottom - C always holds zero. Action: rotate the hi byte of the line start three times right; divide by eight - subtract one - OR with 50h; this is the required hi byte - save both bytes - double the line number five times; this is the number of attribute bytes in B lines. Exit: RET Output parameters: DE holds the attribute address - BC and HL hold the number of attribute bytes. Called from: 0E19 CL SCR 3 0E4D CL LINE 2 CL CHAN subroutine 0D94 "Housekeeping" after the screen has been cleared. The main task is to correct the input and output addresses in channel K; they could have been changed during output of print control parameters. Input parameters: none. Action: call 1601 CHAN OPEN with stream minus 3 to open channel K - load the correct output address 09F4 PRINT OUT for thechannel - clear the carry flag. _0DA0_CL_CHAN_A: put this address in the two bytes of thechannel - load the input address 10A8 KEY INPUT - reverse the carry flag - if it now shows carry jump back to CL CHAN A to put the address in the next two bytes of the channel - (both channel addresses loaded) load the print position 1721h, the start of the second line from the top of thelower screen. Exit: into 0DD9 CL SET, which loads the svs which controlthe print position. Output parameters: BC holds the lower screen print position. Called from: 0DAF CL ALL Exit from: 0D8E CLS 3 (0D6B CLS) CL CHAN A 0DA0 (0D94 CL CHAN) Jumps from: auto CLEAR key (FD) see also commands, functions and operators, KEYBOARD SCANNING The X key in K mode produces the command CLEAR; it requires one numeric parameter, the setting for 5CB2 RAMTOP, butit doesn't have to be supplied from BASIC - if none is supplied,the existing value is used. The command is read by 1B29 STMT L 1 referring through the syntax offset table 1A48 to the syntax parameter table 1A7A.1ABB P CLEAR causes a jump via 1C0D CLASS 03 - which gets the parameter if supplied - and 1C16 JUMP C R to the executive routine 1EAC CLEAR. CLEAR subroutine 1EAC Called only from the syntax parameter table 1A7A; the executive routine of the CLEAR command. Reclaims the whole of the variables area and GO SUB stack, and clears the screen. The calculator stack and work space aren't reclaimed - they should be clear already. Also the exit routine from the 1EA1 RUN subroutine, which enters at 1EAF CLEAR RUN (misprinted in 1EA1 RUN); the RUNcommand never supplies a new 5CB2 RAMTOP address. Better not called from m/c! because the stack pointer will probably be badly placed. [The note in the Rems at the end of this subroutine refers to the fact that although statements can be entered in a BASIC line after a RUN command - and their syntax may be passed correct - there is no way they can be executed. This doesn't apply to the CLEAR command.] Input parameters: none - the BASIC pointer in 5C5D CH ADD is on the code after CLEAR. Action: call 1E99 FIND INT2 to get the new 5CB2 RAMTOP value from BASIC; if none is given, it will use zero. _1EAF_CLEAR_RUN (entry here from 1EA1 RUN, always with a zero value for 5CB2 RAMTOP): if the RAMTOP value isn't zero jumpon to CLEAR 1 - (zero RAMTOP value) use the value already in 5CB2 RAMTOP. _1EB7_CLEAR_1: call 19E5 RECLAIM 1 with the first byte todelete taken from 5C4B VARS and the first to be left alone the one below that in 5C59 E LINE, the 80-byte at the end of the variables; this reclaims the variables area - call 0D6B CLS to clear the screen - get the value from 5C65 STKEND - add 32h/50d to allow for extra space on the stack and machine stack - subtract the 5CB2 RAMTOP value - if the 5CB2 RAMTOP value is lower report "RAMTOP no good" - get the value from 5CB4 P RAMT - subtract the RAMTOP from that - if the 5CB2 RAMTOP value is higher report "RAMTOP no good". _1EDC_CLEAR_2 (misprinted): - put the new value in 5CB2 RAMTOP - get the 1B76 STMT RET return address for this subroutine off the stack - get the address below it off the stack; the return address to 1303 MAIN 4 - put the stack end marker 3E at the new RAMTOP - point the stack pointer at the address below RAMTOP - push the MAIN 4 address on to the new stack - keep the present stack pointer address in 5C3D ERR SP. Exit: effectively a RET, though in order to meddle with the stack pointer this is done periphrastically by POP DE/EX DE,HL/JP (HL). This will be to 1B76 STMT RET. Output parameters: none. Called from: 1ABB P CLEAR (syntax parameter table) Rems: 1EA1 RUN exits to perform CLEAR 0 clear display see DISPLAY AREA