Using the tape

This emulator can load programs that are saved to tape in the usual way, but also speed-saved programs can be loaded. Furthermore, you can also make a disk file act as an `emulated tape', so that the normal SAVE and LOAD commands can be used to transfer data to and from disk easily.

Let's first discuss the saving and loading of programs using a tape recorder—that'll be the first thing you want to do, to transfer your programs to the PC. First of all, you need an interface to connect the tape recorder to the PC. The parallel printer interface is used for this. All you need is a very simple and cheap piece of electronics to get the input and output signals at the appropriate and safe levels; the circuit diagram is in the program DIAGRAM.Z80. The interface has to be calibrated; a program to help doing this is contained in the snapshot file. Adjust the variable resistor so that when the tape recorder is played at normal volume, the bar points just below 50%. When the tape recorder is turned off, the bar should go to 0%.

You have to tell the emulator which LPT port you use for tape I/O. This can be selected in the tape menu, but it can also be specified on the command line or in the Z80.INI file with the -b switch; for instance -b2 selects LPT2. Default is LPT1.

There are two ways to load programs: in `real' or normal mode. In real mode, the emulator doesn't update the screen or scan the keyboard anymore, so that the emulated Spectrum program can run smoothly. The emulator has to run at about 100%, but then you're able to load everything a normal Spectrum would load, including speed-saved programs. The only thing you see on screen are the loading bars in the border (on EGA or VGA screens). Real mode is selected by pressing F6. Saving programs in real mode is a bit useless but it works; enter the SAVE command, press a key to start saving and quickly press F6 when the saving starts. It will continue in real mode.

If your computer is just fast enough, don't slow the emulator down too much. Because the IN instruction is relatively slow, the emulator has to run at about 110% for the best results. If your computer is really fast, you can best slow it down to exactly 100%. If your computer is just a bit too slow, you can try to make your tape recorder run slower too (usually you can do this by adjusting a little screw at the back of the motor), I successfully loaded several speed-saved programs at 90%.

In normal mode, the standard ROM loading and saving routines are `trapped' (at addresses 04D8 and 056A) when they're about to start saving or loading. A routine in the emulator itself then takes over, and loads or saves a block to tape or a disk file. By default, this routine uses the tape instead of a file, and I'll discuss that mode of operation first.

Using these SAVE and LOAD routines has a great advantage as well as a disadvantage compared to using the Spectrum's own routines in real mode. The advantage is that the internal routines work on every machine, no matter how slow or fast, without having to make the emulator run at 100%. The disadvantage at using them is that they obviously won't understand speed-saved files. For normal use, these internal routines work much easier, and real mode loading is only necessary for speed-saved and very well protected programs.

So far for the general information about tape loading.

The emulator uses files with the extension .TAP to hold a piece of `tape', with several blocks on it. Each block is usually either a header or a data block; a normal file thus consists of two blocks. There are two modes of operation when loading and saving to disk files, single and multiple .TAP file mode.

In single .TAP file mode, each block saved is appended to the end of the .TAP file, like would happen if you were actually saving to tape. In the same way, when loading in single file mode, each time the ROM wants to load a block, it is presented the next block in the .TAP file. It is handled as it would if the block was loaded from tape, that is, if the ROM needs a header and is presented a data block, it will skip it. The header will however be considered to be read. So, entering LOAD "rubbish" will show all headers in the .TAP file, just as an ordinary Spectrum would show all headers on the tape if you left the tape running.

If the last block is loaded, the file pointer is moved to the start again. So a .TAP file can be considered to be an infinite tape. Single .TAP file mode is useful to save whole programs to disk, or for multi-load games that need to load in levels as you play.

A sort of `random access' file management would also be useful, for instance when you're developing a program and need to save several pieces of data to disk and later load back a specific one. This can be done in single .TAP file mode (by positioning the file pointer using the Browse function), but there's a different mode of operation that makes things easier: multiple .TAP file mode. In fact, by default the emulator is in this mode.

When the emulator is in multiple .TAP file mode, it will read all blocks from all .TAP files in a specified directory, one after the other. When it has finished reading the last one, it will start all over again.

When saving, the emulator will put the two blocks of a normal file, the header and the data block, in one .TAP file with a unique name made up of the printable letters of the file name and a two-digit number. The name of the .TAP file is irrelevant to the emulator, but to have it resemble the name of the actual Spectrum file you saved is simply convenient. If the Spectrum program saves a data block to tape without first saving a header, the .TAP file will contain only this data block, and the DOS file name will be HDRLES, with a two-ditit number appended to make it unique. The format of the .TAP files saved in multiple .TAP file mode is exactly the same as the format used in single .TAP file mode.

You can easily string together .TAP files; for instance a number of .TAP files created in multiple .TAP file mode can be put into one big .TAP file simply by copying them together, e.g.
 COPY /B FILE1.TAP + FILE2.TAP ALL.TAP
(Note: in some versions of DR DOS the /B switch, necessary because otherwise copying stops after a CTRL-Z character, doesn't work properly; load your old COMMAND.COM to copy the files).

Now you know what you can do, but how to get the emulator to do it? That's what the final section is about: the tape menu.

Press F7 to enter the tape menu. Pressing S will select or de-select single file mode. By default, multiple .TAP file mode is selected. In this case, there are three other possible choices in this menu. First of all, D selects a tape-file directory where the .TAP files will be saved into and loaded from. A default directory can be selected by putting the -xs switch on the command line or in the Z80.INI file; for example -xs c: \spectrum \taps selects that directory.

The I and O options are used to select the source and destination of the saving and loading: the LPT port for a physical tape recorder, or `disk' for disk files. By default LPT1 is selected; another LPT port can be selected with for instance -b2 or by pressing I and O. Input and output are directed to disk by default if a default tape file directory is given by means of a switch on the command line or .INI file.

If Single .TAP file mode is selected, different and more menu options appear. With G and P, the input and output tape files can be selected. They may be the same. If a specified output file already exists, you may choose to append to or overwrite this old file. Saving is always at the end of the file; loading always starts at the beginning of the .TAP file.

With the B option - Browse - the position of the file pointer into the input .TAP file can be changed. If you, for instance, type LOAD"" instead of LOAD "" CODE, the first header is read, and you would have to read all other headers before trying to load the file again. With the browse option you can conveniently change the file pointer. Of every header (that is, every block with flag byte 0 and length exactly 17) the name and type, and of every data block the length is shown.

The option B can also be used to delete specific blocks from a .TAP file. Make sure you do not only delete a data block or a header, or the ROM may get confused! (Double data blocks will be skipped, but double headers can generate Tape Loading errors).

As in multiple .TAP file mode, I and O are used to specify the source and destination for saving and loading. If you enter a .TAP file name with G or P, this will automatically be set correctly. You can then always reset the input or output back to LPTn again, of course.

Finally, in Single .TAP file mode you can use `tape mirroring': loading programs from tape (in normal mode, i.e. not using Real mode) and at the same time saving a copy of each block loaded into a .TAP file. This .TAP file can later be used to load the program again, might anything go wrong. There are two ways of mirroring: normal mirroring and exact mirroring. The last one must be used only in exceptional cases; it will always make a copy of a block, even if it had a tape error (the corresponding block in the .TAP file will also have a tape error). This causes ticks in leader tones to make 0-byte blocks, so the .TAP file may get messy. Do not use exact mirroring if you don't really have to; I think normal mirroring will always work in practice.

If you try to leave the tape menu when for instance tape mirroring is selected, and no output filename is given, the emulator will warn you and will insist that the error be corrected. Yes, it's stubborn!