SPECTRUM RAMDISK
Your Computer, July 1985

Ro Richardson with a piece of software to allow
fast loading on Your Spectrum.


THIS PROGRAM lets you load and save Programs and code very fast without
any extra hardware. It does this by using RAM to make a Ramdisc and by
defining new BASIC commands to access the disc. The new commands arc kept as
similar to the Spectrum's as possible, though many have no direct counterpart
in the tape system.

There is no limit to the number of files that can be saved on the disc, but
there is a limit to the total size of stored files. The Ramdisc usually
stores about 33K but this depends on where you put RAMTOP - by CLEARing. Each
file is stored with a 17 byte header as in the tape system.

To use the Ramdisc, type in the hex loader - listing 1 - SAVE it on tape and
RUN it. The data has checksums so any errors should be spotted. Once it runs
type:
	RANDOMIZE USR 63600
to switch on the new commands. A Ramdos - Ramdisc operating system - logo
should now appear on the bottom of the screen. The new commands are now
active. You can use any BASIC command without interfering with the Ramdos. As
the whole system is above RAMTOP, you can use NEW without losing the files
stored. The easiest way to save code to tape is with the *t command - see later.

All commands consist of an asterisk followed by a lower case letter, possibly
followed by parameters.

*l Load - must be followed by a file name as a string up to 10 characters. If
file name is null ("") then the most recently saved file of the correct type
- program or code - will be loaded. Options SCREEN$ and CODE are provided and
are exactly the same as the tape versions. DATA is not available.

*s Save - must be followed by a file name. The name may not be null. Options
CODE, SCREEN$ and LINE are provided and are the same as the tape versions.
DATA is not supported, but programs are saved with their variables. When a
file under the same name - and type - is already on the disc, it is
overwritten. The file is also moved to the top of the disc.

*m Merge - only works with program files; works the same as the tape version.

*d Delete - must be followed by a file name. You must specify CODE to delete
a CODE file. If the file name is null then the most recently saved file is
deleted.

*c Catalogue - has no parameters. It prints a list of all files on the disc in
exactly the same way as LOAD prints file names for the cassette system. It
also prints the number of available bytes on the Ramdisc.

*e Erase - erases the whole Ramdisc.

*t Tape - must be given a file name. It saves all the files on the Ramdisc and
the Ramdisc operating system to tape as a standard code file. This means that
you can save and load a whole environment in one chunk of code. To load the
file from BASIC:
	CLEAR 30000
or whatever value you are using,
	LOAD "" CODE
and then
	RANDOMIZE USR 63600
to switch on the new commands.

*f Free - prints the number of bytes free in the BASIC system, ie. below RAMTOP.
You may need this value when deciding where to place RAMTOP. To get the total
available space in the machine add this value and the value from catalogue (*c).

*x Block delete - deletes all BASIC lines in the given range including the
start and end lines. It is not strictly a Ramdos command, but is a very short
routine and should be useful.

In addition the NEW command has been redefined to print the new logo, and the
CLEAR command now checks that the new value of RAMTOP will not cause the
Ramdisc to be overwritten. In cases where this would occur, the report "Out
of memory" is given.

Error conditions and messages.

4 Out of memory - occurs when saving to the Ramdisc when there is not enough
space for the new file. The area to be reclaimed if the file already exists
is taken into account, so deleting the old copy will have no effect. Try
moving down RAMTOP by CLEARing. If it occurs during loading or merging then
there isn't enough space in the BASIC area for the program.

8 End of file - occurs when loading, merging or deleting a file which does
not exist - ie. the end of directory had been found without finding the file.
Sometimes occurs because you leave out the CODE when loading bytes.

The value of RAMTOP splits the available RAM into space for BASIC and space
for Ramdisc. A value of 30000 gives BASIC reasonable space and leaves 34K
for the Ramdisc. If you CLEAR too low BASIC will reject your RAMTOP, and if
you CLEAR too high you will get the "Out of memory" error.

The method used for redefining commands consists of two pieces. First, a copy
of the kernel of the ROM is made in RAM. The idea is that control will stay
in the RAM, just calling ROM routines when required. There is one snag, the
ROM routine Check-End 1BEE throws away its return address. To overcome this
some code is inserted in the error routine in case new commands fail the
syntax check.

Once this is done it is easy to define new commands, and I have left 25 bytes
free in the jump table in case you want to add some. Disassemble from 64381,
and move the instruction at 64422 down to accommodate your commands. If you
don't like the default colours of white on black, POKE 63714 with the
attributes you want.

The main use of this system will probably be for small BASIC programs under
development, and for keeping utility programs handy. It also enables you to
load and save screens very quickly, although you are limited to about four
screens. There are other not so obvious uses though.

After I had written the program I still had the problem of generating the hex
dump DATA statements It is easy to print what looks like a program listing,
but then you can't edit or run. I wrote a BASIC program to POKE the DATA
statements together with line numbers, line lengths and trailing ENTER bytes
into unused memory - just above RAMTOP - then saved this as a code file on
Ramdisc, poked around with the header to change it to a program, then loaded
the program.

If you want to have other machine code in the machine you could put it in the
printer buffer or UDG area if it is small enough. If it is too big you could
put it just above RAMTOP, and keep a careful watch on your Ramdisc size, or
save a dummy chunk of code to reserve an area in the Ramdisc.
