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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
|
INCLUDE "engine/facings.asm"
SpriteMovementData:: INCLUDE "data/map_objects.asm"
DeleteMapObject:: ; 4358 (1:4358)
push bc
ld hl, $1
add hl, bc
ld a, [hl]
push af
ld h, b
ld l, c
ld bc, $28
xor a
call ByteFill
pop af
cp $ff
jr z, .asm_437a
bit 7, a
jr nz, .asm_437a
call GetMapObject
ld hl, $0
add hl, bc
ld [hl], $ff
.asm_437a
pop bc
ret
Function4442:
call .CheckObjectStillVisible
ret c
call .HandleStepType
call .HandleObjectAction
ret
.CheckObjectStillVisible: ; 4387 (1:4387)
ld hl, $5
add hl, bc
res 6, [hl]
ld a, [wda03]
ld e, a
ld hl, $10
add hl, bc
ld a, [hl]
add $1
sub e
jr c, .asm_43b3
cp $c
jr nc, .asm_43b3
ld a, [wda02]
ld e, a
ld hl, $11
add hl, bc
ld a, [hl]
add $1
sub e
jr c, .asm_43b3
cp $b
jr nc, .asm_43b3
jr .asm_43dd
.asm_43b3
ld hl, $5
add hl, bc
set 6, [hl]
ld a, [wda03]
ld e, a
ld hl, $14
add hl, bc
ld a, [hl]
add $1
sub e
jr c, .asm_43df
cp $c
jr nc, .asm_43df
ld a, [wda02]
ld e, a
ld hl, $15
add hl, bc
ld a, [hl]
add $1
sub e
jr c, .asm_43df
cp $b
jr nc, .asm_43df
.asm_43dd
and a
ret
.asm_43df
ld hl, $4
add hl, bc
bit 1, [hl]
jr nz, .asm_43ec
call DeleteMapObject
scf
ret
.asm_43ec
ld hl, $5
add hl, bc
set 6, [hl]
and a
ret
.HandleStepType: ; 43f4 (1:43f4)
ld hl, $9
add hl, bc
ld a, [hl]
and a
jr z, .asm_440a
ld hl, $5
add hl, bc
bit 5, [hl]
jr nz, .asm_4427
cp $1
jr z, .asm_4415
jr .asm_4422
.asm_440a
call ObjectMovementReset
ld hl, $5
add hl, bc
bit 5, [hl]
jr nz, .asm_4427
.asm_4415
call MapObjectMovementPattern
ld hl, $9
add hl, bc
ld a, [hl]
and a
ret z
cp $1
ret z
.asm_4422
ld hl, StepTypesJumptable
rst JumpTable
ret
.asm_4427
ret
.HandleObjectAction: ; 4428 (1:4428)
ld hl, $4
add hl, bc
bit 0, [hl]
jr nz, Function44a0
ld hl, $5
add hl, bc
bit 6, [hl]
jr nz, Function44a0
bit 5, [hl]
jr nz, asm_4449
ld de, Pointers4460
jr asm_444e
Function4441:
ld hl, $4
add hl, bc
bit 0, [hl]
jr nz, Function44a0
asm_4449
ld de, Pointers4460 + 2
jr asm_444e
asm_444e
INCLUDE "engine/map_object_action.asm"
CopyNextCoordsTileToStandingCoordsTile: ; 45d9 (1:45d9)
ld hl, $10
add hl, bc
ld a, [hl]
ld hl, $12
add hl, bc
ld [hl], a
ld hl, $11
add hl, bc
ld a, [hl]
ld hl, $13
add hl, bc
ld [hl], a
ld hl, $e
add hl, bc
ld a, [hl]
ld hl, $f
add hl, bc
ld [hl], a
call SetGrassPriority
ld hl, $e
add hl, bc
ld a, [hl]
call UselessAndA
ret
Function4603:
ld hl, $12
add hl, bc
ld a, [hl]
ld hl, $10
add hl, bc
ld [hl], a
ld hl, $13
add hl, bc
ld a, [hl]
ld hl, $11
add hl, bc
ld [hl], a
ret
UpdateGrassPriority:
ld hl, $5
add hl, bc
bit 3, [hl]
jr z, .asm_4628
ld hl, $e
add hl, bc
ld a, [hl]
call SetGrassPriority
.asm_4628
ld hl, $e
add hl, bc
ld a, [hl]
call UselessAndA
ret c
ld hl, $f
add hl, bc
ld a, [hl]
call UselessAndA
ret
SetGrassPriority: ; 463a (1:463a)
call CheckSuperTallGrassTile
jr z, .asm_4644
call CheckGrassTile
jr c, .asm_464b
.asm_4644
ld hl, $5
add hl, bc
set 3, [hl]
ret
.asm_464b
ld hl, $5
add hl, bc
res 3, [hl]
ret
UselessAndA: ; 4652 (1:4652)
and a
ret
EndSpriteMovement:
xor a
ld hl, $c
add hl, bc
ld [hl], a
ld hl, $1b
add hl, bc
ld [hli], a
ld [hli], a
ld [hli], a
ld [hl], a
ld hl, $7
add hl, bc
ld [hl], $ff
ret
InitStep:
ld hl, $7
add hl, bc
ld [hl], a
ld hl, $4
add hl, bc
bit 2, [hl]
jr nz, GetNextTile
add a
add a
and $c
ld hl, $8
add hl, bc
ld [hl], a
GetNextTile:
call GetStepVector
ld hl, $a
add hl, bc
ld [hl], a
ld a, d
call GetStepVectorSign
ld hl, $12
add hl, bc
add [hl]
ld hl, $10
add hl, bc
ld [hl], a
ld d, a
ld a, e
call GetStepVectorSign
ld hl, $13
add hl, bc
add [hl]
ld hl, $11
add hl, bc
ld [hl], a
ld e, a
push bc
call GetCoordTile
pop bc
ld hl, $e
add hl, bc
ld [hl], a
ret
AddStepVector: ; 46b0 (1:46b0)
call GetStepVector
ld hl, $17
add hl, bc
ld a, [hl]
add d
ld [hl], a
ld hl, $18
add hl, bc
ld a, [hl]
add e
ld [hl], a
ret
GetStepVector: ; 46c2 (1:46c2)
ld hl, $7
add hl, bc
ld a, [hl]
and $f
add a
add a
ld l, a
ld h, $0
ld de, StepVectors
add hl, de
ld d, [hl]
inc hl
ld e, [hl]
inc hl
ld a, [hli]
ld h, [hl]
ret
StepVectors: ; 46d9
; x, y, duration, speed
; slow
db 0, 1, 16, 1
db 0, -1, 16, 1
db -1, 0, 16, 1
db 1, 0, 16, 1
; normal
db 0, 2, 8, 2
db 0, -2, 8, 2
db -2, 0, 8, 2
db 2, 0, 8, 2
; fast
db 0, 4, 4, 4
db 0, -4, 4, 4
db -4, 0, 4, 4
db 4, 0, 4, 4
GetStepVectorSign: ; 4709 (1:4709)
add a
ret z
ld a, $1
ret nc
ld a, $ff
ret
UpdatePlayerStep:
ld hl, $7
add hl, bc
ld a, [hl]
and $3
ld [wPlayerStepDirection], a
call AddStepVector
ld a, [wPlayerStepVectorX]
add d
ld [wPlayerStepVectorX], a
ld a, [wPlayerStepVectorY]
add e
ld [wPlayerStepVectorY], a
ld hl, wPlayerStepFlags
set 5, [hl]
ret
Function4732:
push bc
ld e, a
ld d, $0
ld hl, $1
add hl, bc
ld a, [hl]
call GetMapObject
add hl, de
ld a, [hl]
pop bc
ret
INCLUDE "engine/movement_pattern.asm"
INCLUDE "engine/step_types.asm"
INCLUDE "engine/movement.asm"
Function53b1:
dr $53b1, $5457
Function5457:
dr $5457, $54d7
Function54d7:
dr $54d7, $557f
Function557f::
dr $557f, $5730
Function5730::
dr $5730, $5795
StopFollow::
dr $5795, $5896
UpdateSprites_::
dr $5896, $58c5
|