Authors
Publication
Publication Details
Volume: 3 Issue: 4
Date
Pages
One of the ways that Basic is slow is in putting things on the screen. Have you ever played a game in Basic and you wanted things to zip across the screen, but, instead, they crawled? It is frustrating, but Basic is simply very slow in this department. In the 8K Basic SLOW mode, even something as simple as
10 FOR A = 1 TO 10
20 PRINT A
30 NEXT A
takes a long time. (Try it and you will see.)
You can speed up the process of putting something on the screen by using machine code, but, to do that, you must have some understanding of how the computer puts things on the TV. This is a little technical, but do not panic — it will not last long.
TV Guide
Somewhere in RAM there is a block of memory called the display file. This is where the computer stores what will go on your TV screen. Depending on how long your program is, the display file could be almost anywhere in memory. For example, when there is no program in the computer, the display file starts at location 16509 — near the bottom of RAM. With a 16K RAM pack and a long program, the display file might start way up around memory location 32000 — almost at the top of memory.
To put something on the TV screen, the computer has to know where the display file starts. It keeps track of that starting point as one of the “system variables.” The people at Sinclair call this particular system variable “D-FILE” (for “display file”), and it is at the same place for 4K and 8K Basic — memory locations 16396 and 16397.
Any time you want to know where the display file begins, just look at those two memory locations. In Basic, you can do it like this:
PRINT PEEK (16396)+256*PEEK (16397)
Notice that you must multiply what is in the second memory location by 256, and add it to what is in the first memory location. This is similar to the way you load a number into a register pair in machine code— first comes the remainder, then comes the quotient.