forked from ArchipelagoMW/z3randomizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.asm
62 lines (54 loc) · 1.72 KB
/
init.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
;--------------------------------------------------------------------------------
; Init_Primary
;--------------------------------------------------------------------------------
; This can be as inefficient as we want. Interrupts are off when this gets
; called and it only gets called once ever during RESET.
;--------------------------------------------------------------------------------
Init_Primary:
LDA #$00
LDX #$00 ; initalize our ram
-
STA $7EC025, X
STA $7F5000, X
INX
CPX #$10 : !BLT -
LDX #$10 ; initalize more ram
-
STA $7F5000, X
INX
CPX #$FF : !BLT -
LDX #$00
-
LDA $702000, X : CMP $00FFC0, X : BNE .clear
INX
CPX #$15 : !BLT -
BRA .done
.clear
REP #$30 ; set 16-bit accumulator & index registers
LDA.w #$0000
-
STA $700000, X
INX
CPX #$2000 : !BLT -
SEP #$30 ; set 8-bit accumulator & index registers
LDX #$00
-
LDA $00FFC0, X : STA $702000, X
INX
CPX #$15 : !BLT -
.done
LDA DeathLink : STA $702000, X ; move death link byte to just after the sram copy of rom header
LDA.b #$01 : STA $420D ; enable fastrom access on upper banks
LDA.b #$10 : STA $BC ; set default player sprite bank
LDA.b #$81 : STA $4200 ; thing we wrote over, turn on NMI & gamepad
RTL
;--------------------------------------------------------------------------------
; Init_PostRAMClear
;--------------------------------------------------------------------------------
; This gets called after banks $7E and $7F get cleared, so if we need to
; initialize RAM in those banks, do it here
;--------------------------------------------------------------------------------
Init_PostRAMClear:
JSL MSUInit
JSL InitRNGPointerTable
JML $00D463 ; The original target of the jump table that we hijacked