2017-01-08 03:35:35 +00:00
|
|
|
;-------------------------------
|
|
|
|
; IsF7
|
|
|
|
; check for a specific nibble sequence
|
|
|
|
; ("F7 F6 EF EE AB") that is used by a
|
|
|
|
; whole-track protection scheme
|
|
|
|
;
|
|
|
|
; in slot 6, drive 1 is on track to test
|
|
|
|
; out C clear if sequence was found
|
|
|
|
; C set if sequence was not found
|
|
|
|
;-------------------------------
|
2017-01-24 00:57:43 +00:00
|
|
|
!zone {
|
2017-01-08 03:35:35 +00:00
|
|
|
IsF7
|
|
|
|
lda $C0E9
|
|
|
|
lda #$00
|
|
|
|
jsr WAIT
|
|
|
|
lda #$20
|
|
|
|
sta nibcount
|
|
|
|
ldy #$00
|
|
|
|
- lda $C0EC
|
|
|
|
bpl -
|
|
|
|
cmp #$F7
|
|
|
|
beq +
|
2017-01-24 00:57:43 +00:00
|
|
|
.restart iny
|
2017-01-08 03:35:35 +00:00
|
|
|
bne -
|
|
|
|
dec nibcount
|
|
|
|
bne -
|
|
|
|
beq F7fail
|
2017-01-24 00:57:43 +00:00
|
|
|
+
|
|
|
|
- lda $C0EC
|
2017-01-08 03:35:35 +00:00
|
|
|
bpl -
|
|
|
|
cmp #$F6
|
2017-01-24 00:57:43 +00:00
|
|
|
bne .restart
|
2017-01-08 03:35:35 +00:00
|
|
|
- lda $C0EC
|
|
|
|
bpl -
|
|
|
|
cmp #$EF
|
2017-01-24 00:57:43 +00:00
|
|
|
bne .restart
|
2017-01-08 03:35:35 +00:00
|
|
|
- lda $C0EC
|
|
|
|
bpl -
|
|
|
|
cmp #$EE
|
2017-01-24 00:57:43 +00:00
|
|
|
bne .restart
|
2017-01-08 03:35:35 +00:00
|
|
|
- lda $C0EC
|
|
|
|
bpl -
|
|
|
|
cmp #$AB
|
2017-01-24 00:57:43 +00:00
|
|
|
bne .restart
|
2017-01-08 03:35:35 +00:00
|
|
|
clc
|
|
|
|
!byte $24 ; hides SEC
|
|
|
|
F7fail sec
|
|
|
|
lda $C0E8
|
|
|
|
rts
|
2017-01-24 00:57:43 +00:00
|
|
|
}
|
2017-01-08 03:35:35 +00:00
|
|
|
;-------------------------------
|
|
|
|
; IsSyncBytes
|
|
|
|
; check if track is mostly $FF bytes
|
|
|
|
;
|
|
|
|
; in slot 6, drive 1 is on track to test
|
|
|
|
; out C clear if track is mostly just $FF bytes
|
|
|
|
; C set otherwise
|
|
|
|
;-------------------------------
|
|
|
|
IsSyncBytes
|
|
|
|
lda #$FD
|
|
|
|
sta nibtableff
|
|
|
|
jsr IsUnformatted
|
|
|
|
lda #$3F
|
|
|
|
sta nibtableff
|
|
|
|
rts
|
|
|
|
|
|
|
|
;-------------------------------
|
|
|
|
; IsUnformatted
|
|
|
|
; check if track is unformatted
|
|
|
|
;
|
|
|
|
; in slot 6, drive 1 is on track to test
|
|
|
|
; out C clear if track is unformatted
|
|
|
|
; C set if track is formatted
|
|
|
|
;-------------------------------
|
|
|
|
IsUnformatted
|
|
|
|
lda $C0E9
|
|
|
|
lda #$00
|
|
|
|
sta unform
|
|
|
|
sta unform+1
|
|
|
|
jsr WAIT
|
|
|
|
lda #$20
|
|
|
|
sta nibcount
|
|
|
|
ldy #$00
|
|
|
|
nibloop ldx $C0EC
|
|
|
|
bpl nibloop
|
|
|
|
lda nibtable,x
|
|
|
|
bpl +
|
|
|
|
inc unform
|
|
|
|
bne +
|
|
|
|
inc unform+1
|
|
|
|
+ iny
|
|
|
|
bne nibloop
|
|
|
|
dec nibcount
|
|
|
|
bne nibloop
|
|
|
|
lda $C0E8
|
|
|
|
lda #$18
|
|
|
|
cmp unform+1
|
|
|
|
rts
|
|
|
|
|
|
|
|
;-------------------------------
|
|
|
|
; xHeredityDog
|
|
|
|
; check for a protection check at $BB00
|
|
|
|
; which implies an unreadable T00,S0A
|
|
|
|
;
|
|
|
|
; in: $0800..$08FF contains boot0
|
|
|
|
; $B600..$BFFF contains boot1
|
|
|
|
; out: C clear if protection code was found
|
|
|
|
; C set if protection code was not found
|
|
|
|
;-------------------------------
|
2017-01-24 00:57:43 +00:00
|
|
|
!zone {
|
2017-01-08 03:35:35 +00:00
|
|
|
xHeredityDog
|
|
|
|
lda $08FE
|
|
|
|
clc
|
|
|
|
adc #$04
|
|
|
|
pha
|
|
|
|
ldx #$16
|
|
|
|
ldy #$0B
|
|
|
|
jsr CompareMemory
|
2017-01-24 00:57:43 +00:00
|
|
|
!byte $F0,$05,$A2,$B2,$4C,$F0,$BB,$BD,$8C,$C0,$A9
|
2017-01-08 03:35:35 +00:00
|
|
|
pla
|
2017-01-24 00:57:43 +00:00
|
|
|
bcc .maybe
|
|
|
|
jmp .no
|
2017-01-08 03:35:35 +00:00
|
|
|
|
|
|
|
; don't check byte at $BB21 because it can vary
|
|
|
|
|
2017-01-24 00:57:43 +00:00
|
|
|
.maybe
|
2017-01-08 03:35:35 +00:00
|
|
|
ldx #$22
|
|
|
|
ldy #$3E
|
|
|
|
jsr CompareMemory
|
2017-01-24 00:57:43 +00:00
|
|
|
!byte $8D,$00,$02,$BD,$8C,$C0,$10,$FB,$C9,$EB,$D0,$F7,$BD,$8C
|
2017-01-08 03:35:35 +00:00
|
|
|
!byte $C0,$10,$FB,$C9,$D5,$D0,$EE,$BD,$8C,$C0,$10,$FB,$C9,$AA,$D0,$E5
|
2017-01-24 00:57:43 +00:00
|
|
|
!byte $A9,$4C,$A0,$00,$99,$00,$95,$88,$D0,$FA,$CE,$46,$BB,$AD,$46,$BB
|
|
|
|
!byte $C9,$07,$D0,$EC,$A9,$18,$8D,$42,$B9,$A9,$0A,$8D,$ED,$B7,$D0,$05
|
|
|
|
bcs .no
|
|
|
|
.yes
|
2017-01-08 03:35:35 +00:00
|
|
|
lda #$80
|
|
|
|
sta T00S0A
|
2017-01-24 00:57:43 +00:00
|
|
|
.no
|
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
|
|
|
|
|
|
|
;-------------------------------
|
|
|
|
; xSunburst
|
|
|
|
; check for a Sunburst RWTS
|
|
|
|
; which implies an unreadable T11,S0F
|
|
|
|
;
|
|
|
|
; in: $0800..$08FF contains boot0
|
|
|
|
; $B600..$BFFF contains boot1
|
|
|
|
; out: C clear if Sunburst RWTS was found
|
|
|
|
; C set otherwise
|
|
|
|
;-------------------------------
|
2017-01-24 00:57:43 +00:00
|
|
|
!zone {
|
2017-01-08 03:35:35 +00:00
|
|
|
xSunburst
|
|
|
|
lda $08FE
|
|
|
|
clc
|
|
|
|
adc #$03
|
|
|
|
ldx #$69
|
|
|
|
ldy #$2C
|
|
|
|
jsr CompareMemory
|
|
|
|
!byte $48,$A5,$2A,$4A,$A8,$B9,$29,$BA
|
|
|
|
!byte $8D,$6A,$B9,$8D,$84,$BC,$B9,$34
|
|
|
|
!byte $BA,$8D,$FC,$B8,$8D,$5D,$B8,$C0
|
2017-01-24 00:57:43 +00:00
|
|
|
!byte $11,$D0,$03,$A9,$02,$AC,$A9,$0E
|
|
|
|
!byte $8D,$C0,$BF,$68,$69,$00,$48,$AD
|
|
|
|
!byte $78,$04,$90,$2B
|
|
|
|
bcs .no
|
|
|
|
.yes
|
2017-01-08 03:35:35 +00:00
|
|
|
lda #$80
|
|
|
|
sta T11S0F
|
2017-01-24 00:57:43 +00:00
|
|
|
.no
|
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
|
|
|
|
|
|
|
;-------------------------------
|
|
|
|
; xOptimumRes
|
|
|
|
; check if disk has Optimum Resource bootloader
|
|
|
|
; which implies an unreadable T01,S0F
|
|
|
|
;
|
|
|
|
; in: $0800..$08FF contains boot0
|
|
|
|
; $B600..$BFFF contains boot1
|
|
|
|
; out: C clear if OptimumRes bootloader was found
|
|
|
|
; C set otherwise
|
|
|
|
;-------------------------------
|
2017-01-24 00:57:43 +00:00
|
|
|
!zone {
|
2017-01-08 03:35:35 +00:00
|
|
|
xOptimumRes
|
|
|
|
lda #$08
|
|
|
|
ldx #$5D
|
|
|
|
ldy #$0C
|
|
|
|
jsr CompareMemory
|
2017-01-24 00:57:43 +00:00
|
|
|
!byte $68,$85,$F0,$68,$85,$F1,$A0,$01
|
2017-01-08 03:35:35 +00:00
|
|
|
!byte $B1,$F0,$85,$54
|
2017-01-24 00:57:43 +00:00
|
|
|
bcc .yes
|
2017-01-08 03:35:35 +00:00
|
|
|
lda #$08
|
|
|
|
ldx #$5D
|
|
|
|
ldy #$0C
|
|
|
|
jsr CompareMemory
|
2017-01-24 00:57:43 +00:00
|
|
|
!byte $68,$85,$A0,$68,$85,$A1,$A0,$01
|
2017-01-08 03:35:35 +00:00
|
|
|
!byte $B1,$A0,$85,$54
|
2017-01-24 00:57:43 +00:00
|
|
|
bcs .no
|
|
|
|
.yes
|
2017-01-08 03:35:35 +00:00
|
|
|
lda #$80
|
|
|
|
sta T01S0F
|
2017-01-24 00:57:43 +00:00
|
|
|
.no
|
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
|
|
|
|
|
|
|
;-------------------------------
|
|
|
|
; xB4BB
|
|
|
|
; check if disk changes RWTS in
|
|
|
|
; late boot after a nibble check
|
|
|
|
;
|
|
|
|
; in: $0800..$08FF contains boot0
|
|
|
|
; $B600..$BFFF contains boot1
|
|
|
|
; out: C clear if RWTS was modified in this routine
|
|
|
|
; C set otherwise
|
|
|
|
;-------------------------------
|
2017-01-24 00:57:43 +00:00
|
|
|
!zone {
|
2017-01-08 03:35:35 +00:00
|
|
|
xB4BB
|
|
|
|
lda gTrack
|
|
|
|
pha
|
|
|
|
lda gSector
|
|
|
|
pha
|
|
|
|
b4bbcompare
|
|
|
|
lda #$FF ; modified at runtime (in Inspect1)
|
|
|
|
ldx #$00
|
|
|
|
ldy #$20
|
|
|
|
jsr CompareMemory
|
|
|
|
!byte $D8,$A9,$DF,$48,$A9,$FF,$48,$A9
|
2017-01-24 00:57:43 +00:00
|
|
|
!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
|
2017-01-08 03:35:35 +00:00
|
|
|
bcs _b4bbexit
|
|
|
|
lda #$00
|
|
|
|
sta gTrack
|
|
|
|
sta gAddress
|
|
|
|
lda #$0C
|
|
|
|
sta gSector
|
|
|
|
lda #$0C
|
|
|
|
clc
|
|
|
|
adc #BASEPAGE
|
|
|
|
sta gAddress+1
|
|
|
|
jsr ReadSector
|
|
|
|
bcs _b4bbexit
|
|
|
|
lda #$0C
|
|
|
|
ldx #$84
|
|
|
|
ldy #$03
|
|
|
|
jsr compare
|
|
|
|
!byte $4C,$BB,$B4
|
|
|
|
bcs _b4bbexit
|
|
|
|
lda #$02
|
|
|
|
sta gTrack
|
|
|
|
sta gSector
|
|
|
|
jsr ReadSector
|
|
|
|
bcs _b4bbexit
|
|
|
|
lda #$0C
|
|
|
|
clc
|
|
|
|
adc #BASEPAGE
|
|
|
|
sta x0+2
|
|
|
|
x0 lda $FFC2 ; modified at runtime (above)
|
|
|
|
b4bbmodify
|
|
|
|
sta $FF55 ; modified at runtime (in Inspect1)
|
|
|
|
lda #$DE
|
|
|
|
b4bbmodify2
|
|
|
|
sta $FF91 ; modified at runtime (in Inspect1)
|
|
|
|
_b4bbexit
|
|
|
|
pla
|
|
|
|
sta gSector
|
|
|
|
pla
|
|
|
|
sta gTrack
|
|
|
|
rts
|
2017-01-24 00:57:43 +00:00
|
|
|
}
|
2017-01-08 03:35:35 +00:00
|
|
|
|
|
|
|
;-------------------------------
|
|
|
|
; xB660
|
|
|
|
; Check if RWTS calls an extra routine at $B660
|
|
|
|
; after matching the first two data prologue
|
|
|
|
; nibbles. This routine can hang in an infinite
|
|
|
|
; loop if it's used to read an unprotected sector,
|
|
|
|
; so we need to force-switch to the built-in RWTS
|
|
|
|
; after reading all the protected sectors.
|
|
|
|
; (T00,S00-S09 are unprotected because they are
|
|
|
|
; read by the drive firmware.)
|
|
|
|
;
|
|
|
|
; in: $0800..$08FF contains boot0
|
|
|
|
; out: C clear if $B660 routine was found
|
|
|
|
; C set otherwise
|
|
|
|
;-------------------------------
|
2017-01-24 00:57:43 +00:00
|
|
|
!zone {
|
2017-01-08 03:35:35 +00:00
|
|
|
xB660
|
|
|
|
lda #$08
|
|
|
|
ldx #$60
|
|
|
|
ldy #$1A
|
|
|
|
jsr CompareMemory
|
|
|
|
!byte $BD,$8C,$C0,$10,$FB,$C9,$AD,$D0
|
2017-01-24 00:57:43 +00:00
|
|
|
!byte $F4,$A9,$F8,$3D,$8C,$C0,$D0,$02
|
2017-01-08 03:35:35 +00:00
|
|
|
!byte $EA,$EA,$EA,$EA,$BD,$8C,$C0,$2A
|
2017-01-24 00:57:43 +00:00
|
|
|
!byte $30,$02
|
|
|
|
bcs .no
|
|
|
|
.yes
|
2017-01-08 03:35:35 +00:00
|
|
|
lda #$FE
|
|
|
|
sta T00S09
|
2017-01-24 00:57:43 +00:00
|
|
|
.no
|
2017-01-08 03:35:35 +00:00
|
|
|
rts
|
2017-01-24 00:57:43 +00:00
|
|
|
}
|