Prev: 8C58 Up: Map Next: 8D1F
8CB2: Explode Player Ship
Used by the routine at UpdateEnemies.
Fills all nine enemy slots with the pieces of debris from the player's exploding ship: four pieces of type 15 followed by five pieces of type 1C.
ExplodePlayerShip 8CB2 LD IY,$C8E5 Use the player's object.
8CB6 LD BC,$0400 Set the piece counter and timer in BC.
8CB9 LD IX,$9974 Use the first enemy slot.
8CBD LD A,($C1A9) Fetch the scroll value from ShipHeight.
8CC0 SRL A Halve it.
8CC2 NEG Negate it.
8CC4 LD ($5C1D),A Store it in TileNumber.
ExplodePlayerShip_First 8CC7 PUSH BC Save the counters.
8CC8 CALL StartDebrisPiece Start a piece at the position of the player.
8CCB CALL StartExplosion Make the piece type 15.
8CCE LD (IX+$0D),$FF Make the attribute of the piece FF.
8CD2 POP BC Restore the counters.
8CD3 LD A,C Set the timer of the piece.
8CD4 LD (IX+$15),A
8CD7 ADD A,$40 Add 40 to the timer for the next piece.
8CD9 LD C,A
8CDA LD DE,$0018 Set the length of a slot.
8CDD ADD IX,DE Move on to the next slot.
8CDF DJNZ ExplodePlayerShip_First Decrease the piece counter by one and loop back to ExplodePlayerShip_First until none remain.
8CE1 LD BC,$0500 Set the counter for five more pieces.
ExplodePlayerShip_Second 8CE4 PUSH BC Save the counters.
8CE5 CALL StartDebrisPiece Start a piece at the position of the player.
8CE8 LD (IX+$00),$1C Make the piece type 1C.
8CEC LD (IX+$10),$06 Set the flags of the piece.
8CF0 LD (IX+$13),$50 Set the first state byte of the piece.
8CF4 LD (IX+$14),$02 Set the second state byte of the piece.
8CF8 LD (IX+$15),$40 Set the lifetime of the piece.
8CFC LD (IX+$0D),$EE Make the attribute of the piece EE.
8D00 POP BC Restore the counters.
8D01 LD A,C Fetch the timer.
8D02 LD HL,$8D1F Use the table of speeds at DebrisSpeeds.
8D05 CALL AddAToHL Add the offset to the address.
8D08 LD A,(HL) Set the horizontal speed of the piece from the table.
8D09 LD (IX+$07),A
8D0C INC HL Fetch the next byte of the table.
8D0D LD A,(HL) Set the vertical speed of the piece from the table.
8D0E LD (IX+$09),A
8D11 INC C Move on to the next pair of speeds.
8D12 INC C
8D13 LD (IX+$0F),$20 Set the vertical acceleration of the piece.
8D17 LD DE,$0018 Set the length of a slot.
8D1A ADD IX,DE Move on to the next slot.
8D1C DJNZ ExplodePlayerShip_Second Decrease the piece counter by one and loop back to ExplodePlayerShip_Second until none remain.
8D1E RET Return.
Prev: 8C58 Up: Map Next: 8D1F