SCROLL YOUR OWN
by Leif Kvernhusvik
from ZX Computing December 1986

A short m/c routine that can be used in your own programs.


[NOTE: The code is loaded into the printer buffer at 23296, so it will not]
[work on a 128K Spectrum. If it's moved elsewhere the absolute addresses  ]
[used in the code would need to be altered to take account of the new     ]
[position before it would work. A routine was published in the "Shortcuts"]
[section a few months later to resolve this (see below).              JimG]


Here's a short machine code routine which uses the Spectrum's DEF FN
facility to allow you to scroll text across any line of the screen, in
any colour, and in a variety of character widths. Although you can
scroll text using different character widths, the best results are
obtained using the lower two lines of the screen, because of the way
that the screen display is mapped in memory.

Listing 1 Is a BASIC loader program, containing all the machine code
in DATA statements, while listing 2 is a short program demonstrating
how to use the routine. In listing 2, line 10 sets up the width,
colours and line number for the text, line 20 defines the actual text
itself, and line 30 starts the scrolling routine.

For the smartypants amongst you, listing 3 [see SCROLLYO.ASM] is the
assembler listing which gives full details of the machine code
routine. Normally, the routine, once started, can be interrupted by
pressing a key, but the following POKES have different effects:

POKE 23421,201 - the program returns to BASIC when a key is pressed or
when the text has finished scrolling.

POKE 23414,0: POKE 23421,201 - the program cannot be interrupted, and
only returns to BASIC when it has finished.

POKE 23414,192: 23421,195 - the program will only return to BASIC when
a key has been pressed.


= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =


[Extract from "Shortcuts", ZX Computing March 1987.                     ]
[Note that I have not tested this routine.                          JimG]

Scroll Relocate

One of the things I like about this column is the way readers often
send in and share modifications of previous programs. R Dorsett of
Middlesex sent us a short cut which solves a problem he found with
Leif Kvernhusvik's Scroll program in the Dec.86 issue.

The original program is located in the printer buffer, not good news
for printer owners, so Mr Dorsett's program will relocate it to any-
where in memory that you may desire.

First (providing you have a M/C copy of the program on tape) CLEAR 
RAMTOP to the new start address - 1. As an example we will imagine
that we are going to move the routine to address 60000, therefore
CLEAR 59999.

Now LOAD "SCROLL" CODE newaddress (eg. LOAD "SCROLL" CODE 60000).
Type in the RELOCATE program and run it. Finally SAVE "SCROLL" CODE
newaddress,159 (eg. SAVE "SCROLL" CODE 60000,159). Don't forget to
change the line in your program which defines the function to call
the new address (eg. DEF FN x(a$,l,w,a)=USR newaddress).

Some alterations to the way in which the program works can also be
made: POKE start+125,201 will return the program to BASIC if a key
is pressed or when the scrolling is finished. POKE start+118,0:
POKE start+125,201 prevents the program from being interrupted and
returns to BASIC when finished. POKE start+118,192: POKE start+125,195
and the program will only return to BASIC when a key is pressed.

9899 REM Scroll Relocate
9900 INPUT "Start Address ";s
9910 FOR n=1 TO 7: READ a,b: LET a=a+s: LET b=b+s
9920 POKE a,b-256*INT (b/256): POKE a+1,INT (b/256)
9925 NEXT n
9930 DATA 10,128,27,144,30,159,59,161,70,159,73,161,126,0


--
Another Fine Product transcribed by:
Jim Grimwood, Weardale, England (http://www.users.globalnet.co.uk/~jimg/)
--
