-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path2-st_fall.asm
284 lines (251 loc) · 5.7 KB
/
2-st_fall.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
; vi: syntax=asm68k
;{ 2/proc126, 2/com_33, 10/proc327 }
;:1cae 2/proc129()
;Set up #FALL state (fall/land)
; -> called after #MIDJMP or #WHOA
; arg A6: (dc_t *)
; A2: (map_t *)
; D0.w: dc.X (coord_t)
; D1.w: .Y (coord_t)
ch_fall:
;#FALL(D1, 10, 0, N/A)
move.w d1, _VY0(a6)
push d0
move.w #SND_LAND, d0
jsr 1/play_snd(a5)
pop d0
bra.s .fall2 ;2/jbox_fall():
;{ 2/proc113, 2/proc117, 14/proc357 }
;:1cc0 2/proc130()
;Fall to death -> #FALL
dy_fall:
;#FALL(-200, 10, 0, N/A)
move.w #-200, _VY0(a6)
move.w #FALL, _ST(a6)
clr.w _VFAL(a6)
move.w #10, _VDY(a6)
;offscreen (left)?
ledge cmp.w lscr_edge(a5), d0
bge.s .redge
move.w lscr_edge(a5), d0
bra.s .dyfall2
; " (right)?
redge cmp.w rscr_edge(a5), d0
ble.s .retdy
move.w rscr_edge(a5), d0
dyfall2 move.w d0, _X(a6)
retdy bra .endfall
;[RTS]
;:1cf4 2/com_27()
;Fall/land inside jumpbox -> #FALL
; args A6,A2,D0/D1: as st_fall()
jbox_fall:
;#FALL(D1-31, 10, 0, N/A)
move.w d1, _VY0(a6)
subi.w #31, _VY0(a6)
push d0
move.w #SND_LAND, d0
jsr 1/play_snd(a5)
pop d0
nop
;2/ch_fall() ENTRY POINT
fall2 move.w #FALL, _ST(a6)
clr.w _VFAL(a6)
move.w #10, _VDY(a6)
ledge2 cmp.w lscr_edge(a5), d0
bge.s .redge2
move.w lscr_edge(a5), d0
addi.w #10, d0
move.w d0, _X(a6)
bra.s 2/st_fall(pc)
redge2 cmp.w rscr_edge(a5), d0
ble.s 2/st_fall(pc)
move.w rscr_edge(a5), d0
subi.w #10, d0
move.w d0, _X(a6)
; .. st_fall()
; { 2/proc113, 2/proc126, 2/com_27 }
;48 _VY0(a6).w: initial dc.Y/-200
;50 _VDY(a6).w: fall veloc (init +10)
;52 _VFAL(a6).w: fall type {0,1,2}
;54 _VSPR(a6).l: (spr_t *) NOT type 0!
;:1d42 2/com_28()
;:1e42 2/com_29()
;:1ebc 2/com_30()
;:1eea 2/com_31()
;:1f24 2/com_32()
;#FALL state handler
; args A6,A2/D4,D0/D1: as st_jmpoff()
st_fall:
;fall down (w/gravity)
add.w _VDY(a6), d1
addq.w #8, _VDY(a6)
clr.w d2
;get row for new pos
move.w _RWP(a6), d3
flrow move.w _Y(a2,d3.w), d7
cmp.w d1, d7
bra.s .flrow2
rowdown addq.w #4, d3
bra .flrow
;path clear? -> [fall]
flrow2 bgt .bltfall
;find row tile containing dc.X
move.w _TLV(a2,d3.w), d4
beq .rowdown
addi.w #18, d4
fltile cmp.w _RX(a2,d4.w), d0
bgt.s .fltiler
cmp.w _LX(a2,d4.w), d0
blt .rowdown
;can't land on pole etc
cmpi.w #$200, _TL(a2,d4.w)
bge.s .fltiler
;hit tile -> [land]
flhittl move.w _Y(a2,d3.w), d1
bra.s .land
;next tile
fltiler addi.w #18, d4
tst.w _LX(a2,d4.w)
beq .rowdown
bra .fltile
land move.w d1, _Y(a6)
move.w d4, _TLP(a6)
move.w d3, _RWP(a6)
;#F_DUEL (mace combat)?
cmpi.w #F_DUEL, _TL(a2,d4.w)
bne.s .land2
;D7/distance fallen = (Y-Yi)
duel move.w _VY0(a6), d7
neg.w d7
add.w d1, d7
;lethal fall? (> 80px)
cmpi.w #80, d7
bgt .lethal
duel2 tst.w _FACE(a6)
bgt.s .rduel
;land facing LEFT/RIGHT
lduel lea 2/lfall_ani, a3
bra.s .duel3
rduel lea 2/rfall_ani, a3
subi.w #12, d0
duel3 move.w d0, _X(a6)
move.l a3, _V0(a6)
jmp 7/proc312(a5)
land2 cmpi.w #2, _VFAL(a6)
bne.s .land3
;type #2/[after hitting wall]
wall move.w _VY0(a6), d7
neg.w d7
add.w d1, d7
cmpi.w #80, d7
bgt .lethal
;DIZZY, even when fall < 30px
wall2 tst.w _FACE(a6)
bgt.s .rwall
lwall lea 2/lfall_ani, a3
bra.s .wall3
rwall lea 2/rfall_ani, a3
subi.w #12, d0
;don't auto X_EXIT
wall3 cmpi.w #X_EXIT, _TL(a2,d4.w)
bne.s .wall4
;wall on right? -> (--tile)
rexit cmpi.w #W_, 18+_TL(a2,d4.w)
bne.s .lexit
subi.w #18, d4
move.w d4, _TLP(a6)
bra.s .wall4
; on left? (++tile)
lexit cmpi.w #W_, -18+_TL(a2,d4.w)
bne.s .wall4
addi.w #18, d4
move.w d4, _TLP(a6)
;lose 15% health -> DIZZY
wall4 move.w d0, _X(a6)
move.w #DIZZY, _ST(a6)
move.l a3, _VANI(a6)
subi.w #$f00, health(a5)
jmp 2/st_dizzy(pc)
;:1e42 2/com_29()
;swamp/forest ground? [die]
land3 cmpi.w #F_B212, _TL(a2,d4.w)
bne.s .land4
b212 clr.w health(a5)
move.w d4, d5
jsr 2/tl_dispatch(pc)
addi.w #10, d1
bra .bltfall
;#X_SFHS (false floor)?
land4 cmpi.w #X_SFHS, _TL(a2,d4.w)
bne.s .land5
sfhs cmpi.w #-200, _VY0(a6)
beq.s .dead
;alive -> <DUNJ>
sfhs2 move.w #SFHS, _ST(a6)
move.w #4, _V0(a6)
jmp com_34
;already dead
dead jsr 2/lose_life(pc)
tst.w lives(a5)
gamover blt .endfall
sf.b new_rm(a5)
bra .sfhs2
;land on (normal) tile!
land5 move.w _VY0(a6), d7
neg.w d7
add.w d1, d7
;squarely/fallen < 30px?
ble.s .fallok
cmpi.w #30, d7
blt.s .fallok
;lethal fall?
cmpi.w #80, d7
bgt.s .lethal
; -> [concussed], -15% health
dizzy move.w #DIZZY, _ST(a6)
lea 2/dfall_ani, a3
move.l a3, _VANI(a6)
subi.w #$f00, health(a5)
jmp 2/st_dizzy(pc)
;:1ebc 2/com_30()
;#6/death rattle
lethal push d0
move.w #SND_PLUMMET, d0
jsr 1/play_snd(a5)
pop d0
lea 2/fdie_ani, a3
clr.w health(a5)
jmp 2/st_death(pc)
;#4/'whoa!' sound
fallok push d0
move.w #SND_FALL, d0
jsr 1/play_snd(a5)
pop d0
; -> [tile landed on]
move.w d4, d5
jsr 2/tl_dispatch(pc)
jmp 2/st_dispatch(pc)
;:1eea 2/com_31()
;blit falling spr
bltfall move.w d4, _TLP(a6)
move.w d3, _RWP(a6)
move.w d1, _Y(a6)
subq #8, d1
movea.l currpg(a5), a0
movea.l _SPRV(a6), a4
blit2 tst.w _VFAL(a6)
bne.s .vspr
;type 0: #123/SPR_FALL <. >
fallspr movea.l 23*4(a4), a1
bra.s .blit3
;" 1/2: #198/SPR_ <. >
vspr move.w _FR(a6), d2
movea.l _VSPR(a6), a1
blit3 jsr 3/blit_spr(a5)
;already dead?
cmpi.w #-200, _VY0(a6)
beq.s .endfall
jmp 2/dg_dispatch(pc)
;:1f24 2/com_32()
endfall rts