passport/src/id/ea.a
2021-06-19 19:42:56 -04:00

92 lines
2.0 KiB
Plaintext

;-------------------------------
; IDEA
; identify Electronic Arts custom bootloader
;
; in: track buffer contains T00,S00
; A = 0
; X = 0
; out: C clear if EA bootloader was found
; C set if not found
; A = 0
; X = 0
; all other registers & flags clobbered
;
; module by qkumba
;-------------------------------
!macro IDEA {
ldy #16
jsr compare
!byte $05,$4C,$04,$08,$A9,$00,$8D,$F2
!byte $03,$A9,$C6,$8D,$F3,$03,$49,$A5
bcc +
jsr compare
!byte $01,$A5,$27,$C9,$09,$D0,$2E,$A2
!byte $10,$8A,$9D,$EF,$03,$CA,$D0,$F9
+
}
foundea
;
; We found an EA bootloader. Now we create
; an RWTS that can read the rest of the disk.
; Starting with our built-in RWTS, we modify address
; and data prologues based on the parameters of the
; original disk.
;
!zone {
jsr PrintByID
!byte s_eab0
jsr CopyUniversal
; mark track $22 as "optional" in sector map
ldy #$0F
lda #kSectorOptional
.ignoresectors
sta T22,y
dey
bpl .ignoresectors
;hook read data prologue
lda #<.checktrk
sta $BE36
lda #>.checktrk
sta $BE37
;
; this RWTS alters the data prologue in a routine
; on a non-zero track, so we need to set a flag so
; we know to search for it later
;
lda #TRUE
sta gIsEA
jmp ADStyle
.prologtbl
!byte $AA, $BB, $AD, $CF
;try regular values first
.checktrk
ldy #0
lda .prologtbl, y
sta UNIV_D2
lda .prologtbl+2, y
sta UNIV_D3
jsr $B8DC
bcc +
;on failure, switch to alternative values
;we keep using the last successful values until we fail
;and then we switch again
lda .checktrk + 1
eor #1
sta .checktrk + 1
;and allow DOS to retry
;if DOS runs out of retries, then Passport will report it
+ rts
}