anti-m/src/idantim.a
2019-03-09 19:29:19 -08:00

82 lines
2.0 KiB
Plaintext

IDAntiM
lda #8
ldx #1
ldy #11
jsr CompareMemory
!byte $A2,$00 ;LDX #$00
!byte $BD,$00,$08 ;LDA $0800,X
!byte $9D,$00,$02 ;STA $0200,X
!byte $E8 ;INX
!byte $D0,$F7 ;BNE *-7
bcs @exit
; patch code to regain control after it loads 1 sector into $0300
lda #<@callback1
sta $0838
lda #>@callback1
sta $0839
@exit
rts
@callback1
; duplicate bootloader from $0300 to $0200
ldx #$00
- lda $0300,x
sta $0200,x
inx
bne -
- lda @copysrc,x
sta $1700,x
inx
bne -
; patch bootloader so it reads the pristine copy at $0200
dec $030A
dec $0310
dec $0316
dec $031C
; patch bootloader to regain control after it decrypts itself into $0100
lda #$4C
sta $0325
lda #<@callback2
sta $0326
lda #>@callback2
sta $0327
jmp $0301
@copysrc
!pseudopc $1700 {
@callback2
; patch bootloader to regain control after it loads 4 sectors into $0400
lda #$4C
sta $01FB
lda #<@callback3
sta $01FC
lda #>@callback3
sta $01FD
rts
@callback3
; patch bootloader so it doesn't wipe main memory
lda #$60
sta $04E2
; patch bootloader to regain control after it loads title screen and code into $2000+
lda #$4C
sta $0498
lda #<@callback4
sta $0499
lda #>@callback4
sta $049A
; restore bytes on stack page that we patched earlier because they're checksummed soon
lda #$AE
sta $01FB
lda #$65
sta $01FC
lda #$05
sta $01FD
jmp $01FB
@callback4
; patch bootloader to bypass ROM check at $6300
lda #$60
sta $0421
jmp $0400
}