This short, clever technique allows you to put text on screen and then clear the screen below at will, leaving your messages intact.
After you've owned your Sinclair/Timex computer for a few minutes, you know that the bottom two lines on the screen are not available to you. Your computer needs them to send you report codes and to display the program line you are editing.
Here's a way to reserve as many lines as you need at the top of the screen for your own words. You can put instructions, reminders, warnings, and other messages there. Then, instead of using CLS in your program, you can use the USR command (a call to a six-byte machine language routine) to clear the screen of all but those top lines.
The machine language routine is easy to add to any program in the form of a REM statement that must be the first line in your program:
1 REM T?LN GSTAN
The six keystrokes after REM are: graphic T/?/function LN/G/graphic S/function TAN.
Before you can use this routine, you must POKE into it information on how many lines you want to protect at the top of the screen:
POKE 16515, 24-N
where N is the number of protected lines (and 24-N is the number of lines that are cleared).
Then, each time you want to clear only the lower portion of the screen, use:
RAND USR 16514
To see how easily this works, add these lines after the REM line and RUN:
10 FOR I=0 TO 20
20 PRINT AT I,0;I
30 NEXT I
40 PRINT AT 21,0;"N=?"
50 INPUT N
60 POKE 16515,24-N
70 PRINT AT 21,0;"PRESS ENTER TO CLEAR"
80 PAUSE 4E4
90 RAND USR 16514
Here is the assembly listing of the machine language subroutine:
|loads N into the B register
|calls CLS routine in ROM,
but skips 0A2A and
0A2B, which is ld b,24