Adaptation of programs for ZX Spectrum to TR-DOS by modern means. Part 2

  • Tutorial

In the first part of the article, we sorted the bootloader of the original version and found out where the game code is loaded and how it starts. Now you need to transfer the files to disk.


Floppy 5.25


This is usually done by simply copying the files, but there is one problem. The fact is that the original file contains the picture and the game code in a whole piece and, therefore, overwrites the area of ​​basic and system variables, which are located immediately behind the screen area. Such a file can be downloaded from tape, but cannot be downloaded from a floppy disk. TR-DOS reserves a certain memory area for your needs, and if you load data there, everything will break during the download process.


Fortunately, we have enough memory not occupied by the game. Therefore, the game can be downloaded to another place, and at the end of the download move to where you want and run. In this case, I would like to show the picture before the end of the download - for that it is also bootable. To do this, we’ll cut a monolithic file into two - screen area data and game data:


$ head -c 6912 headless.bin > screen.bin
$ tail -c +6913 headless.bin > data.bin

The game data file will immediately translate the hobeta format. Later we will need it for recording in the final image. To convert the formats we will use zxspectrum-utils and trd2hob:


$ binto0 data.bin 3
$ 0tohob data.000 # создаст файл data.$C

Loading screen


As for the boot screen, spend 6.75 kB on such a simple picture - waste. It can be properly compressed with a screen compressor, for example, Laser Compact 5.2 . To do this, you first need to write the image file to a temporary diskette image:


$ binto0 screen.bin 3
$ 0tohob screen.000
$ createtrd tmp.trd
$ hobeta2trd screen.\$C tmp.trd

After that, run Laser Compact in the emulator and save the compressed image to the same diskette (Pack screen → Save with depacker). When saving, specify the file name screenz.C. Next, you need to copy the compressed image from the floppy disk image back to disk. Unfortunately, trd2hobI could not find the source anywhere, so I have to run the DosBox binary from under:


$ dosbox -c "mount C $PWD" -c "C:" -c "trd2hob.exe screen.trd" -c exit

As a result, we get a hobeta-file of a view screenz.$Сwith a compressed picture.


In addition to native Spectrum utilities for screen compression, there are utilities for PCs, for example, zx7band zxsc. Although it’s more convenient to automate working with them, both of them have disadvantages before Laser Compact:


  1. Both lose in compression quality.
  2. When unpacking the picture, certain artifacts are visible when, as the Laser Compact fills the area of ​​the screen attributes almost instantly.
  3. zx7b does not support the creation of self-extracting archives - you have to additionally compile the decompressor.

Finally, we find out the size of the compressed file. We will need it later to write the bootloader.


$ lstrd tmp.trd 
80 Tracks, Double Side, capacity 640kB
Number of files/deleted: 2/0
Free sectors/bytes:      2509/642304
First free sector/track: 3/3
FILENAME      TYPE         SECTORS ADDRESS LENGTH TRACK SECTOR 
--------------------------------------------------------------
screen     CODE (BYTES)    27   16384   6912     1      0
screenz    CODE (BYTES)     8   40000   1812     2     11

As you can see, the file was compressed more than threefold and occupies 8 sectors on the disk.


In the next part, we will go directly to the bootloader.


Related links:


  1. “Adaptation of programs to the TR-DOS system” by Nikolai Rodionov.

Also popular now: