passport/src/patchers/t00_bb03.a
2021-06-21 11:57:02 -04:00

95 lines
3.0 KiB
Plaintext
Executable File

;-------------------------------
; #BB03
; boot1 calls $BB03 for a self-decrypting nibble check
;
; variant 1a (JSR $BB03, push $B518)
; - Classifying Animals with Backbones
; - EduCalc
;
; variant 1b (JSR $BB03, push $B519)
; - Spanish for Mastery
;
; variant 2 (JSR $BB03 but David-DOS)
; - Case of the Great Train Robbery
; - Case of the Missing Chick
; - Mrs. Wigglesworth's Secret
; - Mystery of the Witch's Shoes
;
; variant 3 (JMP $BB03)
; - Alice in Wonderland (some versions)
; - Sum Ducks
; - Trivia Fever
;-------------------------------
!zone {
lda #$07 ; sector to check for David-DOS variant
lda gIsDavidDOS
beq .check
lda gIsBoot0 ; if DOS 3.3 boot0 loader
bne .exit
lda #$05 ; sector to check for DOS 3.3 variant
.check ldx #$03
jsr compare3 ; if T00,S0(5|7),$03 ==
!byte $4E,$06,$BB
bcs .exit
jsr PrintByID
!byte s_bb03
lda gIsDavidDOS
beq .variant2
lda #$01
ldx #$38
jsr compare3 ; if T00,S01,$38 ==
!byte $20,$03,$BB; JSR $BB03
bcc .variant1
jsr compare3 ; if T00,S01,$38 ==
!byte $4C,$03,$BB; JMP $BB03
bcs .exit
lda #$05
ldx #$6B
tay
jsr compare ; and T00,S05,$6B ==
!byte $06,$26,$7D; encrypted, decrypts to 'LDA $C08C,X / BPL -'
!byte $39,$41
bcs .exit
;variant3
jsr modify2 ; then set T00,S05,$6B =
!byte $6B,$F6 ; encrypted, decrypts to 'BNE +$5C' which will unconditionally branch to success path at $BBC9
lda #$06
ldx #$0F
jsr modify1 ; and set T00,S06,$0F =
!byte $89 ; encrypted, decrypts to $10 which is the expected nibble count value
; passport-test-suite/Trivia Fever.woz [V=0] reaches here
bvc .exit ; unconditional branch (V is always 0 coming out of modify)
.variant1
lda $1243
eor $1543
sta + ; calculate entry point of success path (usually #$18 but sometimes #$19)
lda #$05
ldx #$03
ldy #$09
jsr modify ; then set T00,S05,$03 =
!byte $A9,$B5
!byte $48
!byte $A9
+ !byte $FD ; SMC
!byte $48
!byte $4C,$93,$B7
; passport-test-suite/Classifying Animals with Backbones.woz [V=0] reaches here
bvc .exit ; unconditional branch (V is always 0 coming out of modify)
.variant2
ldx #$03 ; passport-test-suite/Case of the Great Train Robbery.woz [Z=0] reaches here
ldy #$0B
jsr modify ; then set T00,S07,$03 =
!byte $A9,$B5
!byte $48
!byte $A9,$18
!byte $48
!byte $A0,$04
!byte $4C,$A9,$B7
.exit
}