Prev: 26437 Up: Map Next: 26576
26469: Handle Pike And Tin Can
The handler for the pike and the tin can (IDs 26 to 29), which are thrown out of a dustbin by the monster (see HandleMonster_Throwing). They fly in an arc; byte 4 of the actor is the horizontal speed, and byte 5 is the vertical speed, which is increased by one every 8 frames to make them fall. They bounce off the sides and the top of the play area, and are removed when they drop below the bottom of the screen. When they reach the floor they are handled in the same way as an actor which has been hit (see MoveHitActor).
Input
IX Actor
HandlePikeAndTinCan 26469 CALL StoreEntity Record the position of the sprite using StoreEntity.
26472 LD HL,24347 Increase the number of actors in play (ActorsInPlay) by one.
26475 INC (HL)
26476 CALL TestCharlieCollision Test whether the actor has hit Charlie using TestCharlieCollision.
26479 DEC E Has the actor hit Charlie (is E now zero)?
26480 JP Z,LoseHat Jump to LoseHat if Charlie has been hit.
26483 CALL TestFlourCollision Test whether a flour shot has hit the actor using TestFlourCollision.
26486 BIT 7,(IX+0) Jump to HandleHitActor if the actor has been hit.
26490 JP NZ,HandleHitActor
26493 LD A,68 Set the colour to 68.
26495 LD (IX+3),A Update the colour of the actor.
26498 LD A,(IX+2) Fetch the vertical co-ordinate.
26501 CP 160 Jump to HandleHitActor if the actor has reached the floor.
26503 JP NC,HandleHitActor
Every 8 frames, increase the vertical speed.
26506 LD A,(24349) Fetch the frame counter.
26509 AND %00000111 Keep only bits 0-2.
26511 JR NZ,HandlePikeAndTinCan_Vertical Jump to HandlePikeAndTinCan_Vertical if the frame counter is not a multiple of 8.
26513 INC (IX+5) Increase the vertical speed by one.
Move vertically.
HandlePikeAndTinCan_Vertical 26516 LD A,(IX+5) Fetch the vertical speed.
26519 ADD A,(IX+2) Add the vertical co-ordinate to get the new position.
26522 CP 184 Jump to HandlePikeAndTinCan_Remove if the actor has dropped below the bottom of the screen.
26524 JR NC,HandlePikeAndTinCan_Remove
26526 LD (IX+2),A Update the vertical co-ordinate.
26529 CP 36 Compare with 36 (the top of the play area).
26531 CALL C,ReverseVerticalSpeed Call ReverseVerticalSpeed if the actor has reached the top of the play area.
Move horizontally.
26534 LD A,(IX+4) Fetch the horizontal speed.
26537 AND A Is the actor moving left (is the speed negative)?
26538 JP M,HandlePikeAndTinCan_Left Jump to HandlePikeAndTinCan_Left if the actor is moving left.
26541 ADD A,(IX+1) Add the horizontal co-ordinate to get the new position.
26544 LD (IX+1),A Update the horizontal co-ordinate.
26547 CP 188 Compare with 188 (the right edge of the play area).
26549 CALL NC,ReverseHorizontalSpeed Call ReverseHorizontalSpeed if the actor has reached the right edge.
HandlePikeAndTinCan_Draw 26552 CALL DisplayEntity Erase the sprite and draw it in its new position using DisplayEntity.
26555 JP ColourSprite Jump to ColourSprite to colour the sprite.
HandlePikeAndTinCan_Left 26558 ADD A,(IX+1) Add the horizontal co-ordinate to get the new position.
26561 LD (IX+1),A Update the horizontal co-ordinate.
26564 CP 4 Compare with 4 (the left edge of the play area).
26566 CALL C,ReverseHorizontalSpeed Call ReverseHorizontalSpeed if the actor has reached the left edge.
26569 JR HandlePikeAndTinCan_Draw Jump to HandlePikeAndTinCan_Draw.
The actor has dropped below the bottom of the screen.
HandlePikeAndTinCan_Remove 26571 LD (IX+0),0 Write 0 to the actor ID.
26575 RET Return.
Prev: 26437 Up: Map Next: 26576