forked from aerinon/z3randomizer
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnpcitems.asm
238 lines (205 loc) · 6.33 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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
;================================================================================
; 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 SpriteDraw_Stumpy ; 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:
PHA : LDA.l OldManItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID : PLA
JSL 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:
PHA : LDA.l SickKidItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID : PLA
JSL Link_ReceiveItem ; thing we wrote over
PHA : LDA.l NpcFlags : ORA.b #$04 : STA.l NpcFlags : PLA
RTL
ItemSet_TreeKid:
PHA : LDA.l TreeKidItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID : PLA
JSL Link_ReceiveItem ; thing we wrote over
PHA : LDA.l NpcFlags : ORA.b #$08 : STA.l NpcFlags : PLA
RTL
ItemSet_Sahasrala:
PHA : LDA.l SahasralaItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID : PLA
JSL 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:
PHA : LDA.l LibraryItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID : PLA
JSL 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 SprItemReceipt, X ; Retrieve stored item type
BNE +
; if for any reason the item value is 0 reload it, just in case
%GetPossiblyEncryptedItem(MushroomItem, SpriteItemValues) : TAY
+
LDA.l MushroomItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID
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
LDA.l RupeeNPC_MoldormCave_Player
BRA .done
+ CMP.w #286 : BNE +
%GetPossiblyEncryptedItem(RupeeNPC_NortheastDarkSwampCave, SpriteItemValues)
TAY ; load northeast dark swamp cave value into Y
LDA.l RupeeNPC_NortheastDarkSwampCave_Player
BRA .done
+
LDA.w #$0000
LDY.b #$46 ; default to a normal 300 rupees
.done
SEP #$20
STA.l !MULTIWORLD_ITEM_PLAYER_ID
PLP : PLA
RTL
;================================================================================
; Randomize Zora King
;--------------------------------------------------------------------------------
LoadZoraKingItemGFX:
LDA.l ZoraItem_Player : STA.l !MULTIWORLD_SPRITEITEM_PLAYER_ID
LDA.l $1DE1C3 ; location randomizer writes zora item to
STA.w SprSourceItemId, Y
PHX : TYX : PLY
JSL RequestStandingItemVRAMSlot
PHY : TXY : PLX
RTL
;--------------------------------------------------------------------------------
JumpToSplashItemTarget:
LDA.w SpriteMovement, X
CMP.b #$FF : BNE + : JML SplashItem_SpawnSplash : +
CMP.b #$00 : JML SplashItem_SpawnOther
;================================================================================
; Randomize Catfish
;--------------------------------------------------------------------------------
LoadCatfishItemGFX:
LDA.l CatfishItem_Player : STA.l !MULTIWORLD_SPRITEITEM_PLAYER_ID
LDA.l $1DE185 ; location randomizer writes catfish item to
STA.w SprSourceItemId, Y
PHX : TYX : PLY
JSL RequestStandingItemVRAMSlot
PHY : TXY : PLX
RTL
;--------------------------------------------------------------------------------
DrawThrownItem:
LDA.w SprRedrawFlag, X : BEQ +
LDA.w SprSourceItemId, X
JML RequestStandingItemVRAMSlot
+ LDA.w SprItemReceipt,X
JML DrawPotItem
;--------------------------------------------------------------------------------
MarkThrownItem:
PHA
LDA.b OverworldIndex : CMP.b #$81 : BNE .catfish
.zora
JSL ItemSet_ZoraKing
LDA.l ZoraItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID
BRA .done
.catfish
JSL ItemSet_Catfish
LDA.l CatfishItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID
.done
PLA
JSL Link_ReceiveItem ; thing we wrote over
RTL
;--------------------------------------------------------------------------------