The screen line number is a number of at most 5 binary digits, say 000XYPQRb. XYPQR represent digits which may be zero or one: PQRb is the remainder r on dividing by eight, XYb is thequotient q. Three right rotations give PQR000XYb; ANDing with 11100000b/E0h gives PQR00000b, which is already 20h * r, the required lo byte. Now 000XYPQRb is recovered and ANDed again, this time with 00011000b/18h, giving 000XY000b; this in turn is ORed with 01000000b giving 010XY000b, which is none other than the required hi byte 40h + 8q. Input parameters: B holds the line number. Action: subtract the line number from 18h/24d; now it counts from zero at the top to 17h/24d at the bottom - save a copy of the line number - rotate it three times right - AND the result with 11100000b/E0h; this is the lo byte - recover the line number and AND it with 00011000b/18h - OR the result with 01000000b/40h; this is the hi byte. Exit: RET. Output parameters: HL holds the display address, the start of line B - B unchanged. Called from: 0CD2 PO SCR 3 0DEE CL SET 1 0E00 CL SCROLL 0E44 CL LINE CL ALL subroutine 0DAF Clears the whole display area. From m/c it is usually better to call 0D6B CLS, to reform the lower part of the screen. Input parameters: none. Action: put zero in 5C7D COORDS; the PLOT position - reset FLAGS2 bit zero; "the screen is cleared" - call 0D94 CL CHAN to correct channel K and set the lower screen print position to 1721h, ie 0,0; see DISPLAY AREA - call 1601 CHAN OPEN with stream minus 2 to open channel S - call 0D4D TEMPS to copy the permanent colours into thetemporary ones - call 0E44 CL LINE to clear 18h/24d lines and colour them with the permanent attributes - put the correct output address in channel S; it might not have been restored after 0A6D PO TV 2 and following - put one in the scroll counter 5C8C SCR CT; corrected later by 12CF MAIN 2 or 20AD INPUT 2 - load the upper screen print position 1821h, ie 0,0; see DISPLAY AREA. Exit: into 0DD9 CL SET and 0ADC PO STORE, which load valus into system variables controlling the display. Output parameters: BC holds the print position for the first character on the screen. Called from: 0D6B CLS 12CF MAIN 3 1795 AUTO LIST CLASS 00 subroutine 1C10 A "command class" subroutine, called from the syntax parameter table 1A7A by 1B55 GET PARAM in the statement loop. Itis called for commands which mustn't have operands, such as COPY, or those whose operands have all been collected by other routines and mustn't have any more. It merely sets the Z flag, which has the effect of calling 1BEE CHECK END two lines further down; in syntax checking, this will make an error report unless a colon or newline is found. Exit: into 1C11 CLASS 05. Called from syntax parameter table by: (no parameters wanted:) 1A8A P STOP 1A8D P RETURN 1AA8 P NEW 1AB8 P CONT 1ABE P CLS 1AD6 P COPY 1B14 P CAT (all parameters fetched:) 1A7D P GO TO 1A86 P GO SUB 1A98 P NEXT 1AB1 P POKE 1AC1 P PLOT 1AC5 P PAUSE 1AE3 P BEEP 1AF1 P OUT 1AF5 P BORDER 1AFC P OPEN 1B02 P CLOSE 1B06 P FORMAT 1B0A P MOVE 1B10 P ERASE Exit from: 1C0D CLASS 03 CLASS 01 subroutine 1C1F A "command class" subroutine, called from the syntax parameter table 1A7A by 1B55 GET PARAM in the statement loop. Itis called for LET to identify the variable in assignment in caseit is an old variable, see under variables. It is also called direct from other parts of ROM where a variable must be found. Input parameters: none - the BASIC pointer in 5C5D CH ADD is on a variable letter. Action: call 28B2 LOOK VARS, which reads the variable letter, checks if the variable has been used before, and finds its address in the variables area if so. Output parameters: as for LOOK VARS. Exit: into 1C22 VAR A 1; see under LOOK VARS. Called from syntax parameter table by: 1A7A P LET Called direct by: 1DED READ 20D8 IN ITEM 2 20ED IN ITEM 3 CLASS 02 subroutine 1C4E A "command class" subroutine, called from the syntax parameter table 1A7A by 1B55 GET PARAM in the statement loop. Itis called only for the LET command, to evaluate the expression after LET X = in the BASIC line and give its value to the variable in assignment. Input parameters: none - the BASIC pointer 5C5D CH ADD is on the start of the expression after LET X =. Action: drop the return address; no more return to 1B52 SCAN LOOP, return now will be to 1B76 STMT RET - call 1C56 VAL FET 1 to evaluate the expression - call 1BEE CHECK END; must be the end of the statement. Exit: RET, to 1B76 STMT RET. Called from syntax parameter table by: 1A7A P LET CLASS 03 subroutine 1C0D A "command class" subroutine, called from the syntax parameter table 1A7A by 1B55 GET PARAM in the statement loop. For commands which may or may not be followed in the BASIC line by one numeric parameter; assigns zero if none given. Input parameters: none - the BASIC pointer 5C5D CH ADD is on the character after the command. Action: call 1CDE FETCH NUM; if the pointer is on a numeric expression it gets the value, if on a terminator it supplies the value zero. Exit: into 1C10 CLASS 00; it checks that nothing follows the parameter. Called from syntax parameter table by: 1AAB P RUN 1AB5 P RANDOM 1AB8 P CLEAR 1ACF P RESTORE CLASS 04 subroutine 1C6C A "command class" subroutine, called from the syntax parameter table 1A7A by 1B55 GET PARAM in the statement loop. Called for the FOR and NEXT commands; finds the variable named in the BASIC line and checks it is a valid looping variable. Input parameters: none - the BASIC pointer 5C5D CH ADD is on the variable name. Action: call 2B82 LOOK VARS, which finds the variable letter in the variables area - OR the letter with 10011111b/9Fh; this will make FF ifthe hi bits are 011 or 111, a "short numeric variable" name - if incrementing the result doesn't make zero, report "Nonsense in BASIC". Exit: into 1C22 VAR A 1, which makes the variable ready for assignment; see under 28B2 LOOK VARS. Called from syntax parameter table by: 1A90 P FOR 1A98 P NEXT Rems: 1DAB NEXT variable is already determined CLASS 05 subroutine 1C11 A "command class" subroutine, called from the syntax parameter table 1A7A by 1B55 GET PARAM in the statement loop. Called when all parameter collecting, etc, which can be done from the parameter table is complete and it is time to break outto the executive routine. This is sometimes done through the class routines which exit into CLASS 05, 1C0D CLASS 03 or 1C10 CLASS 00, but: - CLASS 03 collects a parameter, or supplies zero if noneis given in the BASIC - CLASS 00 rejects further parameters with an error report. CLASS 05 is neutral about this, leaving such decisions to the executive routine itself. The example given in the notes is PRINT; a full list is CIRCLE: there must be a third parameter, but it is left to the executive routine DATA and READ: identifying and reading the values is leftto the executive routine DEF FN: there are parameters, but they are only read whenchecking syntax. DIM: must be followed by a variable name, but it is left to the executive routine to identify it DRAW: there may or may not be a third parameter FOR ... TO x: may be followed by STEP or not INPUT: may be followed by a string before the variable tobe assigned, or not LIST and LLIST: may be followed by a line number or a stream PRINT and LPRINT, which can stand alone or be followed byan expression REM: may be followed by anything or nothing THEN: "IF xxxx THEN" is good syntax by itself, though it has no particular effect. Indeed, IF USR x THEN can be used to operate a m/c routine. Input parameters: the Z flag shows NZ on a direct call orZ on entry from CLASS 00 or CLASS 03. Action: drop the 1B52 SCAN LOOP return address; there will be no more parameters from the parameter table 1A7A. The return address on the machine stack is now 1B76 STMT RET. - if the Z flag is set call 1BEE CHECK END to report "Nonsense in BASIC" if the end of the BASIC statement hasn't been reached; the flag shows NZ when the routine is called from GET PARAM, because of the DEC B at the end of GET PARAM, so CHECK END isn't called. It is Z on entry from CLASS 00 or CLASS 03; in these cases the statement must be at an end. _1C16_JUMP_CR (this label is never used in ROM, despite having a cross-heading to itself): get the next two bytes from the syntax parameter table 1A7A - the address of the executive subroutine - and jump to that address. Exit: the RET is actually a jump to the address in BC. Output parameters (they were read by 0018 GET CHAR at theend of 1B55 GET PARAM - or, if entry was from 1C0D CLASS 03, they were read by GET CHAR in 2734 S LOOP on the exit from 24FB SCANNING called by 1C82 EXPT 1NUM, called by 1CDE FETCH NUM, called by 1C0D CLASS 03): - HL holds the address of the last character code read from BASIC -_except if FETCH NUM had to use a zero, in which case HL points to the first byte of the zero on the calculator stack - A holds the value of the code. Called from syntax parameter table by: 1A81 P IF 1A90 P FOR 1A9C P PRINT 1A9F P INPUT 1AA2 P DIM 1AA5 P REM 1AAE P LIST 1AC8 P READ 1ACC P DATA 1AD2 P DRAW 1AD9 P LPRINT 1ADC P LLIST 1AE7 P CIRCLE 1AF9 P DEF FN Exit from: 1C10 CLASS 0 CLASS 06 subroutine 1C82 (also called EXPT 1NUM) 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 one numeric parameter. Also called direct as EXPT 1NUM whenever a numeric expression is to be read from BASIC and put on the calculator stack. Input parameters: none - the BASIC pointer in 5C5D CH ADD is on the start of the expression in BASIC. Action: call 24FB SCANNING to get the value of the expression - if bit 6 of FLAGS is set report "Nonsense in BASIC"; astring value is an error. Exit: RET. Output parameters: HL points to the first byte of the last value on the calculator stack, the value of the expression - DE holds the stack end. Called from syntax parameter table by: 1A7D P GO TO 1A81 P IF 1A86 P GO SUB 1A90 P FOR (twice) 1AC5 P PAUSE 1AF5 P BORDER 1AFC P OPEN 1B02 P CLOSE Called as EXPT 1NUM by: 06E1 SA CODE 1 06F5 SA CODE 3 0723 SA LINE 1 1814 LIST 2 1C7A EXPT 2NUM 1D03 FOR 200E PR ITEM 2 2070 STR ALTER 21FC CO TEMP 4 2320 CIRCLE 238D DR 3 PRMS 2ACD INT EXP2 Exit from: 1C7A EXPT 2NUM 1CDE FETCH NUM CLASS 07 subroutine 1C96 (also called PERMS) see also colours A "command class" subroutine, called from the syntax parameter table 1A7A; unlike most of the other CLASS subroutines, it is also the executive routine for the command, and doesn't return to the parameter table. The executive routine for the INK to OVER commands when used as free-standing BASIC commands, ie not as part of a PRINT etc command; the header note is a little obscure. Not otherwise called from ROM. The actual colouring of the screen is performed by 0BDB PO ATTR, which uses the fbpapink byte from 5C8F ATTR T to make the PAPER, INK, FLASH and BRIGHT attributes and the flags from 5C91 P FLAG for INVERSE, OVER and PAPER and INK 9 - see colours.