2017-01-08 03:35:35 +00:00
|
|
|
;-------------------------------
|
|
|
|
; 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
|
2017-09-30 17:55:20 +00:00
|
|
|
; the RWTS entry point (e.g. $BD or $3D)
|
2017-01-08 03:35:35 +00:00
|
|
|
; out: all registers clobbered
|
|
|
|
; C clear if read was successful
|
|
|
|
; C set if read failed
|
|
|
|
;-------------------------------
|
|
|
|
ReadSector
|
2017-10-08 21:54:03 +00:00
|
|
|
;
|
|
|
|
; Lots of custom RWTS routines need these zero page locations
|
|
|
|
; set to magic values. Always the same values though!
|
|
|
|
;
|
|
|
|
lda #$AA
|
|
|
|
sta $31
|
|
|
|
lda #$AD
|
2017-01-08 03:35:35 +00:00
|
|
|
sta $4E
|
2017-10-08 21:54:03 +00:00
|
|
|
;
|
|
|
|
; Copy requested track and sector into RWTS parameter table.
|
|
|
|
; These are maintained outside the table because some disks
|
|
|
|
; alter the values from inside the RWTS. (MUSE)
|
|
|
|
;
|
|
|
|
lda gTrack
|
|
|
|
sta _track
|
|
|
|
lda gSector
|
|
|
|
sta _sector
|
2017-01-08 03:35:35 +00:00
|
|
|
|
|
|
|
lda gIsProtDOS
|
|
|
|
beq _protread
|
|
|
|
|
2017-01-14 15:13:06 +00:00
|
|
|
setuprwts
|
2017-01-08 03:35:35 +00:00
|
|
|
ldy #<gRWTSParams
|
|
|
|
lda #>gRWTSParams
|
2017-10-08 21:54:03 +00:00
|
|
|
callrwts jsr $FF00 ; modified at runtime
|
2017-01-14 15:13:06 +00:00
|
|
|
bcc endread
|
|
|
|
lda gOnAClearDayYouCanReadForever
|
|
|
|
beq setuprwts
|
|
|
|
endread
|
2017-01-08 03:35:35 +00:00
|
|
|
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.
|
|
|
|
;
|
2017-01-24 00:57:43 +00:00
|
|
|
!zone {
|
2017-01-08 03:35:35 +00:00
|
|
|
_protread
|
|
|
|
lda gTrack ; T02,S05+ use "protected" mode
|
|
|
|
cmp #$03 ; (altered data prologue and
|
2017-01-24 00:57:43 +00:00
|
|
|
bcs .protected ; nibble translate table)
|
2017-01-08 03:35:35 +00:00
|
|
|
cmp #$02 ; T00,S00 - T02,S04 use
|
2017-01-24 00:57:43 +00:00
|
|
|
bcc .standard ; "standard" mode
|
2017-01-08 03:35:35 +00:00
|
|
|
lda gSector
|
|
|
|
cmp #$05
|
2017-01-24 00:57:43 +00:00
|
|
|
bcs .protected
|
|
|
|
.standard
|
2017-01-08 03:35:35 +00:00
|
|
|
lda #$9B
|
|
|
|
sta $BF2C
|
2017-01-24 00:57:43 +00:00
|
|
|
bne .go ; unconditional branch
|
|
|
|
.protected
|
2017-01-08 03:35:35 +00:00
|
|
|
lda #$B5
|
|
|
|
sta $4E
|
|
|
|
lda #$D5
|
|
|
|
sta $BF2C ; execution falls through here
|
2017-01-24 00:57:43 +00:00
|
|
|
.go
|
2017-01-08 03:35:35 +00:00
|
|
|
lda #<gRWTSParams
|
|
|
|
ldy #>gRWTSParams
|
|
|
|
jsr $BA00 ; note non-standard entry point
|
2017-01-14 15:13:06 +00:00
|
|
|
bcc endprotread
|
|
|
|
lda gOnAClearDayYouCanReadForever
|
2017-01-24 00:57:43 +00:00
|
|
|
beq .go
|
2017-01-14 15:13:06 +00:00
|
|
|
endprotread
|
2017-01-08 03:35:35 +00:00
|
|
|
rts
|
2017-01-24 00:57:43 +00:00
|
|
|
}
|
2017-01-08 03:35:35 +00:00
|
|
|
|
2017-10-02 01:36:43 +00:00
|
|
|
;-------------------------------
|
|
|
|
; PreReadSector
|
|
|
|
; in: A contains sector map code that specifies what to do
|
|
|
|
; out: A contains (possibly new) sector map code
|
|
|
|
; assume all other things clobbered
|
|
|
|
;-------------------------------
|
|
|
|
PreReadSector
|
|
|
|
!zone {
|
|
|
|
cmp #kSectorCustomDOS32B4BB
|
|
|
|
bne +
|
|
|
|
ldx callrwts+2
|
|
|
|
dex
|
|
|
|
dex
|
|
|
|
dex
|
|
|
|
dex
|
|
|
|
stx .a+2
|
|
|
|
stx .b+2
|
|
|
|
ldx #$D5
|
|
|
|
.a stx $FF76
|
|
|
|
ldx #$ED
|
|
|
|
.b stx $FFB2
|
|
|
|
bne .exit ; always branches
|
|
|
|
+
|
|
|
|
.exit rts
|
|
|
|
}
|
|
|
|
|
2017-10-30 01:00:15 +00:00
|
|
|
IgnoreAddressChecksum
|
|
|
|
lda #$00
|
|
|
|
!byte $2C ; hide next LDA
|
|
|
|
EnforceAddressChecksum
|
|
|
|
lda #$B7
|
|
|
|
sta $B98A
|
|
|
|
rts
|
|
|
|
|
2017-01-24 00:57:43 +00:00
|
|
|
gTrack !byte $00
|
|
|
|
gSector !byte $00
|
2017-10-08 21:54:03 +00:00
|
|
|
|
|
|
|
gRWTSParams ; used to read each sector
|
|
|
|
!byte $01,$60,$01,$00
|
|
|
|
_track !byte $00
|
|
|
|
_sector !byte $00
|
2017-01-08 03:35:35 +00:00
|
|
|
!word dct
|
|
|
|
gAddress !word $1F00
|
2017-01-24 00:57:43 +00:00
|
|
|
!byte $00,$00,$01,$00,$FE,$60,$01,$00,$00
|
|
|
|
dct !byte $00,$01,$EF,$D8,$00
|