Prev: 58306 Up: Map Next: 58479
58336: Handler: Explosion
Used by the routine at InitialiseGame.
Handler_Explosion 58336 LD A,(62171) Return if *TableBombSparks has no active sparks.
58339 CP 0
58341 RET Z
58342 LD IX,62171 Point IX at TableBombSparks.
58346 LD HL,61787 Write 61787 to *CHARS.
58349 LD (23606),HL
58352 LD A,16 Set INK: WHITE (7).
58354 RST 16
58355 LD A,7
58357 RST 16
58358 LD B,5 B=5 (five sparks).
Handler_Explosion_Loop 58360 PUSH BC Stash the sparks counter on the stack.
58361 LD B,(IX+1) B=this spark's vertical co-ordinate.
58364 LD DE,257 Set the spark width/ height to 1/ 1.
58367 LD C,(IX+0) C=this spark's horizontal co-ordinate.
58370 LD A,C Jump to Handler_Explosion_AddVelocity if the spark is off the right.
58371 CP 34
58373 JR NC,Handler_Explosion_AddVelocity
58375 CP 2 Jump to Handler_Explosion_AddVelocity if the spark is off the left.
58377 JR C,Handler_Explosion_AddVelocity
58379 PUSH BC Stash the spark position and size on the stack.
58380 PUSH DE
58381 CALL PrintSpriteUpdateBuffer Erase the spark's previous tile.
58384 POP DE Restore the spark position and size from the stack.
58385 POP BC
Handler_Explosion_AddVelocity 58386 LD A,(IX+3) Add the spark's vertical velocity.
58389 ADD A,B
58390 LD B,A
58391 LD A,(IX+2) Add the spark's horizontal velocity.
58394 ADD A,C
58395 LD C,A
58396 INC (IX+5) Advance this spark's timer.
58399 LD A,(IX+5) Jump to Handler_Explosion_Housekeep if this spark has finished.
58402 CP 4
58404 JR Z,Handler_Explosion_Housekeep
58406 LD A,C Jump to Handler_Explosion_Next if the new column is off the right.
58407 CP 34
58409 JR NC,Handler_Explosion_Next
58411 CP 2 Jump to Handler_Explosion_Next if the new column is off the left.
58413 JR C,Handler_Explosion_Next
58415 LD (IX+0),C Write the new horizontal co-ordinate back to the spark.
58418 LD (IX+1),B Write the new vertical co-ordinate back to the spark.
58421 LD DE,257 Set the spark width/ height to 1/ 1.
58424 LD A,32 A=the spark sprite ID.
58426 CALL PrintSprite Print the spark.
58429 LD B,(IX+1) B=the spark vertical co-ordinate.
58432 LD A,(62002) A=*PlayerVerticalCoordinate.
58435 SUB B Subtract the spark vertical.
58436 CP 2 Jump to Handler_Explosion_Next if the player is outside this spark's vertical span.
58438 JR NC,Handler_Explosion_Next
58440 LD C,(IX+0) C=the spark horizontal co-ordinate.
58443 LD A,(62001) A=*TablePlayerAttributes.
58446 SUB C Subtract the spark horizontal.
58447 CP 2 Jump to Handler_Explosion_Next if the player is outside this spark's horizontal span.
58449 JR NC,Handler_Explosion_Next
58451 LD A,3 Queue the bomb-explosion sound at SoundFlag_General.
58453 LD (65534),A
58456 JP HousekeepStackThenLoseLife Jump to HousekeepStackThenLoseLife to lose a life.
Handler_Explosion_Next 58459 LD DE,6 Move IX on to the next six-byte spark entry.
58462 ADD IX,DE
58464 POP BC Restore the sparks counter from the stack.
58465 DJNZ Handler_Explosion_Loop Decrease the sparks counter by one and loop back to Handler_Explosion_Loop until every spark has been processed.
58467 RET Return.
This spark has run its course, remove it.
Handler_Explosion_Housekeep 58468 LD (IX+0),0 Clear this spark's horizontal co-ordinate.
58472 LD A,0 Clear the bomb sound at SoundFlag_Bomb.
58474 LD (65533),A
58477 JR Handler_Explosion_Next Jump to Handler_Explosion_Next.
Prev: 58306 Up: Map Next: 58479