refactor MECC routines, collapse MECC logging, and add support for another MECC fastloader variant

This commit is contained in:
4am 2017-02-21 12:05:23 -05:00
parent 4789751836
commit e993eaca0e
8 changed files with 187 additions and 117 deletions

View File

@ -141,19 +141,26 @@ IDBootloader
; ;
jsr IDMECC jsr IDMECC
bcs .notmecc bcs .notmecc
jsr IDMECCM8 lda #s_mecc
bcs .notmeccm8 jsr PrintByID
jmp foundmeccm8 jsr CopyUniversal
.notmeccm8 jsr IDMECC1
jsr IDMECCM7 bcs .notmecc1
bcs .notmeccm7 jmp foundmecc1
jmp foundmeccm7 .notmecc1
jsr IDMECC2
bcs .notmecc2
jmp foundmecc2
.notmeccm7 .notmecc2
jsr IDMECCM6 jsr IDMECC3
bcs .notmeccm6 bcs .notmecc3
jmp foundmeccm6 jmp foundmecc3
.notmeccm6 .notmecc3
jsr IDMECC4
bcs .notmecc4
jmp foundmecc4
.notmecc4
.notmecc .notmecc
; ;
; Try to identify the encrypted Datasoft bootloader. ; Try to identify the encrypted Datasoft bootloader.

View File

@ -2,15 +2,18 @@
; IDMECC ; IDMECC
; identify MECC custom bootloader ; identify MECC custom bootloader
; note: there are several MECC RWTSes that share ; note: there are several MECC RWTSes that share
; the same bootloader, so further checks will be ; the same early bootloader, so further checks
; required to distinguish between them ; are required to distinguish between them after
; this function matches
; ;
; in: track buffer contains T00,S00 ; in: track buffer contains T00,S00
; out: C clear if MECC bootloader was found ; out: C clear if MECC bootloader was found
; (and track buffer now contains all of track 0)
; C set if not found ; C set if not found
; all other flags clobbered ; all other flags clobbered
; all registers clobbered ; all registers clobbered
;------------------------------- ;-------------------------------
!zone {
IDMECC IDMECC
lda #$00 lda #$00
ldx #$00 ldx #$00
@ -19,34 +22,37 @@ IDMECC
!byte $01,$4C,$1A,$08,$17,$0F,$00,$00 !byte $01,$4C,$1A,$08,$17,$0F,$00,$00
!byte $0D,$0B,$09,$07,$05,$03,$01,$0E !byte $0D,$0B,$09,$07,$05,$03,$01,$0E
!byte $0C,$0A,$08,$06,$04,$02,$0F !byte $0C,$0A,$08,$06,$04,$02,$0F
bcs .exit
lda #$00
sta gTrack
sta gAddress
lda #$0F
sta gSector
clc
adc #BASEPAGE
sta gAddress+1
- jsr ReadSector
bcs .exit
dec gAddress+1
dec gSector
bne -
.exit
rts rts
}
;------------------------------- ;-------------------------------
; IDMECCM8 ; IDMECC1
; identify MECC "M8" bootloader ; identify MECC bootloader variant #1
; (labeled "M8" on original disks)
; ;
; in: track buffer contains T00,S00 ; in: track buffer contains all of track 0
; out: C clear if MECC "M8" bootloader was found ; out: C clear if MECC "M8" bootloader was found
; C set if not found ; C set if not found
; all other flags clobbered ; all other flags clobbered
; all registers clobbered ; all registers clobbered
;------------------------------- ;-------------------------------
!zone { !zone {
IDMECCM8 IDMECC1
lda #$00
sta gTrack
sta gAddress
lda #$0B
sta gSector
clc
adc #BASEPAGE
sta gAddress+1
jsr ReadSector
bcs .exit
; This entry point is also called by the meccm8 patcher
; in lieu of keeping a global variable around.
IDMECCM8RWTS
lda #$0B lda #$0B
ldx #$02 ldx #$02
ldy #$06 ldy #$06
@ -84,7 +90,7 @@ IDMECCM8RWTS
.exit .exit
rts rts
foundmeccm8 foundmecc1
; ;
; We found an "M8" MECC bootloader. Now we create ; We found an "M8" MECC bootloader. Now we create
; an RWTS that can read the rest of the disk. ; an RWTS that can read the rest of the disk.
@ -92,9 +98,6 @@ foundmeccm8
; and data prologues based on the parameters of the ; and data prologues based on the parameters of the
; original disk. ; original disk.
; ;
lda #s_meccb0
jsr PrintByID
jsr CopyUniversal
lda #$00 lda #$00
sta modsrc sta modsrc
lda #$0B lda #$0B
@ -124,31 +127,20 @@ foundmeccm8
} }
;------------------------------- ;-------------------------------
; IDMECCM7 ; IDMECC2
; identify MECC "M7" bootloader ; identify MECC bootloader variant #2
; (labeled "M7" on original disks)
; ;
; in: track buffer contains T00,S00 ; in: track buffer contains all of track 0
; out: C clear if MECC "M7" bootloader was found ; out: C clear if MECC "M7" bootloader was found
; C set if not found ; C set if not found
; all other flags clobbered ; all other flags clobbered
; all registers clobbered ; all registers clobbered
;------------------------------- ;-------------------------------
!zone { !zone {
IDMECCM7 IDMECC2
lda #$00
sta gTrack
sta gAddress
lda #$07
sta gSector
clc
adc #BASEPAGE
sta gAddress+1
jsr ReadSector
bcs .exit
; This entry point is also called by the meccm7 patcher
; in lieu of keeping a global variable around.
IDMECCM7RWTS
lda #$07 lda #$07
IDMECC4a
ldx #$7D ldx #$7D
ldy #$06 ldy #$06
jsr compare ; IF T00,S07,$7D == jsr compare ; IF T00,S07,$7D ==
@ -181,7 +173,7 @@ IDMECCM7RWTS
.exit .exit
rts rts
foundmeccm7 foundmecc2
; ;
; We found an "M7" MECC bootloader. Now we create ; We found an "M7" MECC bootloader. Now we create
; an RWTS that can read the rest of the disk. ; an RWTS that can read the rest of the disk.
@ -189,17 +181,13 @@ foundmeccm7
; and data prologues based on the parameters of the ; and data prologues based on the parameters of the
; original disk. ; original disk.
; ;
lda #s_meccm7
jsr PrintByID
jsr CopyUniversal
lda #$00
sta modsrc
lda #$07 lda #$07
foundmecc4a
clc clc
adc #BASEPAGE adc #BASEPAGE
sta modsrc+1 sta modsrc+1
lda #$00
sta modsrc
ldy #$83 ldy #$83
lda (modsrc),y lda (modsrc),y
lsr lsr
@ -223,34 +211,18 @@ foundmeccm7
} }
;------------------------------- ;-------------------------------
; IDMECCM6 ; IDMECC3
; identify MECC "M6" bootloader ; identify MECC bootloader (M7 variant
; found in Word Muncher v1.1 and others)
; ;
; in: track buffer contains T00,S00 ; in: track buffer contains all of track 0
; out: C clear if MECC "M6" bootloader was found ; out: C clear if this MECC bootloader variant was found
; C set if not found ; C set if not found
; all other flags clobbered ; all other flags clobbered
; all registers clobbered ; all registers clobbered
;------------------------------- ;-------------------------------
!zone { !zone {
IDMECCM6 IDMECC3
lda #$00
sta gTrack
sta gAddress
lda #$0B
sta gSector
clc
adc #BASEPAGE
sta gAddress+1
jsr ReadSector
bcs .exit
dec gSector
dec gAddress+1
jsr ReadSector
bcs .exit
; This entry point is also called by the meccm6 patcher
; in lieu of keeping a global variable around.
IDMECCM6RWTS
lda #$0A lda #$0A
ldx #$E2 ldx #$E2
ldy #$06 ldy #$06
@ -285,19 +257,14 @@ IDMECCM6RWTS
.exit .exit
rts rts
foundmeccm6 foundmecc3
; ;
; We found an "M6" MECC bootloader. Now we create ; We found a MECC bootloader. Now we create
; an RWTS that can read the rest of the disk. ; an RWTS that can read the rest of the disk.
; Starting with our built-in RWTS, we modify address ; Starting with our built-in RWTS, we modify address
; and data prologues based on the parameters of the ; and data prologues based on the parameters of the
; original disk. ; original disk.
; ;
lda #s_meccm6
jsr PrintByID
jsr CopyUniversal
lda #$00 lda #$00
sta modsrc sta modsrc
lda #$0A lda #$0A
@ -326,3 +293,33 @@ foundmeccm6
sta $B8FC sta $B8FC
jmp ADStyle jmp ADStyle
} }
;-------------------------------
; IDMECC4
; identify MECC bootloader variant #4
; (labeled "M7" on original disks)
; same as variant #2 but everything is
; on T00,S08 instead of T00,S07
;
; in: track buffer contains all of track 0
; out: C clear if MECC bootloader was found
; C set if not found
; all other flags clobbered
; all registers clobbered
;-------------------------------
!zone {
IDMECC4
lda #$08
jmp IDMECC4a
foundmecc4
;
; We found a MECC 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.
;
lda #$08
jmp foundmecc4a
}

View File

@ -670,9 +670,10 @@ _applyToT00
!source "patchers/bademu.a" !source "patchers/bademu.a"
!source "patchers/bademu2.a" !source "patchers/bademu2.a"
!source "patchers/rwts.a" !source "patchers/rwts.a"
!source "patchers/meccm8.a" !source "patchers/mecc1.a"
!source "patchers/meccm7.a" !source "patchers/mecc2.a"
!source "patchers/meccm6.a" !source "patchers/mecc3.a"
!source "patchers/mecc4.a"
!source "patchers/rol1e.a" !source "patchers/rol1e.a"
!source "patchers/jmpb4bb.a" !source "patchers/jmpb4bb.a"
!source "patchers/jmpb4bbhi.a" !source "patchers/jmpb4bbhi.a"

View File

@ -8,7 +8,7 @@
_meccm8 _meccm8
jsr IDMECC jsr IDMECC
bcs .exit bcs .exit
jsr IDMECCM8RWTS jsr IDMECC1
bcs .exit bcs .exit
lda #$0B lda #$0B
ldx #$08 ldx #$08

View File

@ -8,7 +8,7 @@
_meccm7 _meccm7
jsr IDMECC jsr IDMECC
bcs .exit bcs .exit
jsr IDMECCM7RWTS jsr IDMECC2
bcs .exit bcs .exit
lda #$07 lda #$07
ldx #$83 ldx #$83

View File

@ -1,14 +1,14 @@
;------------------------------- ;-------------------------------
; #MECCM6 ; #MECC3
; MECC fastloader with custom ; MECC fastloader with custom
; address and data prologues ; address and data prologues
; e.g. early versions of Word Munchers ; e.g. Word Munchers v1.1
;------------------------------- ;-------------------------------
!zone { !zone {
_meccm6 _mecc3
jsr IDMECC jsr IDMECC
bcs .exit bcs .exit
jsr IDMECCM6RWTS jsr IDMECC3
bcs .exit bcs .exit
lda #$0A lda #$0A
ldx #$E8 ldx #$E8

73
src/patchers/mecc4.a Normal file
View File

@ -0,0 +1,73 @@
;-------------------------------
; #MECC4
; MECC fastloader with custom
; address and data prologues
; e.g. A-201 Conquering Whole Numbers
;-------------------------------
!zone {
_mecc4
jsr IDMECC
bcs .exit
jsr IDMECC4
bcs .exit
lda #$08
ldx #$83
ldy #$01
jsr compare ; if T00,S08,$83 !=
!byte $D5
bcc .addr2
ldy #$01
jsr modify ; then set T00,S08,$83 =
!byte $D5
.addr2
lda #$08
ldx #$8D
ldy #$01
jsr compare ; if T00,S08,$8D !=
!byte $AA
bcc .addr3
ldy #$01
jsr modify ; then set T00,S08,$8D =
!byte $AA
.addr3
lda #$08
ldx #$98
ldy #$01
jsr compare ; if T00,S08,$98 !=
!byte $96
bcc .data1
ldy #$01
jsr modify ; then set T00,S08,$98 =
!byte $96
.data1
lda #$08
ldx #$15
ldy #$01
jsr compare ; if T00,S08,$15 !=
!byte $D5
bcc .data2
ldy #$01
jsr modify ; then set T00,S08,$15 =
!byte $D5
.data2
lda #$08
ldx #$1F
ldy #$01
jsr compare ; if T00,S08,$1F !=
!byte $AA
bcc .data3
ldy #$01
jsr modify ; then set T00,S08,$1F =
!byte $AA
.data3
lda #$08
ldx #$2A
ldy #$01
jsr compare ; if T00,S08,$2A !=
!byte $AD
bcc .exit
ldy #$01
jsr modify ; then set T00,S08,$2A =
!byte $AD
.exit
}

View File

@ -53,7 +53,7 @@ s_modifyto = $22
s_dosb0 = $23 s_dosb0 = $23
s_prodosb0 = $24 s_prodosb0 = $24
s_pascalb0 = $25 s_pascalb0 = $25
s_meccb0 = $26 s_mecc = $26
s_sierra = $27 s_sierra = $27
s_a6bc95 = $28 s_a6bc95 = $28
s_jmpbcf0 = $29 s_jmpbcf0 = $29
@ -68,7 +68,7 @@ s_thunder = $31
s_jmpae8e = $32 s_jmpae8e = $32
s_diskvol = $33 s_diskvol = $33
s_d5d5f7 = $34 s_d5d5f7 = $34
s_meccm7 = $35 s_construct= $35
s_datasoftb0 = $36 s_datasoftb0 = $36
s_datasoft = $37 s_datasoft = $37
s_lsr6a = $38 s_lsr6a = $38
@ -89,9 +89,7 @@ s_eab0 = $46
s_eatrk6 = $47 s_eatrk6 = $47
s_eeef = $48 s_eeef = $48
s_poke = $49 s_poke = $49
s_construct= $4A STRINGCOUNT = $4A
s_meccm6 = $4B
STRINGCOUNT = $4C
!zone { !zone {
StringTable StringTable
@ -133,7 +131,7 @@ StringTable
!word .dosboot0 !word .dosboot0
!word .prodosboot0 !word .prodosboot0
!word .pascalboot0 !word .pascalboot0
!word .meccboot0 !word .mecc
!word .sierra !word .sierra
!word .a6bc95 !word .a6bc95
!word .jmpbcf0 !word .jmpbcf0
@ -148,7 +146,7 @@ StringTable
!word .jmpae8e !word .jmpae8e
!word .diskvol !word .diskvol
!word .d5d5f7 !word .d5d5f7
!word .meccm7 !word .construct
!word .datasoftb0 !word .datasoftb0
!word .datasoft !word .datasoft
!word .lsr6a !word .lsr6a
@ -169,8 +167,6 @@ StringTable
!word .eatrk6 !word .eatrk6
!word .eeef !word .eeef
!word .poke !word .poke
!word .construct
!word .meccm6
; ;
; Text can contain substitution strings, which ; Text can contain substitution strings, which
; are replaced by current values at runtime. Each ; are replaced by current values at runtime. Each
@ -196,7 +192,7 @@ StringTable
; can be set directly before calling PrintByID. ; can be set directly before calling PrintByID.
; ;
.header .header
!text "Passport by 4am 2017-02-20",00 !text "Passport by 4am 2017-02-21",00
.mainmenu .mainmenu
!text "________________________________________",$8D,$8D,$8D,$8D,$8D,$8D,$8D !text "________________________________________",$8D,$8D,$8D,$8D,$8D,$8D,$8D
!text " " !text " "
@ -335,8 +331,8 @@ StringTable
!text "T00,S00 Found ProDOS bootloader",$8D,00 !text "T00,S00 Found ProDOS bootloader",$8D,00
.pascalboot0 .pascalboot0
!text "T00,S00 Found Pascal bootloader",$8D,00 !text "T00,S00 Found Pascal bootloader",$8D,00
.meccboot0 .mecc
!text "T00 Found MECC M8 bootloader",$8D,00 !text "T00,S00 Found MECC bootloader",$8D,00
.sierra .sierra
!text "T%t,S%0 Found Sierra protection check",$8D,00 !text "T%t,S%0 Found Sierra protection check",$8D,00
.a6bc95 .a6bc95
@ -378,8 +374,8 @@ StringTable
!text "disk volume number.",$8D,00 !text "disk volume number.",$8D,00
.d5d5f7 .d5d5f7
!text "T%t,S%0 Found D5D5F7 protection check",$8D,00 !text "T%t,S%0 Found D5D5F7 protection check",$8D,00
.meccm7 .construct
!text "T00 Found MECC M7 bootloader",$8D,00 !text "T01,S0F Reconstructing missing data",$8D,$00
.datasoftb0 .datasoftb0
!text "T00,S00 Found Datasoft bootloader",$8D,00 !text "T00,S00 Found Datasoft bootloader",$8D,00
.datasoft .datasoft
@ -431,8 +427,4 @@ StringTable
.poke .poke
!text "T%t,S%0 BASIC program POKEs protection",$8D !text "T%t,S%0 BASIC program POKEs protection",$8D
!text "check into memory and CALLs it.",$8D,$00 !text "check into memory and CALLs it.",$8D,$00
.construct
!text "T01,S0F Reconstructing missing data",$8D,$00
.meccm6
!text "T00 Found MECC M6 bootloader",$8D,00
} }