passport/src/rwts.a

67 lines
2.1 KiB
Plaintext
Executable File

;-------------------------------
; ReadSector
; high-level function to read a single sector.
; in: gIsProtDOS is TRUE or FALSE
; if gProtDOS is FALSE, callrwts+2 has been set to
; the RWTS entry point (e.g. $BD or $3D or $FD)
; if RWTS is in LC RAM, the appropriate RAM bank
; has already been selected for read/write access
; out: all registers clobbered
; C clear if read was successful
; C set if read failed
;-------------------------------
ReadSector
lda #$AA ; lots of custom RWTS routines
sta $31 ; need these zero page locations
lda #$AD ; set to magic values
sta $4E
lda gIsProtDOS
beq _protread
ldy #<gRWTSParams
lda #>gRWTSParams
callrwts jsr $FF00 ; modified at runtime (see Inspect1)
rts
;
; "Protected.DOS" has enough differences that we just
; split everything out here. The hi/lo RWTS parameter
; table address is set in A/Y instead of Y/A. The
; RWTS entry point is $BA00. The third data prologue
; nibble is stored in zp$4E and varies based on track
; and sector.
;
_protread
lda gTrack ; T02,S05+ use "protected" mode
cmp #$03 ; (altered data prologue and
bcs protected ; nibble translate table)
cmp #$02 ; T00,S00 - T02,S04 use
bcc standard ; "standard" mode
lda gSector
cmp #$05
bcs protected
standard
lda #$9B
sta $BF2C
bne go ; unconditional branch
protected
lda #$B5
sta $4E
lda #$D5
sta $BF2C ; execution falls through here
go
lda #<gRWTSParams
ldy #>gRWTSParams
jsr $BA00 ; note non-standard entry point
rts
gRWTSParams ; used to read each sector
!byte 01,$60,01,00
gTrack !byte 00
gSector !byte 00
!word dct
gAddress !word $1F00
!byte 00,00,01,00,$FE,$60,01,00,00
dct !byte 00,01,$EF,$D8,00