-
Notifications
You must be signed in to change notification settings - Fork 3
/
ancilla_milestone_item.asm
254 lines (146 loc) · 5.4 KB
/
ancilla_milestone_item.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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
; ==============================================================================
; $44A85-$44A8B DATA
pool Ancilla_MilestoneItem:
parallel pool Ancilla_ReceiveItem:
{
.ether_medallion
db $10
.pendants
db $37, $39, $38
.heart_container
db $26
.bombos_medallion
db $0F
.crystal
db $20
}
; ==============================================================================
; *$44A8C-$44BE3 JUMP LOCATION
Ancilla_MilestoneItem:
{
; Routines for pendants waiting to be picked up in a room.
; Is it the Ether medallion?
LDA $0C5E, X : CMP .ether_medallion : BEQ .medallion
CMP .bombos_medallion : BEQ .medallion
; Has the item in this room (usually pendant or crystal) already been obtained?
; Yes it has been obtained. Kill this pendant process.
LDA $0403 : AND.b #$40 : BNE .terminate_item
; Has the boss been beaten and a heart piece collected?
LDA $0403 : AND.b #$80 : BEQ .waitForEvent
; Delay timer?
LDA $04C2 : BEQ .countDownDone
CMP.b #$01 : BNE .countDownAndWait
; Is it a crystal?
LDY.b #$23
LDA $0C5E, X : CMP .crystal : BNE .not_crystal
LDA.b #$0F : STA $012D
LDY.b #$28
.not_crystal
TYA : STA $72
PHX
JSL GetAnimatedSpriteTile.variable
PLX
.countDownAndWait
DEC $04C2
.waitForEvent
RTS
.terminate_item
STZ $0C4A, X
RTS
.medallion
LDA $0394, X : BEQ .no_misc_palette_load
DEC $0394, X
RTS
; This code is executed when the item is just on the ground, laying there.
.countDownDone
LDA $039F, X : BNE .no_misc_palette_load
LDA $0C5E, X : CMP .crystal : BNE .no_misc_palette_load
; yes it's a crystal
LDA.b #$01 : STA $039F, X
PHX
LDA.b #$04 : STA $0AB1
LDA.b #$02 : STA $0AA9
JSL Palette_MiscSpr.justSP6
INC $15
PLX
.no_misc_palette_load
LDA $0C5E, X : CMP .crystal : BNE .dont_sparkle
JSR Ancilla_AddSwordChargeSpark
.dont_sparkle
LDA $11 : BNE .draw
; If altitude >= 0x18 you can't grab it.
LDA $029E, X : CMP.b #$18 : BCS .no_player_collision
LDY.b #$02
JSR Ancilla_CheckPlayerCollision : BCC .no_player_collision
LDA $037E : BNE .no_player_collision
LDA $4D : BNE .no_player_collision
STZ $0C4A, X
; Success, we've grabbed the item!
LDA $5D
CMP.b #$19 : BEQ .receiving_medallion_player_mode
CMP.b #$1A : BNE .not_receiving_medallion
.receiving_medallion_player_mode
STZ $0112
STZ $03EF
LDA.b #$00 : STA $5D
.not_receiving_medallion
; Indicate that the item is from an object
LDA.b #$03 : STA $02E9
PHX
; This will be the item to grant to Link.;
; Will get stored to $02D8 in the following routine.
TAY
LDA $0C5E, X
JSL Link_ReceiveItem
PLX
RTS
.no_player_collision
LDA $0C54, X : BEQ .hasnt_touched_grond
CMP #$02 : BEQ .draw
; Simulate gravity.
LDA $0294, X : SUB.b #$01 : STA $0294, X
.hasnt_touched_ground
JSR Ancilla_MoveAltitude
LDA $029E, X : CMP.b #$F8 : BCC .draw
; It hit the ground, so make the object bounce upward a bit.
INC $0C54, X
LDA.b #$18 : STA $0294, X
STZ $029E, X
.draw
JSR Ancilla_PrepAdjustedOamCoord
REP #$20
LDA $029E, X : AND.w #$00FF : STA $72
LDA $00 : STA $06 : SUB $72 : STA $00
SEP #$20
JSR Ancilla_ReceiveItem.draw
PHX
DEC $03B1, X : BPL .ripple_delay
LDA.b #$09 : STA $03B1, X
INC $0385, X : LDA $0385, X : CMP.b #$03 : BNE .not_ripple_reset
STZ $0385, X
.ripple_delay
.not_ripple_reset
LDA $0385, X : STA $72
LDA $029E, X : CMP.b #$00 : BNE .above_ground
LDX.b #$00
LDA $A0 : CMP.b #$06 : BNE .not_water_room
LDA $A1 : CMP.b #$00 : BNE .not_water_room
LDA $72 : ADD.b #$04 : TAX
BRA .draw_underside_sprite
.above_ground
LDX.b #$01
CMP.b #$20 : BCC .draw_underside_sprite
; Use a small shadow if the object is higher than 32 pixels off the
; ground.
INX
.not_water_room
.draw_underside_sprite
REP #$20
LDA $06 : ADD.w #$000C : STA $00
SEP #$20
LDA.b #$20 : STA $04
JSR Ancilla_DrawShadow
PLX
RTS
}
; ==============================================================================