|★ APPLICATIONS ★ DIVERS ★ Fast saving and loading on the CPC464 ★|
|Rsx - Fast Saving And Loading On the CPC464|Popular Computing Weekly)||Applications Divers|
Life in the fast lane
Fast saving and loading on the CPC464 brought to you by Brian Cadge
The CPC's cassette system is designed to save and load programs at a variety of speeds; two are available in Basic, 1000 and 2000 baud. However, even at the faster of the two speeds, saving a screen dump to tape takes nearly two minutes. This is mainly because all cassette data is written out, and read back in blocks of 2048 bytes long. Between each block there is an interblock gap and header of about five seconds. This is there to allow Basic to perform operations on the data read in (especially on text files). On long files of continuous data, such as screen dumps, these gaps simply waste time.
The program presented here adds two new RSX commands to Basic. These are FSave and |FLoad. They allow screen dumps (or any other block of data from memory), to be saved as one continuous block at the fastest safest speed of 2200 baud. This speeds up loading times dramatically; for example, the screen dump now saves and loads at twice the speed of the normal 2000 baud save/load commands. For longer sections of data the saving is even better.
You can save any other block of data by using the full format of the command as follows; f$= "Data File-1'': |FSave, @f$,30000,5000, the memory starting at address 30000 will be saved for 5000 bytes. A 30 byte header is saved before the data block, this contains the filename, start and length values. There will be no prompts to 'Press Play', etc, with these new commands. Pressing Esc will report an Input/Output error, as will faulty tape loads.
The |FLoad command has three formats. In its simplest form, |FLoad on its own will load in the first FSaved file it finds, regardless of filename. The following messages are output by the FLoad command; "Searching. . means that |FLoad is still waiting to find an |FSaved file.
"Found: filename" means that |FLoad has found the file 'filename' but this does not match the filename given, so it is being skipped over, and "Loading: filename" means that the file is being loaded.
The second format of the FLoad command is to follow it by the specific filename to be loaded, as in; f$= "Picture-1 ":FLoad,@£$ any file encountered before "Picture-1" will be skipped over. Finally, the third format of the |FLoad command is to add an optional '1' to the end as in; f$= "Picture-1": |FLoad, @f$,1. This tells the program not to print any messages, although Error messages are always printed. This last option is useful from within programs to stop a screen display being disturbed. It is logically similar to adding an '1' as the first character of a standard filename.
As different sync characters are used in the headers of the header and data blocks, the normal CPC cassette commands Load/Save/Cat, etc, will not recognise FSaved files and will skip over them, and similarly, |FLoad will not recognise files saved by the normal CPC commands and will skip over them.
To use the program, type in and save the Basic Loader program, taking care, as always, with the data statements. Once this has been Run successfully it can be Newed and the two new commands will be available until the machine is Reset or turned off. Of course, it is not worth loading in the new commands if you only intend to save small amounts of data, but for a program, such as a screen designer where screens are to be saved and loaded frequently, the time saved is well worth the effort of typing in the program.