Wednesday, April 17, 2019

State of GZX nextgen tape support

You may already know GZX, my humble venerable ZX Spectrum emulator. It runs on Linux/SDL, Windows, HelenOS and has a collection of interesting features (Spec256, MIDI, HiRes, AY file, I/O recording, child lock, ...) It is free software, under the terms of a BSD-style license.

I am trying to gradually modernize and improve the software. Currently I am in progress of revamping the tape support. Currently GZX tape is mostly read only. There is an abstraction layer that unifies TZX, TAP and WAV fiels (not all TZX block types are supported), above that we have a layer that either quick-loads data blocks into the Spectrum memory or synthesizes the tape audio to the virtual Spectrum's EAR. Separate from that, you can quick save blocks to a TAP file and that's it. This is very simple with very low use of memory (one version of GZX worked in 16-bit DOS, after all), but very limited. No way to browse the tape, modify it or convert files between different formats.

Now the goal is to move to a different model of in-core tape representation, where we load the file to memory, keep it in an editable format and then write it back to a file. The memory representation must represent all TZX features to allow for a perfect round trip. With this we can browse the tape, edit it and perform format conversions. After all RAM is somewhat cheaper today ^_^ and it is still possible to optimize the code to load stuff lazily from the file.

I have the basic scaffolding for the in-memory tape in place and now starting on TZX file loading. Once I can load and save a simple file, I can theoretically add a backend for the current tape support to read from this in-memory tape as a starting point for a switch over to the new system.

I will need to add complete support for loading/saving of all TZX blocks. This will be a challenge to test, so I guess I will probably need to fabricate some test files.

Progress on this has been painfully slow simply because I am working on other things most of the time (such as having Sycek compile C for ZX Spectrum, let's leave that for another day). With the basic tape and TZX work added in one commit in August last year and finally some progress on TZX loading yesterday. Hope I will be able to push this forward as tape support is one of the crucial big pieces.