-
Notifications
You must be signed in to change notification settings - Fork 2
/
2-aim_kugel.asm
220 lines (204 loc) · 4.4 KB
/
2-aim_kugel.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
; vi: syntax=asm68k
;:34b2 2/proc138()
;Aim/throw rock or fireball + arm
; arg D0: (coord_t) dc X
; D1: (coord_t) dc Y
aim_kugel:
movem.l d0-d7/a0-a4,-(sp)
movea.l currpg(a5), a0
movea.l _SPRV(a6), a4
clr.w d7
;branch by st #AIM,HID,THW,THI
move.w _KGST(a6), d2
asl.w 2, d2
jmp aimjt(d2.w)
aimjt: ;:34ca
jmp .staim
jmp .sthid
jmp .stthw
jmp .stthi
;:34da dc->kgst(#HID) #1
sthid move.w _TRJ(a6), d2
cmp.w _TRJ0(a6), d2
bne.s .showarm
btst.b #MOU, _JOY(a6)
bne.s .showarm
;traj unchanged/no click [.7]
hid2 move.w #7, d2
bra .blitaim
;arm moved OR click -> #AIM
showarm move.w #25, _AIMC(a6)
clr.w _KGST(a6)
nop
;3500 c->kgst(#AIM) #0
staim move.w _TRJ(a6), d2
cmp.w _TRJ0(a6), d2
beq.s .aim2
;new trajectory (9 bits wide)
dtrj move.w #25, _AIMC(a6)
move.w d2, _TRJ0(a6)
aim2 subq.w #1, _KGC(a6)
bge.s .aim3
;(--kgc < 0) throw timeout
kgtmout clr.w _KGC(a6)
btst.b #MOU, _JOY(a6)
beq.s .aim3
;(mouse click) = throw kugel
kgstart move.w #25, _AIMC(a6)
move.w #4, _KGC(a6)
move.w #8, d2
move.w #16, d7
;low (< 192°)/high throw?
startlo move.w #THW, _KGST(a6)
cmpi.w #192, _TRJ(a6)
bgt .blitaim
starthi move.w #THI, _KGST(a6)
bra .blitaim
;:3554
;(kgc >= 0) || no click
aim3 asr.w 6, d2
subq.w #1, _AIMC(a6)
bgt .blitaim
;aim timeout -> hide arm
aimout move.w #HID, _KGST(a6)
bra .blitaim
;:3568 dc->kgst(#THW) #2
stthw move.w #9, d2
bra.s .throw
;:356e dc->kgst(#THI) #3
stthi move.w #10, d2
;next state #AIM
throw clr.w _KGST(a6)
tst.w _FACE(a6)
blt.s .lthrow
;SPR_RARM <.11>/#112 (-12,-6)
rthrow movea.l 12*4(a4), a1
lea rtraj_xy(pc), a2
subq.w #6, d1
addq.w #4, d0
subi.w #16, d0
bra.s .blthrow
;SPR_LARM <.11>/#111 (+2,-6)
lthrow movea.l 11*4(a4), a1
lea ltraj_xy(pc), a2
subq.w #6, d1
subi.w #14, d0
addi.w #16, d0
;blit throwing arm [.9|.10]
blthrow jsr 3/blit_spr(a5)
throw2 btst.b #FB, _FLG(a6)
bne.s .thwfb
;SPR_ROCK <.4>/#113, 16x8px
thwrock movea.l 13*4(a4), a0
tst.b rocks(a5)
beq.s .throw3
;rocks remain -> 'nyah' sound
move.w d0, -(sp)
move.w #7, d0
jsr 1/play_snd(a5)
move.w (sp)+, d0
bra.s .throw3
;SPR_FIREBALL <.2>/#138, 16x9px
thwfb movea.l 38*4(a4), a0
tst.b rocks(a5)
beq.s .throw3
move.w d0, -(sp)
move.w #9, d0
jsr 1/play_snd(a5)
move.w (sp)+, d0
;traj -> <lr>traj_xy[] index
throw3 lea kghead(a5), a1
move.w _TRJ(a6), d2
asr.w 6, d2
asl.w 1, d2
adda.w d2, a2
;get ∆x,∆y (struct ani2v_t[8])
getdx move.b (a2)+, d2
ext.w d2
add.w d2, d0
getdy move.b (a2), d3
ext.w d3
add.w d3, d1
;compute kugel velocity
;∆y = traj - 300. [-300,+212]
kgveloc move.w _TRJ(a6), d3
move.w #300, d2
subi.w #300, d3
bmi.s .negdy
;{∆y≥0} ∆x = 600-traj [300,88]
posdy sub.w d3, d2
bra.s .veloc2
;{∆y<0} ∆x = traj [0,299]
negdy add.w d3, d2
;make long, >>= 3
veloc2 ext.l d2
ext.l d3
moveq #13, d5
asl.l d5, d2
asl.l d5, d3
tst.w _FACE(a6)
bge.s .rveloc
;facing LEFT: -∆x (RIGHT: +∆x)
lveloc neg.l d2
rveloc cmpi.w #B212, _ST(a6)
bne.s .veloc3
cmpi.w #(3*4), _VFN(a6)
bne.s .veloc3
;state(B212):fn(3) -> in chopper
b212dx move.w _V2(a6), d4
add.w d4, d0
swap d4
clr.w d4
add.l d4, d2
;gravity accl (x1/$10000px/fr²)
veloc3 move.l #$0000d555, d4
tst.b rocks(a5)
beq.s .endaim
;--rocks remain (bcd_t)
decrock move.b rocks(a5), d7
move.b #1, d6
andi.b #%00000111, ccr
sbcd.b d6, d7
move.b d7, rocks(a5)
move.w #2, rocklen(a5)
;create new kugel
jsr 2/mk_kugel(pc)
bra .endaim
blitaim tst.w _FACE(a6)
blt.s .lbltaim
;SPR_RARM <.11>/#112 (+4[-16],-6)
rbltaim movea.l 12*4(a4), a1
subq.w #6, d1
addq.w #4, d0
sub.w d7, d0
bra.s .bltaim2
;SPR_LARM <.11>/#111 (-14[+16],-6)
lbltaim movea.l 11*4(a4), a1
subq.w #6, d1
subi.w #14, d0
add.w d7, d0
;blit throwing arm (32x32px)
bltaim2 jsr 3/blit_spr(a5)
endaim movem.l (sp)+, d0-d7/a0-a4
rts
;:368a
rtraj_xy:
dc.b +16, +3
dc.b +16, +3
dc.b +16, +3
dc.b +16, +3
dc.b +19, +19
dc.b +19, +19
dc.b +19, +19
dc.b +19, +19
dc.b +19, +19
;:369c
ltraj_xy:
dc.b +11, +4
dc.b +11, +4
dc.b +11, +4
dc.b +11, +4
dc.b +12, +19
dc.b +12, +19
dc.b +12, +19
dc.b +12, +19