clearing editing area see 1097 CLEAR SP clearing input area see 1097 CLEAR SP CLEARING THE WHOLE DISPLAY AREA SUBROUTINE see 0DAF CL ALL CLEAR LINES SUBROUTINE see 0E44 CL LINE CLEAR PRB subroutine 0EDF Clears the ZX printer buffer, ie zeroes all its bytes. Input parameters: none. Action: get the printer buffer zero address 5B00 - put its zero lo byte in 5C80 PR CC. _0EE7_PRB_BYTES: put zero in each byte of the buffer; a DJNZ loop with zero counter makes 256d turns - zero bit 1 of FLAGS2; "print buffer empty" - set the print position at 21h, the equivalent of minusone. Exit: into 0DD9 CL SET, which sets the print position svsand flags. Output parameters: C holds 21h for "printer position". Called from: 0EFD COPY L 1 1219 RAM SET Exit from: 0EDA COPY END (0EAC COPY, 0ECD COPY BUFF) CLEAR PRINTER BUFFER SUBROUTINE see 0EDF CLEAR PRB CLEAR RUN 1EAF (1EAC CLEAR) The entry point to 1EAC CLEAR from the 1EA1 RUN subroutine. Exit from: 1EA1 RUN (misprinted CLEAR 1) clear screen see DISPLAY AREA CLEAR SP subroutine 1097 Reclaims the editing area or the work space, depending on the setting of FLAGX bit 5 - the editing area if the flag is set. Input parameters: none. Action: call 1190 SET HL, which points HL and DE at the last and first address of the area signalled by the flag - call 19E5 RECLAIM 1 to reclaim the area - point 5C5B K CUR at the first address of the area - zero 5C41 MODE signalling "not E or G mode". Exit: RET. Output parameters: HL is saved, otherwise none. Called from: 133C MAIN 5 0FA9 ED EDIT Exit from: 0FA9 ED EDIT (twice) CLEAR 1 1EB7 (1EAC CLEAR) Jumps from: 1EAF CLEAR RUN CLEAR 2 1EDC (1EAC CLEAR; misprinted CLEAR 3) Jumps from: 1EB7 CLEAR 1 click on keyboard see 5C39 PIP CL LINE subroutine 0E44 Clears the bottom lines of the display. The number L of lines to be cleared is given on input. Each character position on screen is cleared by setting all its pixels to zero; then theattribute bytes are set to the screen colours. See DISPLAY AREA for the way the display is arranged in thirds of eight lines each. If you divide L by eight, the quotient is T, the number of complete thirds to be cleared at the bottom of the screen, and the remainder is S, the number of odd lines to be cleared above them. L is never more than a 5-bitbinary number; if it is 000XYPQRb, then T = XYb and S = PQRb; XYPQR each being either zero or one. Go eight times through the following loop; on each n'th turn of the loop all the n'th pixel lines in all L lines are zeroed. The address in the display area, say M, is initially that of the line start of the L'th line from the bottom of the screen, but it gets moved on every time a byte is zeroed: - AND 000XYPQRb with 00000111b and rotate the result right three times; this gives PQR00000b, which is 20h/32d times S, and therefore the number of characters in S lines; see "one- byte arithmetic" for other examples of this type of calculation - put zero in this number of bytes starting at the address M: this clears all the n'th-row pixel bytes of the S oddlines; or if S is zero, 256d bytes are zeroed, ie a whole third. - when all these have been cleared, add 701h to the last M address cleared; this gets the address of the first of the n'th row of pixel bytes in the next third Eg the last third-row pixel byte of the first third is 4200h + 8 lines of 20h bytes - 1 = 42FF add 701h 42FF + 701h = 4A00 the first third-row pixel byte of the second third. - decrement 000XYPQRb; if PQRb, the number S of odd lines, isn't zero, this leaves XYb unchanged, but if it is zero it makes PQRb into 111b and decrements XYb - AND the result with 11111000b/F8h, which zeroes S and leaves 000XY000b, decremented if S was zero - if this isn't zero, jump back to the start of the loop;S is now zero, so this time it will clear the whole n'th row of the XYb'th third. - after one, two or three thirds, XY and so 000XY000b will be zero; recover the line number L, the same 000XYPQRb as we started with, and the original M address, and add 100h to M; this gives the start address for the next, (n + 1)'th, row of bytes for the whole L lines. Start all over again, and repeat the loop for all eight pixel rows. The rest of the subroutine sets the attribute bytes for the L lines; this is quite straightforward. Input parameters: B holds the number L of lines to be cleared. Action: call 0E9B CL ADDR to get the start address M - make a loop counter for eight turns of the loop. _0E4A_CL_LINE_1: stack L, M and the loop counter - put L in the A register. _0E4D_CL_LINE_2: move S = PQRb into the hi bytes; this isthe count of pixel bytes to be zeroed starting from M - zero the byte at M - use LDIR with a count of S - 1 to zero the following bytes; if S is zero, "S - 1" becomes 255d - add 701h to the last M; the start of the next third - decrement 000XYPQRb; it decrements XYb if PQRb is zero - AND the result with 11111000b/F8h - if the result 000XY000b isn't yet zero, jump back to CL LINE 2 to zero another third, still in the same turn of the loop - (the result is zero; all the n'th-row pixel bytes havebeen cleared) recover the start address - increment it by 100h; it addresses the next row of pixel bytes - recover the counter and 000XYPQRb - decrement the counter - if it isn't yet zero jump back to CL LINE 1 for the next turn of the loop - (all pixel bytes zeroed) call 0E88 CL ATTR, which returns the address of the first attribute byte to be cleared and the number to be cleared - get the attribute bytes from 5C8D ATTR P - if TV FLAG bit zero is zero jump on to CL LINE 3; these are the correct attributes for the main screen - (lower screen) get the attribute bytes from 5C48 BORDCR _0E80_CL_LINE_3: poke the attributes with the new value - recover the print position line number - set the print position column number to 21h. Exit: RET Output parameters: BC is the print position; the start ofthe first cleared line. Called from: 0D6E CLS LOWER 0DAF CL ALL 1795 AUTO LIST Exit from: 0DFE CL SC ALL 0E00 CL SCROLL CL LINE 1 0E4A (0E44 CL LINE) Jumps from: 0E4D CL LINE 2 CL LINE 2 0E4D (0E44 CL LINE) Jumps from: auto CL LINE 3 0E80 (0E44 CL LINE) Exit from: 0E4D CL LINE 2 (0E44 CL LINE) clock see 5C78 FRAMES, time period CLOSE (hatch) key (D4) see also commands, functions and operators, KEYBOARD SCANNING, 0284 extended mode key table (f) The 5 key in E mode with symbol shift produces the command CLOSE (hatch). It requires a single numeric parameter, the stream number. The command is read by 1B29 STMT L 1 referring through the syntax offset table 1A48 to the syntax parameter table 1A7A.1B02 P CLOSE causes a jump via 1C82 CLASS 06 - which gets the parameter - 1C10 CLASS 00 and 1C16 JUMP C R to the executive routine 16E5 CLOSE. CLOSE subroutine 16E5 see also channels and streams Called only by the statement loop from the syntax parameter table 1A7A; executes the command CLOSE (hatch). CLOSEs the nominated stream, ie zeroes its stream data. Only streams 04 -> 15 can be closed from BASIC. Streams -03 -> -01 cannot be handled, because a negative number will produce anerror report from 1E94 FIND INT1 called (misprinted) from STR DATA when it is called at the start of the routine. Streams 00 -> 03 cannot be closed, because instead of zeroing the stream bytes the subroutine reloads the standard offsets for channels K, K, S and P. Input parameters: none - the stream number is last value on the calculator stack. Action: call 171E STR DATA, which gets the stream number off the stack and finds the address of the first byte of the stream data at that stream address - call 1701 CLOSE 2; this is quite meaningless with the standard Spectrum - load a two-byte zero, which will be put in the stream data if closure is accepted - add A3E2 to the stream byte address, making a carry ifthe address is 5C1E or more; 5C1E is the base address of stream 04 - if there is carry jump on to CLOSE 1 - (the stream was 00 -> 03, HL is now FFF8, FFFA, FFFC or FFFE) add 15D4; the result is 15CC, 15CE, 15D0 or 15D2, whichare the addresses for the four streams in the "initial stream data" table in the ROM - get the two-byte offset for the stream data from the table. _16FC_CLOSE_1: put either zero, if closure is accepted, or the data from the initial stream table if not into the streambytes. Exit: RET. Output parameters: none. Rems: 1736 OPEN skips channel check if stream closed closed streams see channels and streams CLOSE STR 171C (1701 CLOSE 2) Exit from: 1701 CLOSE 2 close stream look-up table 1716 see tables CLOSE 1 16FC (16E5 CLOSE) Exit from: 16E5 CLOSE CLOSE 2 subroutine 1701 In the Spectrum without Interface 1, this routine achieves nothing. Input parameters: BC holds the stream data for the stream; see channels and streams - HL holds the address of the first byte of the stream selected by the CLOSE command. Action: find the appropriate channel data in the channel area - check the channel code with the "close stream look-up table"; there are three entries, all of which lead to the same jump address 171C. There is no end marker, so if the channel code was anything but K, S or P the program would crash; but it cannot be on the standard Spectrum - jump on to CLOSE STR. _171C_CLOSE_STR: clear the machine stack. Exit: RET. Output parameters: HL (unchanged) holds the address of the selected stream; confusingly called the "channel informationpointer" in the note. Called from: 16E5 CLOSE CLS key (FB) see also commands, functions and operators, KEYBOARD SCANNING The V key in K mode produces the command CLS, 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.1ABE P CLS causes a jump via 1C10 CLASS 00 and 1C16 JUMP C R to the executive routine 0D6B CLS. CLS subroutine 0D6B Called by the statement loop from the syntax parameter table to execute the command CLS; also called on start-up and NEW. Clears the whole screen and reforms the input area. Useful for m/c programs. Input parameters: none. Action: call 0DAF CL ALL to clear the screen. Exit: into 0D6E CLS LOWER, which clears the lower screen,makes it two lines, corrects and opens channel K and sets the print position at the top left of the cleared screen. Output parameters: none. Called from: 1219 RAM SET 1EB7 CLEAR 1 CL SC ALL subroutine 0DFE Entry point for 0E00 CL SCROLL after the "scroll?" prompt. Scrolls 23d lines up by one line, all but the bottom line with the "scroll?" prompt in it . Called from: 0CD2 PO SCR 3 CL SCROLL subroutine 0E00 Scrolls the screen once, ie moves a given number L of screen lines, counting from one at the bottom to 18h/24d at the top, up by eight pixel lines. See scrolling, and for the screen layout see DISPLAY AREA. This involves different treatment - for the seven "odd" lines of each third of the display after the first; all the top bytes of all the characters are moved back 20h places, ie up one line, then all the second-from-the-top bytes, etc down to the eighth byte; - for the top "first" lines of the second and the last third; the bytes of the first 20h characters at the top of each third boundary are moved back 720h bytes instead of 20h, to put them in the last line of the previous third; - for the "deleted" line above the top line to be scrolled, line L - 1; it disappears, overwritten by the next line. If L is the top line on the screen, its pixel bytes are "copied to the ROM"; the display area is the first section of RAM. Nothing can actually be copied to the ROM, so any pixel rows which are scrolled off the screen are simply thrown away.