-
Notifications
You must be signed in to change notification settings - Fork 0
/
aanimator.asm
417 lines (403 loc) · 6.27 KB
/
aanimator.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
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
;Airaki! - FSE 2014
;Released under the GPL V3, see LICENSE.TXT
;Commands:
;00: EOL
;01: Load gfx
; ## first tile #
; #### address of data
;02: Make sprite
; ## sprid (0~15)
; ## first tile #
; ## attr
; ## X
; ## Y
;03: Move sprite
; ## sprid (0~15)
; ## X
; ## Y
;04: Link MotionLUT to sprite (NOT IMPLEMENTED, DO NOT USE !)
; ## sprid (0~15)
; ## lut size
; #### address of lut
;05: Run motionLUT(s) (NOT IMPLEMENTED, DO NOT USE !)
; ## speed
;06: Move relative
; ## sprid (0~15)
; ## X
; ## Y
;07: Jump to
; ## number of loops
; #### address
;08: Hide sprite
; ## sprid (0~15)
;09: Wait frames
; ## frames
;10: Call routine
; #### address
;11: Play sound
; ## sound id
aaecmd_jt:
.dw aa_00e ;EOL
.dw aa_01e ;Load gfx
.dw aa_02e ;Make sprite
.dw aa_03 ;Move sprite
.dw aa_04 ;Link MoLUT to sprite
.dw aa_05 ;Run MoLUT
.dw aa_06 ;Move relative
.dw aa_07e ;Jump to
.dw aa_08 ;Delete sprite
.dw aa_09e ;Wait frames
.dw aa_10 ;Call routine
.dw aa_11
aapcmd_jt:
.dw aa_00p ;EOL
.dw aa_01p ;Load gfx
.dw aa_02p ;Make sprite
.dw aa_03 ;Move sprite
.dw aa_04 ;Link MoLUT to sprite
.dw aa_05 ;Run MoLUT
.dw aa_06 ;Move relative
.dw aa_07p ;Jump to
.dw aa_08 ;Delete sprite
.dw aa_09p ;Wait frames
.dw aa_10 ;Call routine
.dw aa_11
aa_00e:
dec de
xor a
ld (AA_E_RUN),a
jp aa_ret
aa_00p:
dec de
xor a
ld (AA_P_RUN),a
jp aa_ret
aa_01e:
ld a,(de)
add T_AASPRE
-:
inc de
ld b,8 ;To end up with $8xxx
ld c,a
sla c
rl b
sla c
rl b
sla c
rl b
sla c
rl b ;BC*16
ld a,(de)
ld l,a
inc de
ld a,(de)
inc de
ld h,a
push de
push bc
pop de
call loadtiles_auto
pop de
jp aa_continue
aa_01p:
ld a,(de)
add T_AASPRP
jr -
aa_02e:
call aa_getspraddr
ld a,(de)
add T_AASPRE
-:
ldi (hl),a ;Tile
inc de
ld a,(de)
ld (hl),a ;Attr
inc de
jr +
aa_02p:
call aa_getspraddr
ld a,(de)
add T_AASPRP
jr -
aa_03:
call aa_getspraddr
inc hl
+:
inc hl
ld a,(de)
ldi (hl),a ;X
inc de
ld a,(de)
ld (hl),a ;Y
inc de
jp aa_continue
aa_04:
;call aa_getspraddr
;inc hl
;inc hl
;inc hl
;inc hl
;ld a,(de)
;ldi (hl),a ;Mo LUT address LSB
;inc de
;ld a,(de)
;ldi (hl),a ;Mo LUT address MSB
;inc de
;ld a,(de)
;ldi (hl),a ;Mo LUT size
;inc de
;ld (hl),a ;Mo LUT index = size (stop)
jp aa_continue
aa_05:
;call aa_getspraddr
;ld bc,7
;add hl,bc
;xor a
;ld (hl),a ;Mo LUT index = 0 (run)
jp aa_continue
aa_06:
call aa_getspraddr
inc hl
inc hl
ld a,(de)
add (hl)
ldi (hl),a ;X
inc de
ld a,(de)
add (hl)
ld (hl),a ;Y
inc de
jp aa_continue
aa_07e:
ld a,(AA_E_LOOP)
or a
jr nz,+
ld a,(de)
inc a
+:
inc de
dec a
ld (AA_E_LOOP),a
jr nz,+
inc de
inc de
jp aa_continue
+:
-:
push de
pop hl
ldi a,(hl)
ld d,(hl)
ld e,a
ld hl,AA_E_PTR
ld (hl),e
inc hl
ld (hl),d
jp aa_continue
aa_07p:
ld a,(AA_P_LOOP)
or a
jr nz,+
ld a,(de)
inc a
+:
inc de
dec a
ld (AA_P_LOOP),a
jr nz,+
inc de
inc de
jp aa_continue
+:
-:
push de
pop hl
ldi a,(hl)
ld d,(hl)
ld e,a
ld hl,AA_P_PTR
ld (hl),e
inc hl
ld (hl),d
jp aa_continue
aa_08:
call aa_getspraddr
xor a
ld (hl),a ;Tile
jp aa_continue
aa_09e:
ld a,(de)
inc de
ld (AA_E_WAIT),a
jp aa_ret
aa_09p:
ld a,(de)
inc de
ld (AA_P_WAIT),a
jp aa_ret
aa_10:
ld a,(de)
ld l,a
inc de
ld a,(de)
ld h,a
inc de
push de
call dojump
pop de
jp aa_continue
aa_11:
ld a,(de)
ld l,a
inc de
ld a,(de)
ld h,a
inc de
call sfx_play
jp aa_continue
aa_getspraddr:
ld a,(de)
inc de
sla a
sla a ;*4
ld b,0
ld c,a
ld hl,AA_SPR
add hl,bc
ret
;de=animation script ptr
aa_init_enemy:
ld hl,AA_E_PTR
ld (hl),e
inc hl
ld (hl),d
xor a
ld (AA_E_WAIT),a
inc a
ld (AA_E_RUN),a
ret
aa_init_player:
ld hl,AA_P_PTR
ld (hl),e
inc hl
ld (hl),d
xor a
ld (AA_P_WAIT),a
inc a
ld (AA_P_RUN),a
ret
aa_run_e:
ld a,(AA_E_RUN)
or a
ret z
ld a,(AA_E_WAIT)
or a
jr z,+
dec a
ld (AA_E_WAIT),a
ret
+:
ld hl,AA_E_PTR
ldi a,(hl)
ld d,(hl)
ld e,a
dec hl
push hl
ld hl,aaecmd_jt
jr aa_run_lp
aa_run_p:
ld a,(AA_P_RUN)
or a
ret z
ld a,(AA_P_WAIT)
or a
jr z,+
dec a
ld (AA_P_WAIT),a
ret
+:
ld hl,AA_P_PTR
ldi a,(hl)
ld d,(hl)
ld e,a
dec hl
push hl
ld hl,aapcmd_jt
jr aa_run_lp
aa_run_lp:
push hl
aa_continue:
ld a,(de)
inc de
sla a
pop hl
push hl
rst 0
inc hl
ld h,(hl)
ld l,a
jp hl
aa_ret:
pop hl
pop hl
ld (hl),e
inc hl
ld (hl),d
ret
aa_render:
ld b,16
ld de,AA_SPR
-:
ld a,(de)
or a
jr nz,+
ld a,e
add 4
ld e,a
jr nc,++
inc d
++:
--:
dec b
jr nz,-
ret
+:
push bc
inc de
ld b,a
ld a,(de)
inc de
ld c,a
;B=Tile #
;C=ATtr
ld a,(de) ;X
inc de
inc hl
ldd (hl),a
ld a,(de) ;Y
dec de
ldi (hl),a
inc hl
ld a,b
ldi (hl),a ;Tile #
ld a,c
;or PALETTE_RED
ldi (hl),a ;Attr
ld a,(de) ;X
add 8
inc de
inc hl
ldd (hl),a
ld a,(de) ;Y
ldi (hl),a
inc hl
ld a,b
inc a
inc a
ldi (hl),a ;Tile #
ld a,c
;or PALETTE_RED
ldi (hl),a ;Attr
inc de
pop bc
jr --