forked from KatDevsGames/z3randomizer
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathframehook.asm
75 lines (57 loc) · 1.57 KB
/
framehook.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
63
64
65
66
67
68
69
70
71
72
73
74
75
;================================================================================
; Frame Hook
;--------------------------------------------------------------------------------
FrameHookAction:
JSL $0080B5 ; Module_MainRouting
JSL CheckMusicLoadRequest
PHP : REP #$30 : PHA
SEP #$20
LDA StatsLocked : BNE ++
REP #$20 ; set 16-bit accumulator
LDA LoopFrames : INC : STA LoopFrames : BNE +
LDA LoopFrames+2 : INC : STA LoopFrames+2
+
LDA $10 : CMP.w #$010E : BNE + ; move this to nmi hook?
LDA MenuFrames : INC : STA MenuFrames : BNE +
LDA MenuFrames+2 : INC : STA MenuFrames+2
+
++
REP #$30 : PLA : PLP
RTL
!NMI_MW = "$7F5047"
;--------------------------------------------------------------------------------
NMIHookAction:
PHA : PHX : PHY : PHD ; thing we wrote over, push stuff
LDA !NMI_MW : BEQ ++
PHP
SEP #$30
LDA #$00 : STA !NMI_MW
; Multiworld text
LDA !NMI_MW+1 : BEQ +
LDA #$00 : STA !NMI_MW+1
JSL.l WriteText
+
PLP
++
LDA StatsLocked : AND.w #$00FF : BNE ++
LDA NMIFrames : INC : STA NMIFrames : BNE +
LDA NMIFrames+2 : INC : STA NMIFrames+2
+
++
JML.l NMIHookReturn
;--------------------------------------------------------------------------------
!NMI_AUX = "$7F5044"
PostNMIHookAction:
LDA.l !NMI_AUX+2 : BEQ .return
PHK
PEA .return-1
PHA
LDA.b #$00 : STA.l !NMI_AUX+2
REP #$20
LDA.l !NMI_AUX+0 : DEC : PHA
SEP #$20
RTL
.return
LDA.b $13 : STA.w $2100
JML.l PostNMIHookReturn
;--------------------------------------------------------------------------------