Spectrum Turboloader
by Esben Krag Hansen
from Your Sinclair, May 1986


FAST FORWARD

When the Spectrum starts to load, it's time for most of us to nod off
- until now. This prime cut of code from Danish programmer Esben Krag
Hansen speeds up the whole process.


Have you ever felt you were about to peg out from old age waiting for
your Speccy to load? Well, this ingenious piece of machine code goes a
long way to solving the problem. With it, you can double the speed of
saving, loading, verifying and merging. And it does it by using
improved versions of the ROM cassette handling routines in which the
timing values can be changed, so giving you full control of the data
transfer speed. So, you can put away those pension books for a few
years yet!


FRIENDLY ... AND FAST

The program is very user-friendly - there's no need for all that
PEEKing and POKEing here. Type it in following the instructions, then
save it to avoid any mishaps - no-one's going to relish retyping all
those data statements! Now start it with RUN and you'll be asked
immediately for a start address. And the good news here is that the
turboloader is relocatable. You can enter any start address suitable
for storing the 1845 bytes of code and the loader program will
relocate the turboloader to run in that area. So, you'll have no
problems using the turboloader in conjunction with your other machine
code utilities.

When the loader program's finished, you should save the machine code
as instructed on the screen. Now you're ready to roll ...


SPEED SAVING

Using the program is simplicity itself. All you have to do is insert a
RANDOMIZE USR statement before the turboloader commands. It's this
that activates the turboloader's command interpreter. The turboloader
will now remain activated until it reaches the end of the line or a
command it doesn't recognise.

As an example, let's have a look at how you'd save a Screen$ using the
turboloader:

RANDOMIZE USR x: SAVE "test pic" SCREEN$

where x is the start address of the turboloader. And, of course, the
program supports all the usual cassette commands - SAVE, LOAD, VERIFY
and MERGE.

But stop, you're saying - at least, you are if you've just tried
executing the statement above. It's no faster at all. A-ha! (Famous
Scandinavian pop group? Ed). That's because I've yet to tell you how
to change the transfer speed - the baud rate. Initially, the speed is
exactly the same with or without the turboloader - 1500 baud (bits per
second). But you can easily change this using one of the four new
commands that the program adds to ZX Basic.

The problem is that while SAVE, LOAD, VERIFY and MERGE already exist
in Basic, where do we find keywords for the four new commands? I've
got round this by adopting four of the Speccy's existing keywords;
RUN, LIST, INPUT and PRINT. They all still work as normal except when
you're using them as commands to the turboloader. Then their new roles
come into play.


NOTE FOR TRAINSPOTTERS

Ha, thought you'd caught me out, didn't you? Doesn't he know, you're
saying, that the use of RANDOMIZE to call machine code makes the RND
function unusable? That every call actually resets the RND value to the
same number all the time?

Well, yes I do! And to get round this side effect, I've made it so that the
turboloader on return loads the BC-register with the value of the system
variable SEED. Then the RANDOMIZE USR command will only load SEED with the
value it already contains. And bingo, no effect on the RND function
at all! So, the whole problem is eliminated using a single machine
code instruction - LD BC (SEED) - that's only four bytes long.


FAST FOUR-WARD
The four 'new' keywords work in the following way:


LIST
This command reads a header from tape and lists it on the screen. For
example, LIST will display the start address and the length of a
machine code black. And that should keep the hackers happy!
If you want to see how the first two commands work, try:
RANDOMIZE USR x: RUN 3100: SAVE "me" CODE x,1845: LIST

PRINT
This command lets you choose just how much info you want on screen. It
should be followed by either a 0, 1 or 2.
0: Neither the baud-rate nor the names of the data blocks during
LOAD/VERIFY are printed onto the screen; ie. zilch!
1: Only the names of the data blocks are printed.
2: Everything is printed.

RUN
This now changes the baud-rates. It must be followed by a number
ranging from 1500 to 3500 inclusive, in steps of 200 (1500, 1700, 1900
and so on). The maximum baud-rate you can use all depends on your tape
recorder. But most of you should be able to run at a minimum of 3100
baud - more than double the normal speed.

INPUT
This is used in exactly the same way as PRINT. It deals with the
message "Start tape, then..." and then waits for a key in the SAVE
command. The values are used as follows:
0: The message isn't printed and you don't have to press a key.
1: The turboloader only waits for the key press.
2: As usual.
The turboloader is initially set to PRINT 2 and INPUT 2.

