Scrolling that screen window
by J Elliott
from ZX Computing February 1983 Page 63

Scrolling that screen window

J Elliott from Gloucester describes some machine code routines he has
developed to emulate some screen controls available on more sophisticated
computers.

As a teacher I have access to both an RML 38OZ and 48OZ in the course
of teaching Computer Studies. These computers allow fairly easy screen
control. In particular they allow the definition of "screen windows" at
any point on the screen. These windows may be scrolled independently of
the remainder of the screen. In addition to this. the "GRAPH" command
restricts scrolling to the bottom four lines of the screen.

My own ZX 81 does not have these facilities. The "PRINT AT" command is
the greatest equivalent. I decided  attempt to emulate these facilities
with machine code subroutines. The three routines to be described
increase the screen handling of the ZX81 quite considerably.

The first routine defines a rectangular window of any size at any point
on the screen. Once defined, the window can be instantly filled with any
character, or cleared, simply by calling the routine. Any of these
parameters can be changed at any time from the master program. This means
that several different windows can be used with the same program.

The second routine uses the same principle as the first. A window is
again defined -- any size and any position on the screen. When the
routine is called, the contents of the window are scrolled up through
one line and the last line is cleared. The routine can be set to fill
the last line with any character instead of clearing it.

The last routine is a very simple screen reverse. Every character on the
screen is removed and replaced with its inverse. This is very effective
for explosions.

Using the routines

The easiest way of using the routine is as follows:

Save 114 bytes of high memory by poking addresses 16388 and l6389 with
a new value for RAMTOP. With a 16K machine, suitable values are:

POKE 16388,140  POKE 16389,l27.

If you now enter "NEW" you will have the space above 32652 free for the
machine code.

Now reload listing 4 and ’RUN'. The code will be loaded to the area of
memory you enter when prompted by the program. You will now he promoted
to enter size and positions for your window or scroll window and also fill
character. Having done this you are offered the option of redefining, testing
or ending the program. When you end the program is automatically
"NEWed" so that you can easily enter the BASIC code which will call the
routines.

To call the routines, the following commands can be inserted at any point
in the BASIC:

i) Fill or clear window - LET L=USR START

ii) Scroll one line of window - LET L=USR (START+39)

iii) inverse screen - LET L=USR (START+94)

Where START is the start address of the machine code which must have been
previously loaded the parameters of the windows can he changed easily
from within the BASIC program using the routines, by 'POKEing' the
following addresses with suitable values:

Fill window

(START+5)  = last line of window
(START+7)  = number of lines of window
(START+20) = 32-start column of window
(START+25} = columns from end of window to line end
(START+30) = fill character code

Scroll window

(START+44) = last line number in window
(START+46) = number of lines in window
(START+59) = 32-start column number
(START+64) = columns from end of window to line end
(START+85) = scroll character code

The program shown in listing 5 demonstrates how this is done. It produces
random windows and fills or scrolls them with random characters.
It can produce some quite effective patterns!

Memory

To run the routines as described you need at least 3.5K of memory. Those
of you with less than this will need to create a display file by "PRINTing"
spaces to the screen before you attempt to use the routines.