TRD boot loader

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Post Reply
User avatar
Seven.FFF
Manic Miner
Posts: 735
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

TRD boot loader

Post by Seven.FFF »

Splitting from this thread...

Trying to make a TRD boot loader using Windows utilities trdtool, bas2tap and tzx_display.

My build file:

Code: Select all

del jpj.trd
del boot.tap
del boot.tzx
del boot.txt
del boot_1.bin
del boot.
del boot.B
trdtool # jpj.trd
bas2tap boot.bas
tzx_display boot
ren boot_1.bin boot.B
trdtool boot.bas
trdtool + jpj.trd boot.B
where boot.bas is this:

Code: Select all

10 PRINT "Hello"
It almost works, but the header of the boot is wrong - left side is the wrong one, right side is one I made manually from TR-Dos. The 13 bytes of the Standard Data block after it is correct. What am I doing wrong?

Image

All the files.

I feel like I'm missing something obvious, or overcomplicating this!
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
Hikaru
Microbot
Posts: 100
Joined: Mon Nov 13, 2017 1:42 pm
Location: Russia
Contact:

Re: TRD boot loader

Post by Hikaru »

It looks like the 'bad' image has the file type set to 'b' as opposed to 'B'. The ASCII code for 'b' is 98, so that should at least explain the 'custom header type #98' thing. Something to do with trdtool perhaps? BASIC files need some spesshul treatment in TR-DOS in order to enable autostart from line N and whatnot (a special marker must be put after the program data, which shouldn't be accounted for in the file length), and I can't see any of this in the readme for trdtool. It might be just that it only supports adding regular CODE files or similar.
Inactive account
User avatar
Seven.FFF
Manic Miner
Posts: 735
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: TRD boot loader

Post by Seven.FFF »

Ah yes I bet you're right, thanks. I can see something in the code to capitalise .c to .C, so I could add that for .B too.

Not sure if I will be able to figure out the spesshul stuff as c++ is not my strong point, but I'll have a go :)
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
User avatar
Seven.FFF
Manic Miner
Posts: 735
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: TRD boot loader

Post by Seven.FFF »

I wonder if you need to add the spesshul stuff when the basic file is boot.B?

You don't need to tell TR-Dos what line number you want to start it from when you do a SAVE "boot", so I think I might be able to get away with just capitalizing the .B. Will try it.
Last edited by Seven.FFF on Fri Dec 08, 2017 7:39 pm, edited 1 time in total.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
User avatar
Seven.FFF
Manic Miner
Posts: 735
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: TRD boot loader

Post by Seven.FFF »

Ah, you do need it:

Image

I don't need to mod trdtool other than to do the extension capitalization and fixup the length. I can append the spesshul stuff before I add the file.

Is it documented somewhere? It looks like data not z80.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
Hikaru
Microbot
Posts: 100
Joined: Mon Nov 13, 2017 1:42 pm
Location: Russia
Contact:

Re: TRD boot loader

Post by Hikaru »

Yes, it's probably less relevant in the case of boot.B, the only difference I can think of is when it is loaded with LOAD or LOAD "boot". Otherwise, the default implied command for those is RUN.

Looking at my own loader, the autostart marker is #80 #AA placed after the final #0D at the end of the BASIC program. This is followed by the autostart line number as a little endian WORD (unlike the BASIC format that uses big endian). These four bytes should be saved together with the program data, but not add to the program length that is recorded in the file descriptor.
That '...5616' is just leftovers from executing the BASIC command to save the program, it's only there since the data is saved in chunks of 256 bytes.
Inactive account
User avatar
Seven.FFF
Manic Miner
Posts: 735
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: TRD boot loader

Post by Seven.FFF »

w00t, I've done it!

I fixed the extension (by capitalising the b and adding a trailing \r), and 5.03 loads and runs the boot file even without the spesshul stuff!

Source and TRD.

Cheers for that!
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
User avatar
Seven.FFF
Manic Miner
Posts: 735
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: TRD boot loader

Post by Seven.FFF »

Thanks! I will look at adding the data too. Much simpler than it looked.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
Post Reply