Re: Write binary data to TRD from ASM
Posted: Tue Dec 26, 2017 5:30 pm
Good to know. I've had a similar experience recently trying to figure out the (low-level) +3DOS stuff. Those multi-byte OUTs/INs, madness.
The community forum for all Sinclair users
https://spectrumcomputing.co.uk/forums/
Hi, I suppose that's because you typed "CODE" in the string as four separate characters instead of the single character 175.Seven.FFF wrote: ↑Wed Dec 13, 2017 7:39 pm I had been trying to get this one working too. This is the "official" API that passes tokenized basic commands to TR-Dos. I ran into issues with my tokenization - the stuff in my reference REM statements were being tokenised as "C", "O", "D", "E" etc and it was causing confusion with some other problems I was having at the same time. It clearly works in my basic loader though, so I could revisit this later. But I don't really need to.
Code: Select all
LET d = 15363 + 256 * PEEK (15363<>195)
Code: Select all
25000 034 093 092 LD (CHADD),HL
25003 205 003 061 CALL 15619
25006 042 181 097 LD HL,(TEMP)
25009 034 093 092 LD (CHADD),HL
25012 201 RET
25013 DEFS 2
Code: Select all
IF d = 15619 THEN POKE 25005,61
IF d = 15363 THEN POKE 25005,60
Code: Select all
LD HL, CHADD
LD (TEMP),HL
LD HL,BLOCK
CALL 25000
RET
BLOCK:
DEFB 234 ; REM
DEFM ":"
DEFB 239 ; LOAD
DEFB 34 ; "
DEFM "FILENAME"
DEFB 34 ; "
DEFB 175 ; CODE
DEFB 13 ; [ENTER]
Code: Select all
10 BORDER NOT PI: PAPER NOT PI: INK NOT PI: BRIGHT SGN PI: CLEAR VAL "24499"
20 LET d=VAL "15363"+VAL "256"*(PEEK 15363<>195)
30 RANDOMIZE USR d : REM : LOAD "ADB" CODE
40 RANDOMIZE USR VAL "24500"
Code: Select all
ORG 24500
KEY_VAL EQU 24587
CHADD EQU 23645
CALL CLEANER
LD HL, ADB_SCR
LD DE, 16384
CALL dzx7
LD B,150
CALL DELAY
LD A,(15363)
CP 195
JR NZ, MEMORY ; if PEEK 15363 <> 195 then a standard Beta Disk is connected
LD A,60
LD (KEY_VAL),A ; ...otherwise it is a clone and the location is modified
MEMORY:
LD A,(2899)
CP 165
JR NZ,ZX128
ZX48:
LD HL,(CHADD)
LD (TEMP),HL
LD HL,ADB48
CALL TRDOS
JP 32770
ZX128:
LD HL,(CHADD)
LD (TEMP),HL
LD HL,ADB128
CALL TRDOS
JP 32770
DELAY:
HALT
DJNZ DELAY
RET
CLEANER:
LD A,64 ; (64 for BRIGHT 1)
LD (23693),A ; PAPER 0, INK 0, BRIGHT 1
LD (23624),A ; the last two rows have INK and PAPER set to 0
CALL 3503 ; CLS
RET
TRDOS:
LD (CHADD),HL
CALL 15619 ; recalls the TR-DOS loading routine (the last byte here is KEY_VAL)
LD HL,(TEMP) ; reloads CHADD's original value in HL
LD (CHADD),HL ; restores CHADD's original value
RET
TEMP: DEFS 2 ; CHADD's original value is stored here
ADB48:
DEFB 234 ; REM
DEFM ":"
DEFB 239 ; LOAD
DEFB 34 ; "
DEFM "ADB-48"
DEFB 34 ; "
DEFB 175 ; CODE
DEFB 13 ; [ENTER]
ADB128:
DEFB 234 ; REM
DEFM ":"
DEFB 239 ; LOAD
DEFB 34 ; "
DEFM "ADB-128"
DEFB 34 ; "
DEFB 175 ; CODE
DEFB 13 ; [ENTER]
INCLUDE "dzx7_agileRCS.asm" ; Einar Saukas's RCS-ZX7 integrated decompressor
ADB_SCR: INCBIN "ADB-ZX7.bin" ; compressed loading screen