;+3DOS function addresses
DOS_OPEN EQU #0106 ;Open file
DOS_CLOSE EQU #0109 ;Close file
DOS_ABAND EQU #010C ;Abandon file (force it closed)
DOS_READ EQU #0112 ;Read data
DOS_WRITE EQU #0115 ;Write data
GETBYT EQU #0118 ;Read one byte
PUTBYT EQU #011B ;Write one byte
SETPOS EQU #0136 ;Seek
GET_1346 EQU #013C ;Get memory allocation in 1,3,4,6
SET_1346 EQU #013F ;SET memory allocation in 1,3,4,6
DOS_MAPB EQU #0154
;<< v1.03 >> Map drive B: to unit 0 or unit 1
FILENO EQU #0C
;Arbitrary number from 0 to 15 for
;Z-code file. +3 BASIC uses 0-2
SAVENO EQU #0B ;File number for save file
TRANSNO EQU #0A ;Transcript file number
FLAGS3 EQU 23398
;<< v1.03 >> System variable holding no. of drives
;;;;;;;;;;;;;;;;;;;;;
;Transcript functions
IF p3dos
ts_open
LD A,1
;"Save as". This doesn't actually
;have any effect in the ZXIO version.
CALL ZXNAME
;Returns filename
LD A,H
OR L
SCF
RET Z
LD B,TRANSNO
LD C,2 ;Open to write
LD DE,#0204
CALL dodos
DEFW DOS_OPEN
RET NC
LD A,1
LD (tsflag),A
RET
ENDIF
IF p3dos
ts_close
LD HL,#1A
CALL ts_char
RET NC
LD B,TRANSNO
CALL dodos
DEFW DOS_CLOSE
RET NC
LD A,0
LD (tsflag),A
RET
ENDIF
IF p3dos
ts_char
LD A,(tsflag)
OR A
SCF
RET Z
LD A,(cwin)
OR A
SCF
RET Z
LD B,TRANSNO
LD C,L
CALL dodos
DEFW PUTBYT
RET
ENDIF
;;;;
;Verify the game file
p3vrfy
IF p3dos
XOR A
;<< v0.02 - border colour cycling
LD (activea),A ;>> v0.02
PUSH DE
PUSH BC
LD B,FILENO
LD HL,#40
LD E,H
;SET position just after header
CALL dodos
DEFW SETPOS
LD HL,0
POP BC
POP DE
vloop
PUSH BC
PUSH DE
PUSH HL
LD B,FILENO
CALL dodos
DEFW GETBYT
LD E,A
LD D,0 ;DE = byte just read
POP HL
ADD HL,DE
POP DE
POP BC
DEC BC
CALL activity
LD A,B
OR C
JR NZ,vloop
DEC D
LD A,D
CP #FF
JR NZ,vloop
LD A,(BORDCR)
; << v0.02 - remove traces of the
RRCA ;activity checker
RRCA
RRCA
AND 7
OUT (254),A
SCF
RET
;
;DEBUG
ELSE ;~p3dos
SCF
RET
ENDIF
hbuf
DEFB "000000",13,10,"$"
;
;<< v0.02 - cycle the border while
;verify is happening.
;
activity
;Do something every 1k
LD A,C
OR A
RET NZ
LD A,B
AND 3
RET NZ
LD A,(activea)
OUT (254),A
INC A
CP 8
JR C,activ1
XOR A
activ1
LD (activea),A
RET
;
activea
DEFB 0 ;>> v0.02
;;;;;;;;;;;;;;;;;;
IF p3dos
;;;;;;;;;;;;
;Numeric data
chgdsk
DEFW 0
;Original CHANGE DISK routine
unit_b
DEFB 0
;Drive B is unit 0 or 1?
old_1346
DEFW 0
;Original cache and RAMdisc settings
DEFW 0
p3dver
DEFW 0
;The version of +3DOS we are using
dosde
DEFW 0
;Used to store DE while entering +3DOS
tsflag
DEFB 0
;Transcripting on or off?
;One message (not really very informative)
p3der
DEFB "+3DOS error "
p3eno
DEFB "00000"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Utility function to call +3DOS, and
;expand any error returned to text.
;This takes an inline word parameter,
;the address within +3DOS that should
;be called.
dodos
LD (dosde),DE
EX (SP),HL
LD E,(HL)
INC HL
LD D,(HL)
INC HL
EX (SP),HL
LD (dosjmp + 1),DE
LD DE,(dosde)
CALL seldos
dosjmp
CALL 0
CALL sel48
RET C
PUSH AF ;Error no.
LD L,A
LD H,0
LD DE,p3eno
CALL spdec2 ;2-digit
EX DE,HL
DEC HL
SET 7,(HL)
;SET bit 7 on last character, since
;this is a fatal error message
LD HL,p3der
POP AF
RET
ENDIF
if p3dos
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Bank-switching code to take us to/from
;the +3DOS environment
seldos
PUSH AF
PUSH BC
LD A,(BANKM)
;RES 4,A
;OR 7
SET 4,A
AND #38
DI
LD (BANKM),A
LD BC,BANKIO
OUT (C),A
EI
POP BC
POP AF
RET
endif
IF p3dos
sel48
PUSH AF
PUSH BC
LD A,(BANKM)
SET 4,A
AND USED
LD BC,BANKIO
DI
LD (BANKM),A
OUT (C),A
EI
POP BC
POP AF
RET
ENDIF