Merge pull request #53 from peterferrie/master

support Panglossian DOS
This commit is contained in:
4am 2018-06-08 22:15:29 -04:00 committed by GitHub
commit c1a591b6ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 256 additions and 4 deletions

View File

@ -49,6 +49,10 @@
; compile-time flag, no way to change at runtime
FIRSTFILTER
;gIsPanglosDOS
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
;gIsAdvent
!byte FALSE ; 0=true, 1=false
; reset before each operation

View File

@ -88,9 +88,10 @@ gIsTrillium = gIsF7F6-$01 ; byte
gPolarwareTamperCheck = gIsTrillium-$01 ; byte
gForceDiskVol = gPolarwareTamperCheck-$01 ; byte
gIsAdvent = gForceDiskVol-$01 ; byte
gIsPanglosDOS = gIsAdvent-$01 ; byte
;LASTFILTER ; add new gIs* above this line
gOnAClearDayYouCanReadForever = gIsAdvent-$01 ; byte
gOnAClearDayYouCanReadForever = gIsPanglosDOS-$01 ; byte
gUsingRAMDisk = gOnAClearDayYouCanReadForever-$01 ; byte
gRAMDiskRef = gUsingRAMDisk-$01 ; byte
gDisplayBytes = gRAMDiskRef-$0A ; 10 bytes
@ -156,8 +157,9 @@ ConstructStandardDelivery = jConstructStandardDelivery
!warn "gIsTrillium=",gIsTrillium
!warn "gPolarwareTamperCheck=",gPolarwareTamperCheck
!warn "gForceDiskVol=",gIsForceDiskVol
!warn "gOnAClearDayYouCanReadForever=",gOnAClearDayYouCanReadForever
!warn "gIsAdvent=",gIsAdvent
!warn "gIsPanglosDOS=",gIsPanglosDOS
!warn "gOnAClearDayYouCanReadForever=",gOnAClearDayYouCanReadForever
!warn "gUsingRAMDisk=",gUsingRAMDisk
!warn "gRAMDiskRef=",gRAMDiskRef
!warn "gDisplayBytes=",gDisplayBytes

198
src/id/panglosdos.a Normal file
View File

@ -0,0 +1,198 @@
;-------------------------------
; 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
pha
jsr CompareMemory
!byte $84,$48,$85,$49
pla
bcs .jmpexit1
sec
sbc #5
ldx #$C3 ; check for "SEC;RTS" at $x8C3
ldy #$02
pha
jsr CompareMemory
!byte $38,$60
pla
bcs .jmpexit1
ldx #$62 ; check for "LDA $C08C,X" at $x862
ldy #$03
pha
jsr CompareMemory
!byte $BD,$8C,$C0
pla
bcs .jmpexit1
lda jCallRWTS+2
ldx #$B9 ; check for "JSR $xxF9" at $xDB9
ldy #$03
jsr CompareMemory
!byte $20,$F9
bcc +
.jmpexit1
jmp .exit
+ lda #s_gathering
jsr PrintByID
;$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
sec
sbc #5
sta .patch1+2
sta .patch2+2
sta .patch3+2
sta .patch4+2
sta .patch8+2
sta .patch9+2
ldy #0
tya
- sta $900,y
sta $A00,y
;$B00-B2F is partial
sta $C00,y
sta $D00,y
;$E00-E2F is partial
iny
bne -
ldy #$2F
- sta $B00,y
sta $E00,y
dey
bpl -
.patch1
sta $3881
.patch2
sta $38EF
lda #$A9
.patch3
sta $3880
.patch4
sta $38EE
lda #$0F
sta .sector+1
.readdir lda #$11
sta gTrack
.sector lda #$D1
sta gSector
lda #BASEPAGE
sta gAddress+1
jsr ReadSector
bcs .jmpexit1
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
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 #9 ;$900+
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 .readdir
.setpanglos
lda #$20
.patch5
sta $3DBE
lda #<.callback
.patch6
sta $3DBF
lda #>.callback
.patch7
sta $3DC0
lda #TRUE
sta gIsPanglosDOS
clc
.jmpexit2
jmp .exit
.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 #9
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
}

View File

@ -77,6 +77,11 @@ _Inspect1a
bcs .notprotdos
jmp ADStyle
.notprotdos
jsr PanglosDOS ; check for a specific bootloader
; that uses per-file sector encoding
bcs .notpanglosdos
jmp ADStyle
.notpanglosdos
lda jCallRWTS+2
ldx #$00 ; check for "STY $48;STA $49"
ldy #$04 ; at RWTS entry point

View File

@ -108,6 +108,7 @@ AnalyzeT00
!source "../patchers/dos32.a"
!source "../patchers/dos32dlm.a"
!source "../patchers/microfun.a"
!source "../patchers/panglosdos.a"
;add only above this line
rts

View File

@ -148,6 +148,7 @@ FirstMover
!source "id/volumename.a"
!source "id/dinkeydos.a"
!source "id/advent.a"
!source "id/panglosdos.a"
!source "print.a"
!source "compare.a"
!source "modify.a"

37
src/patchers/panglosdos.a Normal file
View File

@ -0,0 +1,37 @@
;-------------------------------
; #PanglosDOS
; RWTS with per-file encryption keys
;
; module by qkumba
;-------------------------------
!zone {
lda gIsPanglosDOS ; only if PanglossianDOS
bne .exit
ldy #6
jsr SearchTrack
!byte $C9,$AD ;CMP #$AD
!byte $D0,$E7 ;BNE *-$17
!byte $A5,$46 ;LDA $46
bcs .exit
inx
inx
inx
inx
ldy #$02
jsr modify
!byte $A9,$00 ;LDA #$00
ldy #6
jsr SearchTrack
!byte $C9,$96 ;CMP #$96
!byte $D0,$E7 ;BNE *-$17
!byte $A5,$46 ;LDA $46
bcs .exit
inx
inx
inx
inx
ldy #$02
jsr modify
!byte $A9,$00 ;LDA #$00
.exit
}

View File

@ -117,6 +117,7 @@ StringTable
!word .tamper
!word .microfun
!word .advent
!word .gathering
;
; Text can contain substitution strings, which
; are replaced by current values at runtime. Each
@ -142,7 +143,7 @@ StringTable
; can be set directly before calling PrintByID.
;
.header
!text "Passport by 4am 2018-06-02",$00
!text "Passport by 4am 2018-06-08",$00
.mainmenu
!text "________________________________________",$8D,$8D,$8D,$8D,$8D,$8D,$8D
!text " "
@ -440,4 +441,6 @@ StringTable
!text "T%t,S%0 Found Micro Fun protection check",$00
.advent
!text "T%t,S%0 Found Interplay bootloader",$8D,$00
.gathering
!text "Gathering per-file encryption keys",$8D,00
}

View File

@ -104,4 +104,5 @@ s_trillium = $62
s_tamper = $63
s_microfun = $64
s_advent = $65
STRINGCOUNT = $66
s_gathering = $66
STRINGCOUNT = $67