Prev: 6745 Up: Map Next: 67D0
6765: Handle Pike And Tin Can
The handler for the pike and the tin can (IDs 1A to 1D), which are thrown out of a dustbin by the monster (see HandleMonster_Throwing). They fly in an arc; byte 04 of the actor is the horizontal speed, and byte 05 is the vertical speed, which is increased by one every 08 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 6765 CALL StoreEntity Record the position of the sprite using StoreEntity.
6768 LD HL,$5F1B Increase the number of actors in play (ActorsInPlay) by one.
676B INC (HL)
676C CALL TestCharlieCollision Test whether the actor has hit Charlie using TestCharlieCollision.
676F DEC E Has the actor hit Charlie (is E now zero)?
6770 JP Z,LoseHat Jump to LoseHat if Charlie has been hit.
6773 CALL TestFlourCollision Test whether a flour shot has hit the actor using TestFlourCollision.
6776 BIT 7,(IX+$00) Jump to HandleHitActor if the actor has been hit.
677A JP NZ,HandleHitActor
677D LD A,$44 Set the colour to 44.
677F LD (IX+$03),A Update the colour of the actor.
6782 LD A,(IX+$02) Fetch the vertical co-ordinate.
6785 CP $A0 Jump to HandleHitActor if the actor has reached the floor.
6787 JP NC,HandleHitActor
Every 08 frames, increase the vertical speed.
678A LD A,($5F1D) Fetch the frame counter.
678D AND %00000111 Keep only bits 0-2.
678F JR NZ,HandlePikeAndTinCan_Vertical Jump to HandlePikeAndTinCan_Vertical if the frame counter is not a multiple of 08.
6791 INC (IX+$05) Increase the vertical speed by one.
Move vertically.
HandlePikeAndTinCan_Vertical 6794 LD A,(IX+$05) Fetch the vertical speed.
6797 ADD A,(IX+$02) Add the vertical co-ordinate to get the new position.
679A CP $B8 Jump to HandlePikeAndTinCan_Remove if the actor has dropped below the bottom of the screen.
679C JR NC,HandlePikeAndTinCan_Remove
679E LD (IX+$02),A Update the vertical co-ordinate.
67A1 CP $24 Compare with 24 (the top of the play area).
67A3 CALL C,ReverseVerticalSpeed Call ReverseVerticalSpeed if the actor has reached the top of the play area.
Move horizontally.
67A6 LD A,(IX+$04) Fetch the horizontal speed.
67A9 AND A Is the actor moving left (is the speed negative)?
67AA JP M,HandlePikeAndTinCan_Left Jump to HandlePikeAndTinCan_Left if the actor is moving left.
67AD ADD A,(IX+$01) Add the horizontal co-ordinate to get the new position.
67B0 LD (IX+$01),A Update the horizontal co-ordinate.
67B3 CP $BC Compare with BC (the right edge of the play area).
67B5 CALL NC,ReverseHorizontalSpeed Call ReverseHorizontalSpeed if the actor has reached the right edge.
HandlePikeAndTinCan_Draw 67B8 CALL DisplayEntity Erase the sprite and draw it in its new position using DisplayEntity.
67BB JP ColourSprite Jump to ColourSprite to colour the sprite.
HandlePikeAndTinCan_Left 67BE ADD A,(IX+$01) Add the horizontal co-ordinate to get the new position.
67C1 LD (IX+$01),A Update the horizontal co-ordinate.
67C4 CP $04 Compare with 04 (the left edge of the play area).
67C6 CALL C,ReverseHorizontalSpeed Call ReverseHorizontalSpeed if the actor has reached the left edge.
67C9 JR HandlePikeAndTinCan_Draw Jump to HandlePikeAndTinCan_Draw.
The actor has dropped below the bottom of the screen.
HandlePikeAndTinCan_Remove 67CB LD (IX+$00),$00 Write 00 to the actor ID.
67CF RET Return.
Prev: 6745 Up: Map Next: 67D0