Prev: E3C2 Up: Map Next: E46F
E3E0: Handler: Explosion
Used by the routine at InitialiseGame.
Handler_Explosion E3E0 LD A,($F2DB) Return if *TableBombSparks has no active sparks.
E3E3 CP $00
E3E5 RET Z
E3E6 LD IX,$F2DB Point IX at TableBombSparks.
E3EA LD HL,$F15B Write F15B to *CHARS.
E3ED LD ($5C36),HL
E3F0 LD A,$10 Set INK: WHITE (07).
E3F2 RST $10
E3F3 LD A,$07
E3F5 RST $10
E3F6 LD B,$05 B=05 (five sparks).
Handler_Explosion_Loop E3F8 PUSH BC Stash the sparks counter on the stack.
E3F9 LD B,(IX+$01) B=this spark's vertical co-ordinate.
E3FC LD DE,$0101 Set the spark width/ height to 01/ 01.
E3FF LD C,(IX+$00) C=this spark's horizontal co-ordinate.
E402 LD A,C Jump to Handler_Explosion_0 if the spark is off the right.
E403 CP $22
E405 JR NC,Handler_Explosion_0
E407 CP $02 Jump to Handler_Explosion_0 if the spark is off the left.
E409 JR C,Handler_Explosion_0
E40B PUSH BC Stash the spark position and size on the stack.
E40C PUSH DE
E40D CALL PrintSpriteUpdateBuffer Erase the spark's previous tile.
E410 POP DE Restore the spark position and size from the stack.
E411 POP BC
Handler_Explosion_0 E412 LD A,(IX+$03) Add the spark's vertical velocity.
E415 ADD A,B
E416 LD B,A
E417 LD A,(IX+$02) Add the spark's horizontal velocity.
E41A ADD A,C
E41B LD C,A
E41C INC (IX+$05) Advance this spark's timer.
E41F LD A,(IX+$05) Jump to Handler_Explosion_Housekeep if this spark has finished.
E422 CP $04
E424 JR Z,Handler_Explosion_Housekeep
E426 LD A,C Jump to Handler_Explosion_Next if the new column is off the right.
E427 CP $22
E429 JR NC,Handler_Explosion_Next
E42B CP $02 Jump to Handler_Explosion_Next if the new column is off the left.
E42D JR C,Handler_Explosion_Next
E42F LD (IX+$00),C Write the new horizontal co-ordinate back to the spark.
E432 LD (IX+$01),B Write the new vertical co-ordinate back to the spark.
E435 LD DE,$0101 Set the spark width/ height to 01/ 01.
E438 LD A,$20 A=the spark sprite ID.
E43A CALL PrintSprite Print the spark.
E43D LD B,(IX+$01) B=the spark vertical co-ordinate.
E440 LD A,($F232) A=*F232.
E443 SUB B Subtract the spark vertical.
E444 CP $02 Jump to Handler_Explosion_Next if the player is outside this spark's vertical span.
E446 JR NC,Handler_Explosion_Next
E448 LD C,(IX+$00) C=the spark horizontal co-ordinate.
E44B LD A,($F231) A=*TablePlayerAttributes.
E44E SUB C Subtract the spark horizontal.
E44F CP $02 Jump to Handler_Explosion_Next if the player is outside this spark's horizontal span.
E451 JR NC,Handler_Explosion_Next
E453 LD A,$03 Queue the bomb-explosion sound at SoundFlag_General.
E455 LD ($FFFE),A
E458 JP HousekeepStackThenLoseLife Jump to HousekeepStackThenLoseLife to lose a life.
Handler_Explosion_Next E45B LD DE,$0006 Move IX on to the next six-byte spark entry.
E45E ADD IX,DE
E460 POP BC Restore the sparks counter from the stack.
E461 DJNZ Handler_Explosion_Loop Decrease the sparks counter by one and loop back to Handler_Explosion_Loop until every spark has been processed.
E463 RET Return.
This spark has run its course, remove it.
Handler_Explosion_Housekeep E464 LD (IX+$00),$00 Clear this spark's horizontal co-ordinate.
E468 LD A,$00 Clear the bomb sound at SoundFlag_Bomb.
E46A LD ($FFFD),A
E46D JR Handler_Explosion_Next Jump to Handler_Explosion_Next.
Prev: E3C2 Up: Map Next: E46F