When the expression following a PRINT command is being output to screen, INK to TAB instructions have already been converted to control codes 10h/16d -> 17h/23d followed by parameters; but the parameters will be decoded wrongly unless they are read merely as numbers following a control code. So thecontrol code is stored in the lo byte of this sv (0A7D PO TV 1) and the first parameter, if there are two, in its hi byte (0A6D PO TV 2) while the rest of the instruction is read. Implementation is then at 0A87 PO CONT. Written by: 0A6D PO TV 2 (hi byte) 0A7D PO TV 1 (lo byte) Read by: 0A87 PO CONT (both bytes) Rems: 0A75 PO 2 OPER saves code while output address changed TV display see DISPLAY AREA Only the Introduction calls it the "TV display". TV FLAG system variable 5C3C Bytes: 1. The eight bits are all separate flags; four aren't used in ROM and are available for m/c programmers, but they are cleared whenever BASIC is listed or an INPUT command executed. All eight flags written by: 1795 AUTO LIST (bit 4 set, others zeroed) 17FB LIST 1 (all zeroed) 2096 INPUT 1 (misprinted DF SZ; bit zero set, others zeroed) TV flag bit 7: not used TV flag bit 6: not used TV flag bit 5: clear screen flag On "clear lower screen after keystroke"; off "don't". The lower screen is cleared by any keystroke after: - "Start tape and press any key" when SAVing. - the "scroll?" message - the copyright message - any report message Turned on by: 0970 SA CONTRL 0C88 PO SCR 2 1219 RAM SET 1313 MAIN G Turned off by: 0D6E CLS LOWER 111D ED COPY Read by: 10A8 KEY INPUT 15D4 WAIT KEY TV flag bit 4: Auto list flag On "dealing with auto list"; off "not". The difference between_automatic and_ordinary_listing is that in automatic listing a check is made to ensure that the_current_line, the onemarked with the > cursor, appears somewhere on the screen; if itdoesn't, the listing is scrolled up without any "scroll?" promptuntil it appears at the bottom of the screen. See 1795 AUTO LIST. The_current_line_number is always in 5C49 E PPC; the_top_line number from which printing to the screen begins is in 5C6CS TOP. The top number used last time, from S TOP, is first choice for the "automatic line number", but the listing routine makes sure the current line won't be left off the screen. Turned on by: 1795 AUTO LIST Turned off by: 0C55 PO SCR 17ED AUTO L 4 Read by: 0C55 PO SCR 1835 LIST ALL Rems: 0C55 PO SCR partly skipped for ordinary listing 0DAF CL ALL called in automatic listing 0FF3 ED DOWN new listing produced 106E ED LIST new listing produced 12A2 MAIN EXEC produces listing 15AB MAIN ADD2 produces listing 1795 AUTO LIST signal is in TV FLAG 17CE AUTO L 1 moves on to find suitable S TOP 17E1 AUTO L 2 gets line number of top line 17E4 AUTO L 3 makes listing 17FB LIST 1 signals ordinary listing 1822 LIST 5 signal "before current line" 1835 LIST ALL handles scroll down to current line 1855 OUT LINE signals before or after current line TV flag bit 3: Copy edit flag On "copy the edit or input line to lower screen"; off "don't". While waiting for key inputs, execution circles many many times round the 15DE WAIT KEY1 loop, calling 15E6 INPUT AD and through it 10A8 KEY INPUT on every turn of the loop. KEY INPUT first checks this flag and if it is set, indicating that some change has been made to the input since last time, recopiesthe editing or input to the screen. The notes call it a "mode flag", set if "the cursor mode may have changed"; this isn't exactly wrong, but doesn't tell the whole story. Turned on by: 10F4 KEY FLAG 15D4 WAIT KEY Turned off by: 111D ED COPY 1795 AUTO LIST 17FB LIST 1 Read by: 10A8 KEY INPUT TV flag bit 2: not used TV flag bit 1: not used TV flag bit 0: Lower screen flag On "printing in lower part of screen"; off "upper screen". See upper screen. Turned on by: 0D2D PO SCR 4B 0D6E CLS LOWER 1634 CHAN K 1795 AUTO LIST (misprinted FLAGS) 2096 INPUT 1 (misprinted DF SZ) Turned off by: 0D2D PO SCR 4B 1642 CHAN S 1795 AUTO LIST (twice: off when all off, then off again, again misprinted FLAGS) 17FB LIST 1 1C96 PERMS 1CBE CLASS 09 20AD INPUT 2 Read by: 0AAC PO AT ERR 0ADC PO STORE 0B03 PO FETCH 0C55 PO SCR 0D4D TEMPS 0DD9 CL SET 0E4D CL LINE 2 TWO PARAM subroutine 1E85 Gets two small integers from the calculator stack into Aand BC. Used for the OUT and POKE commands, which require a two-byte address and a one-byte integer to put to it. Input parameters: none - the two numbers on the stack, the smaller one as last value. Action: call 2DD5 FP TO A to get the first parameter - if it is more than 255d report "Integer out of range" - if FP TO A returned with Z jump on to TWO P 1; positive - (it is negative) negate it; so that eg -1 will be readas FFh. _1E8E_TWO_P_1: call 1E99 FIND INT2 to get the second parameter; this will produce error reports for a negative numberor one bigger than 65535d. Exit: RET, from TWO P 1. Output parameters: A and BC hold the two numbers; they have been cleared from the stack. Called from: 1E74 OUT 1E80 POKE TWO P 1 1E8E (1E85 TWO PARAM) Exit from: 1E85 TWO PARAM twos complementing Normal terminology, but it may be helpful to remark thata number is twos complemented or negated (NEG) by subtracting itfrom 1000...h and ones complemented (CPL) by subtracting it fromFFFF...h; as many 0s or Fs as hex digits in the number. type of save/load blocks see 0605 SAVE ETC type of variable see variables ----- UDG system variable 5C7B, Bytes: 2. The address of the first user-defined graphic. The udgs consist of twenty-one character forms, each of eight bytes, arranged like those in the character set; see page 93 in the oldHandbook, page 89 in the Plus 2 handbook, and page 221 of "ROM Disassembled". On start-up the 168d bytes are copied directly from the character forms for capital A to U in the character set. The_udg_character_codes are 90h to A4h; but when the code has been identified as a udg for printing out (0B52 PO T&UDG), they are reduced by 90h so that they run from 00 to 14h.This makes the first code code zero, so the "base address" of the set is the same as its first address, unlike the character codes addressed by 5C36 CHARS, whose first code is 20h/32d. There is no provision in the ROM for changing the udg character forms or for relocating UDG itself; the bytes must be POKEd individually from BASIC, or of course from m/c. The USR function with a string argument, see usr$ below, merely finds the first byte in the udg area of the character form associated with that letter. However UDG itself and any forms inserted in the udg area are preserved from being rewritten by the NEW command. There are several quite practical commercial programs toassist users in composing udg forms, and even supplying such things as whole alphabets of script forms or similar. Written by: 11EF RAM DONE (twice) Read by: 0B52 PO T&UDG 11B7 NEW Rems: 0B24 PO ANY separates UDGs from other codes UNARY MINUS OPERATION see 346E negate unary operation see binary operation "underline" character (5F) Key zero with caps shift; handled as a normal character.Its "final key code" is allotted as a one-off in 039D K KLC DGT. unprintable codes see character codes unshifted codes see shift keys UNSTACK Z subroutine 1FC3 Uses the syntax/run flag to choose between two return addresses, one used in syntax checking and the other in execution: to cut out actual execution during syntax checking. It is always called from another subroutine, so the machine stack has two return addresses on it. The top one, whichis an address in the calling subroutine, will continue into execution; if the flag calls for execution it is jumped to. If the flag is for syntax checking, UNSTACK Z makes a double returnto the return address of the calling subroutine, skipping its executive part. Could have applications in m/c programs, see useful routines. Input parameters: none. Action and Exit: call 2530 SYNTAX Z to read the flag - POP the upper return address - if the flag is set for syntax checking, return - (run time) jump to the POPped address. Output parameters: HL is corrupted. Called from: 1FF5 PRINT CR 1FFC PR ITEM 1 200E PR ITEM 2 2024 PR ITEM 3 2070 STR ALTER 21FC CO TEMP 4 unused addresses All these are filled with FFh bytes except as indicated. 0010 PRINT A 1 (5 bytes) 0020 NEXT CHAR (3 bytes) 0028 FP CALC (5 bytes) 0055 ERROR 3 (7 bytes) 04AA PROGRAM NAME: 24 bytes, coded as follows: CALL 24FB;(SCANNING) LD A,(5C3B);(FLAGS) ADD A,A JP M,1C8A;(REPORT C) this is a jump if ;bit 6 of FLAGS was set POP HL RET NC PUSH HL ;puts return address back CALL 2BF1;(STK FETCH) LD H,D LD L,E DEC C RET M ;if bit 7 of C is set ADD HL,BC SET 7,(HL) RET This makes sense, but I wouldn't recommend calling it asa USR routine without much thought. 1988 EACH STMT (3 bytes, each 23h INC HL) 386C LAST (491h/1169d bytes; in 128K Spectrums these contain several new routines) "up arrow" character (5E) see also commands, functions and operators, KEYBOARD SCANNING, 026A symbol code table In this index, replaced by "**"; the word processor cannot print the "up arrow"! But it is often so represented in other BASICs. The H key with symbol shift produces the operator "up arrow"; it must be both preceded and followed by a numeric expression. The effect of the operator X**Y is to return X to the power Y; X must be positive, even for eg X**2. Special cases: X**0 = 1 provided X isn't negative, even if X = 0 0**Y = 0 provided Y is positive X**(1/Y) = the Y'th root of X X**(-Y) = 1/(X**Y) provided X isn't zero These are all standard mathematical identities; (-X)**0 is usually accepted as giving the value plus one, but it gives an error in Spectrum BASIC. On execution, after X has been evaluated in 268D S DECIMAL or 26C9 S LETTER, 24FB SCANNING quickly leads to 2723 S OPERTR. Here the token code 5E is looked up in the two tables 2795 table of operators and 27B0 table of priorities, giving a value 0AC6 in BC, 0A being the priority and C6 the code of the ** operator. This is put on the machine stack in 2790 S NEXT. When the code comes off the calculator stack in 2734 S LOOP, C6 is converted (2773 S TIGHTER) to 06, the 3851 to-power executive routine. upper and lower case letters see character codes