-
Notifications
You must be signed in to change notification settings - Fork 53
/
rngfixes.asm
147 lines (145 loc) · 4.14 KB
/
rngfixes.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
;================================================================================
; RNG Fixes
;--------------------------------------------------------------------------------
RigDigRNG:
LDA.l MiniGameTime+1 : CMP.l DiggingGameRNG : !BGE .forceHeart
.normalItem
JML GetRandomInt
.forceHeart
LDA.l MiniGameTime : BNE .normalItem
LDA.b #$04
RTL
;--------------------------------------------------------------------------------
RigChestRNG:
JSL.l DecrementChestCounter
LDA.w $04C4 : CMP.l ChestGameRNG : BEQ .forceHeart
.normalItem
JSL GetRandomInt
AND.b #$07 ; restrict values to 0-7
CMP.b #$07 : BEQ .notHeart
JSL.l DecrementItemCounter
RTL
.forceHeart
LDA.b #$33 : STA.b ScrapBufferBD+$0B ; assure the correct state if player talked to shopkeeper
LDA.w RoomItemsTaken : AND.b #$40 : BNE .notHeart
LDA.b #$07 ; give prize item
RTL
.notHeart
JSL.l DecrementItemCounter
JSL GetRandomInt ; spam RNG until we stop getting the prize item
AND.b #$07 ; restrict values to 0-7
CMP.b #$07 : BNE + ; player got prize item AGAIN
LDA.b #$00 ; give them money instead
+
RTL
;--------------------------------------------------------------------------------
FixChestCounterForChestGame:
JSL DecrementItemCounter
JML $8DBA71
;--------------------------------------------------------------------------------
RNG_Lanmolas1:
LDA.b #$00 : BRA _rng_done
RNG_Moldorm1:
LDA.b #$01 : BRA _rng_done
RNG_Agahnim1:
LDA.b RoomIndex : CMP.b #$20 : BNE RNG_Agahnim2 ; Agah 1 and 2 use the same code, check which agah we're fighting and branch
LDA.b #$02
JSL.l GetStaticRNG : PHA
LDA.l GanonAgahRNG : BEQ + ; check if blue balls are disabled
PLA
ORA.b #$01 ; guarantee no blue ball
RTL
+
PLA
RTL
RNG_Helmasaur:
LDA.b #$03 : BRA _rng_done
RNG_Arrghus:
LDA.b #$04 : BRA _rng_done
RNG_Mothula:
LDA.b #$05 : BRA _rng_done
RNG_Kholdstare:
LDA.b #$06 : BRA _rng_done
RNG_Vitreous:
LDA.b #$07 : BRA _rng_done
RNG_Trinexx:
LDA.b #$08 : BRA _rng_done
RNG_Lanmolas2:;x
LDA.b #$09 : BRA _rng_done
RNG_Moldorm2:;x
LDA.b #$0A : BRA _rng_done
RNG_Agahnim2:
LDA.b #$0B
JSL.l GetStaticRNG : PHA
LDA.l GanonAgahRNG : BEQ + ; check if blue balls are disabled
PLA
ORA.b #$01 ; guarantee no blue ball
RTL
+
PLA
RTL
RNG_Agahnim2Phantoms:;x
LDA.b #$0C : BRA _rng_done
RNG_Ganon:
LDA.b #$0D : BRA _rng_done
RNG_Ganon_Extra_Warp:
LDA.b #$0E
JSL.l GetStaticRNG : PHA
LDA.l GanonAgahRNG : BEQ + ; check if warps are disabled
PLA
AND.b #$FE ; set least significant bit to 0 to prevent teleport
RTL
+
PLA
RTL
RNG_Enemy_Drops:
LDA.l ProgressIndicator : CMP.b #$01 : BEQ + ; drops are static after uncle pickup & before rescuing zelda
JML GetRandomInt
+
LDA.b #$0F
_rng_done:
JSL.l GetStaticRNG
RTL
;--------------------------------------------------------------------------------
; In: A = RNG Index
; Out: A = RNG Result
;--------------------------------------------------------------------------------
GetStaticRNG:
PHX : PHP
REP #$30 ; set 16-bit accumulator and index registers
AND.w #$000F
ASL : TAX : LDA.l RNGPointers, X : INC : AND.w #$03FF : STA.l RNGPointers, X : TAX ; increment pointer and move value to X
LDA.l Static_RNG, X ; load RNG value
PLP : PLX
RTL
;--------------------------------------------------------------------------------
InitRNGPointerTable:
PHX : PHP
REP #$30 ; set 16-bit accumulator & index registers
LDX.w #$0000
-
LDA.l .rngDefaults, X : STA.l RNGPointers, X : INX #2
LDA.l .rngDefaults, X : STA.l RNGPointers, X : INX #2
LDA.l .rngDefaults, X : STA.l RNGPointers, X : INX #2
LDA.l .rngDefaults, X : STA.l RNGPointers, X : INX #2
CPX.w #$001F : !BLT -
PLP : PLX
RTL
.rngDefaults
dw $0000 ; 00 = Lanmolas 1
dw $0040 ; 01 = Moldorm 1
dw $0080 ; 02 = Agahnim 1
dw $00C0 ; 03 = Helmasaur
dw $0100 ; 04 = Arrghus
dw $0140 ; 05 = Mothula
dw $0180 ; 06 = Kholdstare
dw $01C0 ; 07 = Vitreous
dw $0200 ; 08 = Trinexx
dw $0240 ; 09 = Lanmolas 2
dw $0280 ; 10 = Moldorm 2
dw $02C0 ; 11 = Agahnim 2
dw $0300 ; 12 = Agahnim 2 Phantoms
dw $0340 ; 13 = Ganon
dw $0380 ; 14 = Ganon Extra Warp
dw $03C0 ; 15 = Standard Escape Enemy Drops
;--------------------------------------------------------------------------------