-
Notifications
You must be signed in to change notification settings - Fork 53
/
npcitems.asm
217 lines (188 loc) · 5.73 KB
/
npcitems.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
;================================================================================
; Randomize NPC Items
;--------------------------------------------------------------------------------
; Old Man - Zora King - Sick Kid - Tree Kid - Sahasrala - Catfish - Rupee NPC
;=SET 1
;OLD_MAN = "#$01"
;ZORA_KING = "#$02"
;SICK_KID = "#$04"
;TREE_KID = "#$08"
;SAHASRALA = "#$10"
;CATFISH = "#$20"
;UNUSED = "#$40"
;BOOK_MUDORA = "#$80"
;=SET 2
;ETHER_TABLET = "#$01"
;BOMBOS_TABLET = "#$02"
;SMITH_SWORD = "#$04"
;FAIRY_SWORD = "#$08"
;MUSHROOM = "#$10"
;POWDER = "#$20"
;UNUSED = "#$40"
;MAGIC_BAT = "#$80"
;--------------------------------------------------------------------------------
ItemCheck_FairySword:
LDA.l NpcFlags+1 : AND.b #$08
RTL
ItemCheck_SmithSword:
LDA.l NpcFlags+1 : AND.b #$04
RTL
ItemCheck_MagicBat:
LDA.l NpcFlags+1 : AND.b #$80
RTL
ItemCheck_OldMan:
LDA.l NpcFlags : AND.b #$01 : CMP.b #$01
RTL
ItemCheck_ZoraKing:
LDA.l NpcFlags : AND.b #$02
RTL
ItemCheck_SickKid:
LDA.l NpcFlags : AND.b #$04
RTL
ItemCheck_TreeKid:
LDA.l NpcFlags : AND.b #$08
RTL
ItemCheck_TreeKid2:
LDA.l NpcFlags : AND.b #$08
LSR #2
RTL
ItemCheck_TreeKid3:
JSL $8DD030 ; FluteAardvark_Draw - thing we wrote over
LDA.l NpcFlags : AND.b #$08
BNE .done
LDA.b #$05
.normal
LDA.w SpriteActivity, X
.done
RTL
ItemCheck_Sahasrala:
LDA.l NpcFlags : AND.b #$10
RTL
ItemCheck_Library:
LDA.l NpcFlags : AND.b #$80
RTL
ItemCheck_Mushroom:
LDA.l NpcFlags+1 : AND.b #$10 : CMP.b #$10 ; does the same thing as below
RTL
ItemCheck_Powder:
LDA.l NpcFlags+1 : AND.b #$20
RTL
ItemCheck_Catfish:
LDA.l NpcFlags : AND.b #$20
RTL
;--------------------------------------------------------------------------------
ItemSet_FairySword:
PHA : LDA.l NpcFlags+1 : ORA.b #$08 : STA.l NpcFlags+1 : PLA
RTL
ItemSet_SmithSword:
PHA : LDA.l NpcFlags+1 : ORA.b #$04 : STA.l NpcFlags+1 : PLA
RTL
ItemSet_MagicBat:
PHA : LDA.l NpcFlags+1 : ORA.b #$80 : STA.l NpcFlags+1 : PLA
RTL
ItemSet_OldMan:
JSL.l Link_ReceiveItem ; thing we wrote over
PHA : LDA.l NpcFlags : ORA.b #$01 : STA.l NpcFlags : PLA
RTL
ItemSet_ZoraKing:
PHA : LDA.l NpcFlags : ORA.b #$02 : STA.l NpcFlags : PLA
RTL
ItemSet_SickKid:
JSL.l Link_ReceiveItem ; thing we wrote over
PHA : LDA.l NpcFlags : ORA.b #$04 : STA.l NpcFlags : PLA
RTL
ItemSet_TreeKid:
JSL.l Link_ReceiveItem ; thing we wrote over
PHA : LDA.l NpcFlags : ORA.b #$08 : STA.l NpcFlags : PLA
RTL
ItemSet_Sahasrala:
JSL.l Link_ReceiveItem ; thing we wrote over
PHA : LDA.l NpcFlags : ORA.b #$10 : STA.l NpcFlags : PLA
RTL
ItemSet_Catfish:
PHA : LDA.l NpcFlags : ORA.b #$20 : STA.l NpcFlags : PLA
RTL
ItemSet_Library:
JSL.l Link_ReceiveItem ; thing we wrote over
PHA : LDA.l NpcFlags : ORA.b #$80 : STA.l NpcFlags : PLA
RTL
ItemSet_Mushroom:
PHA
LDA.l NpcFlags+1 : ORA.b #$10 : STA.l NpcFlags+1
LDY.w SpriteID, X ; Retrieve stored item type
BNE +
; if for any reason the item value is 0 reload it, just in case
%GetPossiblyEncryptedItem(MushroomItem, SpriteItemValues) : TAY
+
PLA
STZ.w ItemReceiptMethod ; thing we wrote over - the mushroom is an npc for item purposes apparently
RTL
ItemSet_Powder:
PHA : LDA.l NpcFlags+1 : ORA.b #$20 : STA.l NpcFlags+1 : PLA
RTL
;================================================================================
;================================================================================
; Randomize 300 Rupee NPC
;--------------------------------------------------------------------------------
Set300RupeeNPCItem:
INC.w SpriteActivity, X ; thing we wrote over
PHA : PHP
REP #$20 ; set 16-bit accumulator
LDA.b RoomIndex ; these are all decimal because i got them that way
CMP.w #291 : BNE +
%GetPossiblyEncryptedItem(RupeeNPC_MoldormCave, SpriteItemValues)
TAY ; load moldorm cave value into Y
BRA .done
+ CMP.w #286 : BNE +
%GetPossiblyEncryptedItem(RupeeNPC_NortheastDarkSwampCave, SpriteItemValues)
TAY ; load northeast dark swamp cave value into Y
BRA .done
+
LDY.b #$46 ; default to a normal 300 rupees
.done
PLP : PLA
RTL
;================================================================================
; Randomize Zora King
;--------------------------------------------------------------------------------
LoadZoraKingItemGFX:
LDA.l $9DE1C3 ; location randomizer writes zora item to
JSL.l AttemptItemSubstitution
JSL.l ResolveLootIDLong
STA.w SpriteID,Y
TYX
JML.l PrepDynamicTile_loot_resolved
;--------------------------------------------------------------------------------
JumpToSplashItemTarget:
LDA.w SpriteMovement, X
CMP.b #$FF : BNE + : JML.l SplashItem_SpawnSplash : +
CMP.b #$00 : JML.l SplashItem_SpawnOther
;================================================================================
; Randomize Catfish
;--------------------------------------------------------------------------------
LoadCatfishItemGFX:
LDA.l $9DE185 ; location randomizer writes catfish item to
JSL.l AttemptItemSubstitution
JSL.l ResolveLootIDLong
STA.w SpriteID, Y
TYX
JML.l PrepDynamicTile_loot_resolved
;--------------------------------------------------------------------------------
DrawThrownItem:
LDA.b OverworldIndex : CMP.b #$81 : BNE .catfish
.zora
LDA.b #$01 : STA.l RedrawFlag
BRA .draw
.catfish
.draw
LDA.w SpriteID,X
JML DrawDynamicTile
;--------------------------------------------------------------------------------
MarkThrownItem:
JSL Link_ReceiveItem ; thing we wrote over
LDA.b OverworldIndex : CMP.b #$81 : BNE .catfish
.zora
JML ItemSet_ZoraKing
.catfish
JML ItemSet_Catfish
;--------------------------------------------------------------------------------