passport/src/id/panglosdos.a
2021-06-19 13:11:55 -04:00

288 lines
5.9 KiB
Plaintext

;-------------------------------
; PanglosDOS
; in: $0800..$08FF contains boot0
; $3600..$3FFF contains boot1
; out: C clear if "Panglossian DOS" was found
; C set if "Panglossian DOS" was not found
; gIsPanglosDOS is set to TRUE or FALSE
;
; module by qkumba
;-------------------------------
!zone {
PanglosDOS
lda jCallRWTS+2
ldx #$00 ; check for "STY $48;STA $49"
ldy #$04 ; at RWTS entry point
jsr CompareMemory
!byte $84,$48,$85,$49
bcs .jmpexit1
sec
sbc #5
ldx #$C3 ; check for "SEC;RTS" at $x8C3
ldy #$02
jsr CompareMemory
!byte $38,$60
bcs .jmpexit1
ldx #$62 ; check for "LDA $C08C,X" at $x862
ldy #$03
jsr CompareMemory
!byte $BD,$8C,$C0
bcs .jmpexit1
lda jCallRWTS+2
ldx #$B9 ; check for "JSR $xxF9" at $xDB9
ldy #$02
jsr CompareMemory
!byte $20,$F9
bcc + ; passport-test-suite/Stepwise Multiple Regression.woz [C=0] matches
.jmpexit1
jmp .exit
+
jsr PrintByID
!byte s_gathering
;$230 (560) bytes for address keys
;$230 (560) bytes for data keys
;=$460 bytes total
lda jCallRWTS+2
sta .patch5+2
sta .patch6+2
sta .patch7+2
sta .patch16+2
sta .patch17+2
sta .patch18+2
sta .patch19+2
sec
sbc #4
sta .patch14+2
sta .patch15+2
sta .patch20+2
sta .patch21+2
sbc #1
sta .patch1+2
sta .patch2+2
sta .patch3+2
sta .patch4+2
sta .patch8+2
sta .patch9+2
sta .patch10+2
sta .patch11+2
sta .patch12+2
sta .patch13+2
ldy #0
sty .onetime-1
tya
- sta $2000,y
sta $2100,y
;$2200-222F is partial
sta $2300,y
sta $2400,y
;$2500-252F is partial
iny
bne -
ldy #$2F
- sta $2200,y
sta $2500,y
dey
bpl -
.patch1
sta $3881
.patch2
sta $38EF
lda #$A9
.patch3
sta $3880
.patch4
sta $38EE
ldy #3
.hookpro
lda .hookD5,y
.patch10
sta $3867,y
.patch11
sta $38D5,y
dey
bpl .hookpro
lda #$F3
.patch12
sta $386B
lda #$EF
.patch13
sta $38D9
lda #$0F
sta .sector+1
.readdir lda #$11
sta gTrack
.sector lda #$D1
sta gSector
lda #BASEPAGE
sta gAddress+1
jsr ReadSector
bcs .jmpexit3
bcc .onetime
.onetime
lda #.goodnib-.onetime
sta .onetime-1
lda (BASEPAGE * 256) + $2B
cmp #$A0
beq .goodnib
lda #$20
.patch14
sta $39D5
lda #$D5
.patch15
sta $39D6
jsr ReadSector
lda (BASEPAGE * 256) + $2B
cmp #$A0
bne .jmpexit3
lda #$20
.patch16
sta $3D00
lda #<.callback3
.patch17
sta $3D01
lda #>.callback3
.patch18
sta $3D02
lda #$EA
.patch19
sta $3D03
.goodnib
inc gAddress+1
lda #$0B ;entry offset
.parsedir
sta .diroff+1
.diroff ldy #$D1
lda BASEPAGE<<8,Y
beq .setpanglos
cmp #$FF ;skip deleted files
beq .nextent
ldx (BASEPAGE<<8)+1,Y
.reparse
sta gTrack
stx gSector
jsr ReadSector
.jmpexit3
bcs .jmpexit2
ldx #0
ldy #0
.parsets
lda ((BASEPAGE+1)<<8)+$0C,X
beq .chkextend
asl
asl
asl
sty modsrc+1
rol modsrc+1
asl
rol modsrc+1
ora ((BASEPAGE+1)<<8)+$0D,X
sta modsrc
lda modsrc+1
adc #$20 ;$2000+
sta modsrc+1
lda ((BASEPAGE+1)<<8)+$0A
sta (modsrc),Y
lda modsrc+1
adc #3
sta modsrc+1
lda ((BASEPAGE+1)<<8)+$0B
sta (modsrc),Y
inx
inx
bne .parsets
.chkextend
ldx ((BASEPAGE+1)<<8)+2
lda ((BASEPAGE+1)<<8)+1
bne .reparse
.nextent
lda .diroff+1
clc
adc #$23
bne .parsedir
dec .sector+1
bne .jmpreaddir
.setpanglos
lda #$20
.patch5
sta $3DBE
lda #<.callback
.patch6
sta $3DBF
lda #>.callback
.patch7
sta $3DC0
lda #TRUE
sta gIsPanglosDOS
clc
.jmpexit2
jmp .exit
.jmpreaddir
jmp .readdir
.callback3
sty $48
sta $49
ldy #4
lda ($48),y
cmp #2
bne .notyet
iny
lda ($48),y
cmp #$0F
bne .notyet
lda #$D5
.patch20
sta $39D5
lda #$20
.patch21
sta $39D6
.notyet
rts
.hookD5
jsr .callback2
!byte $D0
.callback2
cmp #$D5
beq .goodpro
cmp #$D6
.goodpro
rts
.callback
sty $578
lda gTrack
asl
asl
asl
ldy #0
sty modsrc+1
rol modsrc+1
asl
rol modsrc+1
ora gSector
sta modsrc
lda modsrc+1
adc #$20
sta modsrc+1
lda (modsrc),Y
.patch8
sta $38EF ;address sum
lda modsrc+1
adc #3
sta modsrc+1
lda (modsrc),Y
.patch9
sta $3881 ;data sum
.exit
rts
}