In the first part of the article, we disassembled the original version downloader and found out where the game code is loaded and how it is launched. Now you need to transfer files to disk.
This is usually done by simply copying files, but there is one problem. The fact is that the original file contains a picture and a game code in a whole piece and, therefore, overwrites the area of ​​basic and system variables that are immediately behind the screen area. Such a file can be loaded from a tape, but cannot be loaded from a floppy. TR-DOS reserves a certain memory area for your needs, and if you load data there, during the boot process everything will break.
Fortunately, we have enough memory, not busy playing. Therefore, the game can be downloaded to another place, and after the download is complete, move where you need to and start it. In this case, I would like to show the picture before the end of the download - for that it is bootable. To do this, we cut the monolithic file into two - the data of the screen area and the game data:
$ head -c 6912 headless.bin > screen.bin $ tail -c +6913 headless.bin > data.bin
The file with the game data immediately translate hobeta format. Later we need it to write to the final image. To convert formats, we will use zxspectrum-utils and trd2hob
:
$ binto0 data.bin 3 $ 0tohob data.000 # data.$C
As for the boot screen, spend 6.75 kb on such a simple picture - waste. It can be 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 floppy image:
$ binto0 screen.bin 3 $ 0tohob screen.000 $ createtrd tmp.trd $ hobeta2trd screen.\$C tmp.trd
After that, run the 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 image back to the disk. Unfortunately, I could not find the trd2hob
source code anywhere, so I have to run the DOS binary from under DosBox:
$ dosbox -c "mount C $PWD" -c "C:" -c "trd2hob.exe screen.trd" -c exit
As a result, we obtain a hobeta file of the form screenz.$
with a compressed picture.
In addition to native Spectrum utilities for compressing screens, there are utilities for PCs, for example, zx7b
and zxsc
. Although it is more convenient to automate work with them, both of them have laser drawbacks before the Laser Compact:
zx7b
does not support the creation of self-extracting archives - you have to additionally compile the decompressor.Finally, 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 <C> CODE (BYTES) 27 16384 6912 1 0 screenz <C> CODE (BYTES) 8 40000 1812 2 11
As you can see, the file shrank more than three times and takes 8 sectors on the disk.
In the next part, we proceed directly to the bootloader.
Source: https://habr.com/ru/post/452542/
All Articles