| STATUS LINE ROUTINES BY
ALGIE GRAY |
I am engaged in writing a BBS program for my A level project; a decision I am beginning to regret. While trawling through all my Public Domain BBS and Terminal programs, for inspiration, I noticed they all had one thing in common; a line or two along the top or bottom of the screen which held various pertinent information and was unaffected by scrolling. In other words a status line.
My original thought was to produce a 24 line screen with the top two lines protected from scrolling. I spent an entire Sunday trying to achieve this. I managed to protect the top two lines but I could not persuade the system to scroll only 22 lines worth of information. It insisted on inventing an extra two lines of info off the bottom of the screen (usually the actual program listing) which scrolled into the wanted information. Aaarrggghh! Finally a solution struck me; leave the 24 line screen alone and tag on an extra two lines with a custom display list (CDL). This idea was working within 15 minutes and a rewrite for Atari Basic, from the original Turbo Basic, is presented here.
Demonstration
Lines 1 to 175 are basically just to demonstrate the
use of the subroutines. However, in line 100 the string variable SL$ is
dimensioned to 80 characters. SL$ will be used hold any information to
be printed to the status line.Initializing
the Status Line
Lines 9000 to 9160 contain the subroutine to
initialise the status line.Line 9030 reserves and protects two pages of memory, for our purposes, above RAMTOP. Locations 106 and 740 both contain the number of pages (256 bytes) of memory available to the computer at powerup. By reducing the number held in location 106 by 2 the computer is fooled into thinking that the last two pages of memory do not exist. I have reserved two pages for a good reason. The screen memory is located just below RAMTOP and when the computer performs a "clear screen" all the memory from the start of the screen to RAMTOP is reset. However, because the ROM usually occurs above RAMTOP and this information cannot be altered, the "clear screen" function is a bit slapdash and will wander past the official RAMTOP. I am reliably imformed that this occurs by a maximun of 64 bytes but I shall leave a whole page as padding. Location 106 is updated in relation to location 740 to prevent your memory being eaten away, two pages at a time, if you run the subroutine more than once without a poweroff.
Line 9040 defines DL which holds the address of the start of our CDL, one page above RAMTOP.
Lines 9060 to 9090 poke the CDL into this final page of memory.
Lines 9100 to 9140 poke various address information into the CDL. More about this later.
Line 9150 effectively turns on the status line. Locations 560 and 561 are examined by the ANTIC chip to find the starting address of the display list. By poking the address of our custom display into these locations ANTIC will use our display list.
Printing
to the
Status Line
Lines 9500 to 9600 contain the subroutine to print
information to the status line.Status Line
Line 9530 checks locations 88 and 89 which contain the address of the start of the screen memory (the top left corner,TLC) in Hi-byte, Low-byte format. This information is used by the system to PRINT to the screen. The values presently in these locations are saved into the variables TLC1 and TLC2.
Line 9540 resets the screen margins to cover all 40 columns. If you are using different margins you will need to handle restoring your own values.
Line 9550 changes the pointers at locations 88 and 89 to tell the system that the screen memory now starts 50 bytes after the start of our new display list. As we only need 80 bytes for our two status lines there is plenty of room.
Line 9560 CLEARs out this area and makes sure that the cursor is POSITIONed at the start of the area.
Line 9670 simply prints SL$ into this area.
Line 9680 restores the pointers at locations 88 and 89 back to the normal 24 line screen area.
Finally, at line 9690 the normal 24 line screen area is CLEARed and the cursor set to the start of this screen. When SL$ was PRINTed to the status line the markers indicating the cursor location were still updated and consequently when you return PRINTing to the normal screen area the POSITION of the cursor can be a little unpredictable. I therefore find it easiest to reset the screen.
Display
List Data
Lines 9990 to 9994 contain the data for the CDL. I
do not intend to run through the total of instructions contained in
display lists as there are numerous and better descriptions available
elsewhere. I shall however breifly explain each element in our custom
list.There are 37 elements in the custom list. The first element, 112, is an ANTIC instruction to display eight blank scan lines. The second and third elements are instructions to display one blank line. This effectively gives a border of 10 blank scan lines at the top of the screen. A normal GRAPHICS 0 screen has three 112 instructions or 24 blank scan lines. This is where most of the space for the extra two status lines is found.
The forth element, 66, is a kind of composite instruction. It is made up of a 64 and a 2 (64+2=66). The 64 tells ANTIC that the next two elements will contain an address to start finding screen information and the 2 tells ANTIC that the first screen line of this information should be displayed as a GRAPHICS 0 line. The fifth and sixth elements in the data are dummies. The address information is set by lines 9120 and 9130 and ANTIC is directed to 50 bytes after the CDL to find the screen information. The seventh element is the instruction 2 on its own, to display the next screen line in GRAPHICS 0 format. The eighth element is not a dummy but another instruction to display one blank scan line. These first eight elements of the custom diplay list effectively define the status line.
Element nine is another composite 64 and 2 and the data for elements ten and eleven are again dummies. The correct values of these elements are set by lines 9100 and 9110 to point to the beginning of the normal 24 line screen memory. The next 23 elements are the ANTIC instructions, 2, to display GRAPHIC 0 lines. Finally there is a 65 instruction. This tells ANTIC to jump to the address contained in the next two bytes and re-execute the display list, i.e. it points ANTIC back to the start of the display list and for our CDL this is the start of the last page of memory. The elements of address information following are again dummies and line 9140 inserts the correct information into the CDL.
The program provided really is the bare bones and is intended for inclusion in your own projects. Turbo Basic programmers may wish to reinstate the original DPEEK and DPOKES. Please note that you can turn off the status line with any GRAPHICS command and back on again by the commands in line 9150.
It must be remembered that we are cheating the system into displaying two more GRAPHICS 0 lines than it wants. I have tested the routine on a portable television and a composite green screen monitor and it is reasonably stable on both of these. Only the green screen rolled once during initialisation (and this disappeared when using Turbo Basic.) I would be interested to know if non-PAL systems have problems. [None appeared when Bob Woolley reviewed the program. ed.] There may also be a loss of screen stability during disk accessing, but unless you intend to constantly use the disk drive this should not be a problem. This also seems to disappear with Turbo Basic.
Well, that is about it. Hope you find this of some use. If anyone would like to exchange programming hints and tips please write to me.
1 REM *****************************
2 REM * *
3 REM * STATUS LINE SUBROUTINES *
4 REM * by *
5 REM * Algie Gray *
6 REM * *
7 REM * For Atari Classic 1993 *
8 REM * *
9 REM *****************************
100 DIM SL$(80)
105 GOSUB 9000
110 SL$=" THESE TOP TWO LINES ARE TO"
115 SL$(28)="TALLY IMMUNE TO SCRO"
120 SL$(51)="LLING. PRESS A KEY TO L"
125 SL$(74)="I ST. "
130 GOSUB 9500
135 POKE 764,255
140 IF PEEK(764)=255 THEN GOTO 140
145 LIST :FOR N=1 TO 1000:NEXT N
150 SL$=" AND THAT IS ALL THERE IS T"
155 SL$(28)="O IT. HOPE THAT YOU "
160 SL$(51)="FIND THESE SUBROUTINES "
165 SL$(74)="HANDY. "
170 GOSUB 9500
175 END
9000 REM ****************************
9010 REM * SET UP THE STATUS LINE *
9020 REM ****************************
9030 POKE 106,PEEK(740)-2
9040 DL=(PEEK(106)+1)*256
9050 GRAPHICS 0
9060 FOR N=0 TO 36
9070 READ D
9080 POKE DL+N,D
9090 NEXT N
9100 POKE DL+9,PEEK(88)
9110 POKE DL+10,PEEK(89)
9120 POKE DL+4,DL/256
9130 POKE DL+5,50
9140 POKE DL+35,DL/256
9150 POKE 561,DL/256:POKE 560,0
9160 RETURN
9500 REM ****************************
9510 REM * PRINT TO STATUS LINE *
9520 REM ****************************
9530 TLC1=PEEK(88):TLC2=PEEK(89)
9540 POKE 82,0:POKE 83,40
9550 POKE 88,DL/256:POKE 89,50
9560 ? CHR$(125):POSITION 0,0
9570 ? SL$
9580 POKE 88,TLC1:POKE 89,TLC2
9590 ? CHR$(125):POSITION 0,0
9600 RETURN
9990 REM ****************************
9991 DATA 112,0,0,66,0,0,2,0,66,0,0
9992 DATA 2,2,2,2,2,2,2,2,2,2,2,2,2
9993 DATA 2,2,2,2,2,2,2,2,2,2,65,0,0
9994 REM ****************************