Write binary data to TRD from ASM

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

Re: Write binary data to TRD from ASM

Post by Seven.FFF » Mon Dec 11, 2017 2:19 pm

Hi @Hikaru, I wonder if you could link me to your copy of 'ZX-Spectrum & TR-DOS Для пользователей и программистов', if you have it as a scan. The one I have only goes up to page 114. It's either a different book or it's missing all the good stuff :)
0 x
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
seven-fff.com/blog

User avatar
Ast A. Moore
Manic Miner
Posts: 668
Joined: Mon Nov 13, 2017 3:16 pm

Re: Write binary data to TRD from ASM

Post by Ast A. Moore » Mon Dec 11, 2017 2:42 pm

Psst, @Seven.FFF. Boing.
0 x
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.

User avatar
Seven.FFF
Manic Miner
Posts: 283
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Write binary data to TRD from ASM

Post by Seven.FFF » Mon Dec 11, 2017 2:46 pm

Ha, thanks! That's the one I have. I translated the TOC (and the first 20 pages), and I think there is nothing about TR-Dos at all in this book. Even the cover says "ZX Spectrum for users and programmers, no mention of TR-Dos.
0 x
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
seven-fff.com/blog

User avatar
Ast A. Moore
Manic Miner
Posts: 668
Joined: Mon Nov 13, 2017 3:16 pm

Re: Write binary data to TRD from ASM

Post by Ast A. Moore » Mon Dec 11, 2017 2:54 pm

Seven.FFF wrote:
Mon Dec 11, 2017 2:46 pm
Ha, thanks! That's the one I have. I translated the TOC (and the first 20 pages), and I think there is nothing about TR-Dos at all in this book. Even the cover says "ZX Spectrum for users and programmers, no mention of TR-Dos.
@Seven.FFF
You just don’t know how to cook it. Chapter 24. ;)
0 x
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.

User avatar
Seven.FFF
Manic Miner
Posts: 283
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Write binary data to TRD from ASM

Post by Seven.FFF » Mon Dec 11, 2017 2:58 pm

Yay that's it, thanks.

He wrote two different books, ISBN 5-7190-0025-9 (Spectrum and TR-Dos) and 5-87472-004-9 (just Spectrum). The online text is on your link is correct, but the download is linked to the wrong book, ha.

Ta!
0 x
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
seven-fff.com/blog

User avatar
Seven.FFF
Manic Miner
Posts: 283
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Write binary data to TRD from ASM

Post by Seven.FFF » Mon Dec 11, 2017 3:00 pm

Anyway my asm calls aren't working, even Hikaru's reference asm load example. My basic calls work fine. At work now but I will try and debug later.
0 x
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
seven-fff.com/blog

User avatar
Ast A. Moore
Manic Miner
Posts: 668
Joined: Mon Nov 13, 2017 3:16 pm

Re: Write binary data to TRD from ASM

Post by Ast A. Moore » Mon Dec 11, 2017 3:31 pm

Seven.FFF wrote:
Mon Dec 11, 2017 2:58 pm
The online text is on your link is correct, but the download is linked to the wrong book, ha.
Whoopsie. Didn’t notice the download link at all.
Seven.FFF wrote:
Mon Dec 11, 2017 3:00 pm
Anyway my asm calls aren't working, even Hikaru's reference asm load example. My basic calls work fine.
Mating calls of other species are notoriously difficult to master. Many have tried. Many have failed.
1 x
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.

Hikaru
Microbot
Posts: 100
Joined: Mon Nov 13, 2017 1:42 pm
Location: Russia
Contact:

Re: Write binary data to TRD from ASM

Post by Hikaru » Mon Dec 11, 2017 6:05 pm

Seven.FFF wrote:
Mon Dec 11, 2017 2:19 pm
Hi @Hikaru, I wonder if you could link me to your copy of 'ZX-Spectrum & TR-DOS Для пользователей и программистов', if you have it as a scan. The one I have only goes up to page 114. It's either a different book or it's missing all the good stuff :)
Heys. This is the scanned version that I'm using. But it's in .DJVU format, not sure if that's useful for google translate and whatnot. Like Ast said, it should be available to read online at zxpress.ru as well, although their OCR quality tends to leave much to be desired.

Seven.FFF wrote:
Mon Dec 11, 2017 3:00 pm
Anyway my asm calls aren't working, even Hikaru's reference asm load example. My basic calls work fine. At work now but I will try and debug later.
One reason might be because, as a general rule, code like that or similar using #3D13 functions is intended to execute after the DOS is fully initialized, for instance as part of a loader. So for instance if you just run it from a snapshot, it is very likely not going to work.

Actually, this is something I'd like to know myself, because there's supposedly an 'init' function located at 15649 that is responsible for initializing the TR-DOS system variables (mentioned at p.190), but I've never had any success with it alone. Perhaps it needs something else besides that.
0 x
Inactive account

User avatar
Seven.FFF
Manic Miner
Posts: 283
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Write binary data to TRD from ASM

Post by Seven.FFF » Tue Dec 12, 2017 1:01 am

I've made a little progress. The error returned in $5D0F was 1 No file. i wasn't padding my filename with spaces in the file descriptor.

Now I get error 12 The channel is not open in $5D0F. But I have already been using TR-DOS - the code this is running from is loaded from basic with a TR-Dos call, so Dos must be initialised, surely?

My (rather chunky) basic loader looks like this:

Code: Select all

10 CLEAR 32767: BORDER 0: PAPER 0: INK 7: BRIGHT 1: FLASH 0: CLS 
20 PRINT AT 7,9; INK 2;"j"; INK 6;"e"; INK 3;"t"; INK 5;" p"; INK 2;"o"; INK 4;"w"; INK 3;"e"; INK 6;"r "; INK 3;"j"; INK 5;"a"; INK 6;"c"; INK 4;"k"; INK 7;AT 10,12;"LOADING..";AT 12,11;"3ArPy3KA...": PLOT 106,77: PLOT 106,78: DRAW 4,0: PLOT INVERSE 1;107,77: DRAW INVERSE 1;2,0: PLOT 121,78: PLOT 125,78: PLOT INVERSE 1;121,75: DRAW 3,0: PLOT INVERSE 1,122,74: DRAW INVERSE 1;2,0
30 RANDOMIZE USR 15619: REM :LOAD "jpj04" CODE 32768
40 RANDOMIZE USR 32768: RANDOMIZE USR 15619: REM :LOAD "jpj01" CODE 32768 
50 RANDOMIZE USR 15619: REM :LOAD "jpj02" CODE 56323
60 RANDOMIZE USR 15619: REM :LOAD "jpj03" CODE 65380
70 RANDOMIZE USR 32768
Nothing here loads any lower than $8000 [actually my stack is just below $8000, but surely it doesn't go down far enough to cause a problem with TR-Dos?], and it all gets loaded and runs fine.

Part of the code in jpj01 is my asm loader, which ends up at $AA00 and looks like this:

Code: Select all

                        di
                        ld hl, FileDescriptor
                        ld c, $13                       ; #3D13 C=#13: copy the file descriptor to TR-DOS system variables
                        call $3D13
                        di
                        xor a
                        ld ($5CF9), a                   ; #00: load, #FF: verify
                        dec a                           ; load the file to an address in HL
                        ld hl, $8000
                        ld c, $0E
                        call $3D13                      ; #3D13 C=#0E: load/save file
                        ei
                        ld a, ($5D0F)                   ; TR-Dos error is reported back here as "12 The channel is not open"
                        jp $8000                        ; This is supposed to be the code in jpj06. But it never gets loaded here.
FileDescriptor:
                        db "jpj06   "                   ; 8 characters
                        db "C"                          ; file type: code
I’m in IM 1 when it runs, and I’ve tried it with interrupts both enabled and disabled. I made sure it was in unpageable memory in case something was getting switched out unexpectedly.

The code in jpj06 is just a trivial test designed to be highly visible.

Code: Select all

BorderTest:             ld a, 2
                        out ($FE), a                    ; Magenta border
                        ld a, 5                         ; then
                        out ($FE), a                    ; Cyan border
                        jp BorderTest                   ; forever...
                                                        ; Actually this needs to be jr BorderTest, because I relocate the code,
                                                        ; but it's moot because it never gets loaded :(
This is my sadface TRD image. The failing loader runs when you hit the 0 key on the menu. Pentagon 128 only - the multicolour timings don’t work with Scorpion.

Any idea at all what gives?
Last edited by Seven.FFF on Tue Dec 12, 2017 2:21 am, edited 5 times in total.
0 x
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
seven-fff.com/blog

User avatar
Seven.FFF
Manic Miner
Posts: 283
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Write binary data to TRD from ASM

Post by Seven.FFF » Tue Dec 12, 2017 1:17 am

Hikaru wrote:
Mon Dec 11, 2017 6:05 pm
Heys. This is the scanned version that I'm using. But it's in .DJVU format, not sure if that's useful for google translate and whatnot. Like Ast said, it should be available to read online at zxpress.ru as well, although their OCR quality tends to leave much to be desired.
THanks, perfect! Now I can read the code cleanly at least.

I tried OCRing a few pages with Tesseract high-quality Russian training data, and the results were not great either. I think it needs special training for that font.
0 x
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
seven-fff.com/blog

Post Reply