/[projet1]/users/twilighte/Stormlord/HeroFire.s
Defence Force logotype

Contents of /users/twilighte/Stormlord/HeroFire.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 412 - (show annotations)
Thu Oct 7 20:50:23 2010 UTC (8 years, 8 months ago) by dbug
File size: 5951 byte(s)
Added Stormlord
1 ;HeroFire.s
2
3 ;If Fire released within timer then shoot quick burst arcing orbs otherwise shoot sword.
4 ;orbs have killing power of 1 but many may be shot at a time(8).
5 ;Swords have killing power of 10 but take more time to fire.
6
7 ;Both sword and orb end life on contact with obstruction in collision map
8
9 ;The course and graphic of the projectile is all that is required in setting it up
10 ProjectileType_XStep
11 .byt 1 ;Orb
12 .byt 1 ;Sword
13 .byt 0 ;Heart
14 ProjectileType_YStep
15 .byt 252 ;Orb
16 .byt 0 ;Sword
17 .byt 254 ;Heart
18 ProjectileType_GFXID
19 .byt 28 ;Orb
20 .byt 29 ;Sword
21 .byt 31 ;Heart
22
23
24 SpawnOrb
25 ; nop
26 ; jmp SpawnOrb
27 lda #SFX_FIREORB
28 jsr KickSFX
29 ;Don't allow hero to fire if too near boundaries
30 jsr PerformProjectileCommonChecks
31 .(
32 bcs skip2
33 lda HeroFrame
34 cmp #8
35 bcs ProjectileLeft
36 ProjectileRight
37 lda HeroX
38 adc #2
39 sta prj_X,x
40 lda #1
41 sta prj_XStep,x
42 jmp skip1
43 ProjectileLeft
44 lda HeroX
45 sbc #1
46 sta prj_X,x
47 lda #255
48 sta prj_XStep,x
49
50 skip1 lda HeroY
51 adc #12
52 sta prj_Y,x
53 lda #252
54 sta prj_YStep,x
55 lda #GFXF_ORB
56 sta prj_GFXID,x
57 skip2 rts
58 .)
59
60
61 SpawnSword
62 ;Don't allow hero to fire if too near boundaries
63 jsr PerformProjectileCommonChecks
64 .(
65 bcs skip2
66 lda HeroFrame
67 cmp #8
68 bcs ProjectileLeft
69 ProjectileRight
70 lda HeroX
71 adc #2
72 sta prj_X,x
73 lda #1
74 sta prj_XStep,x
75 lda #GFXF_SWORDRIGHT
76 sta prj_GFXID,x
77 jmp skip1
78 ProjectileLeft
79 lda HeroX
80 sbc #2
81 sta prj_X,x
82 lda #255
83 sta prj_XStep,x
84 lda #GFXF_SWORDLEFT
85 sta prj_GFXID,x
86
87 skip1 lda HeroY
88 adc #12
89 sta prj_Y,x
90 lda #0
91 sta prj_YStep,x
92 skip2 rts
93 .)
94
95 SpawnHeart
96 ;Don't allow hero to fire if too near boundaries
97 jsr PerformProjectileCommonChecks
98 .(
99 bcs skip2
100 lda HeroX
101 adc #1
102 sta prj_X,x
103 lda #0
104 sta prj_XStep,x
105 lda HeroY
106 sec
107 sbc #5
108 sta prj_Y,x
109 lda #250
110 sta prj_YStep,x
111 lda #GFXF_HEART
112 sta prj_GFXID,x
113 skip2 rts
114 .)
115
116
117 PerformProjectileCommonChecks
118 lda HeroX
119 cmp #3
120 .(
121 bcc skip1
122 cmp #34
123 bcs skip2
124
125 jsr FetchNewProjectileIndex
126 skip2 rts
127 skip1 sec
128 .)
129 rts
130
131 FetchNewProjectileIndex
132 lda UltimateProjectile
133 .(
134 bmi skip2
135 cmp #7
136 bcs skip1
137 skip2 inc UltimateProjectile
138 ldx UltimateProjectile
139 skip1 rts
140 .)
141
142 FireEngine
143 ldx UltimateProjectile
144 .(
145 bmi skip1
146
147 loop1 ;Delete Projectile from screen
148 jsr DeleteProjectile
149
150 ;If Orb gradually increase fall
151 lda prj_GFXID,x
152 cmp #28
153 bne skip2
154 inc prj_YStep,x
155
156 skip2 ;Move projectile
157 lda prj_Y,x
158 clc
159 adc prj_YStep,x
160 ora #1 ;and #$FE
161 sta prj_Y,x
162 tay
163 lda prj_X,x
164 clc
165 adc prj_XStep,x
166 sta prj_X,x
167
168 ;Check boundaries
169 cmp #1
170 bcc DestroyProjectile
171 cmp #38
172 bcs DestroyProjectile
173 cpy #30
174 bcc DestroyProjectile
175 cpy #124
176 bcs DestroyProjectile
177
178 ;Check collisions
179 jsr CheckFireCollision
180 bcc skip3
181 jsr HitNPC
182
183 skip3 ;Plot Projectile
184 jsr PlotProjectile
185
186 dex
187 bpl loop1
188 skip1 rts
189 .)
190
191 DestroyProjectile
192 ;Avoid having to set everything if already the same index
193 cpx UltimateProjectile
194 .(
195 beq skip1
196 ;Copy last projectile to current
197 ldy UltimateProjectile
198 lda prj_X,y
199 sta prj_X,x
200 lda prj_Y,y
201 sta prj_Y,x
202 lda prj_XStep,y
203 sta prj_XStep,x
204 lda prj_YStep,y
205 sta prj_YStep,x
206 lda prj_GFXID,y
207 sta prj_GFXID,x
208 ;Then remove last one
209 skip1 dec UltimateProjectile
210 .)
211 rts
212
213 HitNPC ;NPC Index held in Y
214 .(
215 stx vector1+1
216 ;Check that NPC is not already being destroyed
217 ldx NPC_Activity,y
218 cpx #NPCA_EXPLODE
219 beq vector1
220
221 ;Cannot destroy raindrops, Bees or Fairies
222 cpx #NPCA_BEE
223 beq vector1
224 cpx #NPCA_RAINDROP
225 beq vector1
226 cpx #NPCA_FAIRY
227 beq MakeFairyShedATear
228
229 ldx NPC_Activity,y
230 lda NPC_ExplosionsNeeded,x
231 sta NPC_Count,y
232 lda NPC_SpriteFrame4Activity,x
233 sta NPC_SpriteFrame,y
234 lda #NPCA_EXPLODE
235 sta NPC_Activity,y
236 lda #NPCF_EXPLOSION
237 sta NPC_Progress,y
238 lda NPC_ScreenX,y
239 sta NPC_ScreenXOrigin,y
240 lda NPC_ScreenY,y
241 sta NPC_ScreenYOrigin,y
242
243 ;Wipe B4-7 of collision map(720) - Next frame will restore living NPC's
244 ldx #240
245 loop1 lda CollisionMap-1,x
246 and #15
247 sta CollisionMap-1,x
248 lda CollisionMap+239,x
249 and #15
250 sta CollisionMap+239,x
251 lda CollisionMap+479,x
252 and #15
253 sta CollisionMap+479,x
254 dex
255 bne loop1
256
257 ;Add score
258 lda #$50
259 jsr AddScore
260 jsr DisplayScore
261
262 ;Kick Explosion SFX
263 lda #SFX_EXPLOSION
264 jsr KickSFX
265
266 vector1 ldx #00
267 rts
268
269 MakeFairyShedATear
270 ;Kill the Kiss
271 sty vector2+1
272 ldx vector1+1
273 jsr DestroyProjectile
274 vector2 ldx #00
275
276 ;Spawn a Tear
277 jsr FetchNewNPCIndex
278 bcs skip1
279 lda NPC_ScreenX,x
280 sta NPC_ScreenX,y
281 lda NPC_ScreenY,x
282 sta NPC_ScreenY,y
283 ;Starting at offset 7 in sine table means we'll move up 6,4,2 before down. and abs min fairy is 42
284 lda #0
285 sta NPC_Progress,y
286 lda #7
287 sta NPC_Special,y ;Used in controlling arc of tear and after - for period of remaining on ground
288 lda #NPCA_THROWNTEAR
289 sta NPC_Activity,y
290 skip1 jmp vector1
291 .)
292
293 NPC_ExplosionsNeeded
294 .byt 1 ;NPCA_BALLRISING 0
295 .byt 1 ;NPCA_BALLBOUNCE 1
296 .byt 1 ;NPCA_BALLPAUSE 2
297 .byt 2 ;NPCA_GRUBPEEP 3
298 .byt 2 ;NPCA_GRUBMOVE 4
299 .byt 1 ;NPCA_RAINDROP 5
300 .byt 2 ;NPCA_EGGWASP 6
301 .byt 2 ;NPCA_DRAGONLEFT 7
302 .byt 2 ;NPCA_DRAGONRIGHT 8
303 .byt 1 ;NPCA_BEE 9
304 .byt 1 ;NPCA_EXPLODE 10
305 .byt 1 ;NPCA_SPIDER 11
306
307
308
309 CheckFireCollision
310 lda prj_X,x
311 ldy prj_Y,x
312 clc
313 adc CollisionMapYLOCL-30,y
314 .(
315 sta vector1+1
316 lda CollisionMapYLOCH-30,y
317 adc #00
318 sta vector1+2
319 vector1 lda $dead
320 and #$F0
321 beq skip1
322 ; 00 Background
323 ; 01-0C NPC Index
324 cmp #$D0
325 bcs skip2
326 ;Place NPC Index in Y
327 lsr
328 lsr
329 lsr
330 lsr
331 tay
332 dey
333
334 sec
335 skip1 rts
336 skip2 clc
337 rts
338 .)
339
340 DeleteProjectile
341 lda prj_GFXID,x
342 sta SpriteFrame
343 lda prj_X,x
344 ldy prj_Y,x
345 jsr RecalcScreen
346 lda prj_X,x
347 ldy prj_Y,x
348 stx rsbg_RestorationOfX+1
349 jmp RestoreSpriteBG2
350
351 PlotProjectile
352 lda prj_GFXID,x
353 sta SpriteFrame
354 lda prj_X,x
355 ldy prj_Y,x
356 jsr RecalcScreen
357 jmp PlotSpriteWithMask

  ViewVC Help
Powered by ViewVC 1.1.26