support DOS 3.2 JMP B4BB, refactor sectormap codes, add PreReadSector routine

This commit is contained in:
4am 2017-10-01 21:36:43 -04:00
parent 125a344fb7
commit d68ac00436
11 changed files with 107 additions and 51 deletions

View File

@ -256,7 +256,7 @@ xHeredityDog
!byte $C9,$07,$D0,$EC,$A9,$18,$8D,$42,$B9,$A9,$0A,$8D,$ED,$B7,$D0,$05
pla
bcs .exit
lda #$80
lda #kSectorOptional
sta T00S0A
.exit
rts
@ -288,7 +288,7 @@ xSunburst
!byte $78,$04,$90,$2B
bcs .no
.yes
lda #$80
lda #kSectorOptional
sta T11S0F
.no
rts
@ -314,7 +314,7 @@ xOptimumRes
!byte $B1,WILDCARD,$85,$54
bcs .no
.yes
lda #$80
lda #kSectorOptional
sta T01S0F
.no
rts
@ -346,8 +346,9 @@ b4bbcompare
!byte $08,$85,$3D,$85,$43,$A9,$BF,$85
!byte $3F,$A9,$00,$85,$3C,$85,$42,$E6
!byte $42,$A9,$FE,$85,$3E,$A0,$00,$AD
bcs _b4bbexit
lda gIsDOS32
bcc +
jmp _b4bbexit
+ lda gIsDOS32
beq .dos32
lda #$55 ; low byte of address that checks address prologue 1
sta b4bbmodify+1
@ -403,6 +404,10 @@ b4bbmodify
lda #$DE
b4bbmodify2
sta $FFFF ; modified at runtime (high byte in Inspect1, low byte above)
lda gIsDOS32
bne _b4bbexit
lda #kSectorCustomDOS32B4BB
sta T02S0C
_b4bbexit
pla
sta gSector
@ -438,7 +443,7 @@ xB660
!byte $30,$02
bcs .no
.yes
lda #$FE
lda #kSectorSwitchToBuiltinRWTS
sta T00S09
.no
rts

View File

@ -48,7 +48,7 @@ foundea
; mark track $22 as "optional" in sector map
ldy #$0F
lda #$80
lda #kSectorOptional
.ignoresectors
sta T22,y
dey

View File

@ -86,7 +86,7 @@ TraceLaureate
; (never read, some disks have intentionally bad sectors there)
; (seen on Sound Ideas)
;
lda #$00
lda #kSectorIgnore
sta T00S0C
sta T00S0D
sta T00S0E

View File

@ -212,7 +212,7 @@ TraceDOS32d
sta .C+1
lda #>sectormap
sta .C+2
lda #$00
lda #kSectorIgnore
ldx #$22
.A ldy #$0F
.B cpy #$03

View File

@ -142,7 +142,7 @@ _Inspect1a
bcs .x7
lda #s_milliken
jsr PrintByID
lda #$80
lda #kSectorOptional
sta T02S05
;
; Check for Adventure International RWTS (sets flag for patcher)

View File

@ -196,7 +196,7 @@ SDsuccess
; mark tracks 0-2 as "skip" in sector map
ldy #$2F
lda #$00
lda #kSectorIgnore
skipsectors
sta T00,y
dey

View File

@ -85,7 +85,7 @@ _restore3
; Mark track 0 and part of track 2 as "skip" in sector map
;
ldy #$0F
lda #$00
lda #kSectorIgnore
- sta T00,y
dey
bpl -

View File

@ -366,10 +366,16 @@ ReadWithRWTS
bpl checksector
jmp Cancel
checksector
lda $FFFF ; current sector in sector map
lda $FFFF ; status of current sector in sector map (modified above)
pha
beq nextsector ; #$00 = skip this sector
cmp #$FE ; #$FE = switch to built-in RWTS to read this sector
cmp #kSectorCustomFirst ; call a custom routine before deciding what to do with this sector?
bcc +
cmp #kSectorCustomLast
bcs +
jsr PreReadSector
+ cmp #kSectorIgnore ; skip this sector?
beq nextsector
+ cmp #kSectorSwitchToBuiltinRWTS ; switch to built-in RWTS before reading this sector?
bne +
lda gTriedUniv
beq +
@ -383,7 +389,7 @@ checksector
; Maybe we marked this sector as optional based
; on markers in the bootloader.
;
cmp #$80
cmp #kSectorOptional
beq .optional
;
; (13-sector only)

View File

@ -65,6 +65,32 @@ endprotread
rts
}
;-------------------------------
; 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
}
gRWTSParams ; used to read each sector
!byte $01,$60,$01,$00
gTrack !byte $00

View File

@ -1,41 +1,58 @@
!zone {
InitSectorMap
lda #<sectormap
sta .B+1
lda #>sectormap
sta .B+2
lda #$FF
ldx #$22
.A ldy #$0F
.B sta $FFFF
inc .B+1
bne +
inc .B+2
+ dey
bpl .B
dex
bpl .A
rts
}
;-------------------------------
; This is a map of how much we care about each sector
; on the disk. Each byte is one sector, arranged in
; increasing logical sector order from T00,S00 to T22,S0F.
; Some sectors have their own individual labels just for
; convenience.
; e.g. LDA #$80
; Passport maintains a table of codes for each sector on the disk.
; One byte per sector, arranged in increasing logical sector order
; from T00,S00 to T22,S0F. Some sectors have their own individual
; labels for convenience, but you can use math to find any specific
; sector.
; e.g.
; LDA #kSectorOptional
; STA T00S0A
; will mark T00,S0A as optional
;
; Possible values for each sector:
; 00 = ignore this sector (don't even read it)
; 80 = sector is optional -- read, but ignore any errors
; FE = sector is required, and switch to the built-in RWTS
; before reading it (if we haven't already)
; FF = sector is required -- read, and any error is fatal
; (this is the default value for all sectors)
; LDA #kSectorOptional
; LDY #$0A
; STA T00,Y
; will also mark T00,S0A as optional
;
; The sector map is reset for each disk (to #kSectorRequired for
; all sectors), then modified based on boot sector identification
; and other factors.
;
; Codes are opaque values, not bit flags.
; Some codes are grouped into ranges that are compared as integers.
; Always use labels for comparison.
;
kSectorIgnore = $00 ; ignore this sector (don't even read it)
kSectorOptional = $01 ; sector is optional (read, but errors are non-fatal)
kSectorSwitchToBuiltinRWTS = $FE ; sector is required, and switch to built-in RWTS before reading it
kSectorRequired = $FF ; sector is required (errors are fatal)
; range of codes that trigger various custom routines before reading a sector
kSectorCustomFirst = $C0
kSectorCustomLast = $D0
; specific codes
kSectorCustomDOS32B4BB = $C0 ; DOS 3.2 / JMP B4BB RWTS swapper
;-------------------------------
InitSectorMap
!zone {
lda #<sectormap
sta .B+1
lda #>sectormap
sta .B+2
lda #kSectorRequired
ldx #$22
.A ldy #$0F
.B sta $FFFF
inc .B+1
bne +
inc .B+2
+ dey
bpl .B
dex
bpl .A
rts
}
sectormap
T00S00
T00 !byte $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
@ -50,7 +67,9 @@ T01 !byte $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
T01S0F !byte $FF
T02 !byte $FF,$FF,$FF,$FF,$FF
T02S05 !byte $FF
!byte $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
!byte $FF,$FF,$FF,$FF,$FF,$FF
T02S0C !byte $FF
!byte $FF,$FF,$FF
T03 !byte $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
T04 !byte $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
T05 !byte $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF

View File

@ -230,7 +230,7 @@ StringTable
; can be set directly before calling PrintByID.
;
.header
!text "Passport by 4am 2017-09-30",$00
!text "Passport by 4am 2017-10-01",$00
.mainmenu
!text "________________________________________",$8D,$8D,$8D,$8D,$8D,$8D,$8D
!text " "