Loading from Tape
Klive can emulate playing back tape files with .tap
and .tzx
extensions. Before utilizing them with the LOAD
Basic command, select them with the Machine | Select Tape File function. This command opens a file selection dialog where you can select a .tap
or .tzx
file. You can select files with other extensions. In that case, the Emulator tries to read them as tape files, trying to parse them.
On successful read, you can issue a LOAD
Basic command (or use the Tape Loader from the startup menu of ZX Spectrum 128/+2E/+3E). The running LOAD
command will playback the selected file.
Note: You can change the tape file any time, even when the machine is stopped, paused, or running. The effect of such a change is similar to ejecting a tape from a physical tape player and inserting a new one.
Normal and Fast Load
Loading ZX Spectrum programs and tapes may take a long time, especially for large files. Besides the normal loading mode, Klive supports fast load, which reads the program instantly, in a fraction of a second.
You can turn on or off fast load with the Machine | Fast Load command or by clicking the Fast Load icon (rocket) in the toolbar.
You can change the Fast Load mode even while loading a game. However, the change will take effect only when you start loading a program next time.
Note: By default, fast load is turned on.
Revinding the Tape
When the loading completes or gets interrupted, the tape position stays as if you stopped the physical tape player. When you issue the LOAD
command again, the load operation starts searching the following file header from the position where it has been stopped.
You can rewind the tape to its beginning just as you can do it with a physical tape cassette. Click the Rewind icon in the toolbar (the one to the right of the rocket icon) or execute the Machine | Rewind Tape command.
Note: Klive allows you to examine the contents of a particular tape file. You can learn about it in the IDE documentation.
How Fast Load Works
The Fast Load mode applies a powerful technique: ROM hooking. While the emulator runs, it observes when the OS reaches a particular entry point of the load subroutine (by examining the value of the PC
register) in the ZX Spectrum ROM, including all ZX Spectrum models.
When the execution reaches the load routine, the Fast Load mechanism suspends the machine and injects the data from the tape file directly into the memory. While doing this, the algorithm sets the Z80 registers (including the flags) in the same way as the algorithm in the ROM.
When the data is loaded, the mechanism sets the current value of the PC
register to the exit point of the load routine as if the CPU has executed that and exits the fast mode.
If there is some error during the load, the fast load mechanism sets PC
to the beginning of the method that reports tape error.