Prev: 6930 Up: Map Next: 69D4
6996: Handle Tack, Washer And Bolt
The handler for the tack, the washer and the bolt (IDs 1E to 23), which chase Charlie. Every 10 frames the actor works out which way Charlie is from it, and stores this in byte 06 of the actor (bit 0 is set when Charlie is below the actor, bit 1 is set when Charlie is to the right). The horizontal and vertical speeds are then changed by one every other frame towards that direction, up to a maximum speed of 02 in either direction.
Input
IX Actor
HandleTackWasherBolt 6996 CALL StoreEntity Record the position of the sprite using StoreEntity.
6999 LD HL,$5F1B Point HL at ActorsInPlay.
699C INC (HL) Increase the number of actors in play by one.
699D CALL TestCharlieCollision Test whether the actor has hit Charlie using TestCharlieCollision.
69A0 DEC E Has Charlie been hit (is E now zero)?
69A1 JP Z,LoseHat Jump to LoseHat if Charlie has been hit.
69A4 CALL TestFlourCollision Test whether a flour shot has hit the actor using TestFlourCollision.
69A7 BIT 7,(IX+$00) Jump to HandleHitActor if the actor has been hit.
69AB JP NZ,HandleHitActor
69AE LD (IX+$03),$45 Set the actor colour to 45 (cyan).
69B2 LD A,(IX+$07) Fetch the frame counter (byte 07 of the actor).
69B5 AND %00001111 Keep only bits 0-3.
69B7 JR NZ,ChangeActorSpeeds Jump to ChangeActorSpeeds if the counter is not a multiple of 10.
Work out which direction Charlie is in.
69B9 LD C,$00 Set the direction to 00 (left and up).
69BB LD HL,$5F36 Point HL at ActorCharlie_X.
69BE LD A,(IX+$01) Fetch the horizontal co-ordinate.
69C1 SUB (HL) Subtract Charlie's horizontal co-ordinate.
69C2 JR NC,HandleTackWasherBolt_Vertical Jump to HandleTackWasherBolt_Vertical if the actor is to the right of Charlie.
69C4 LD C,$02 The actor is left of Charlie, so set the direction to 02 (right).
HandleTackWasherBolt_Vertical 69C6 INC HL Move on to Charlie's vertical co-ordinate.
69C7 LD A,(IX+$02) Fetch the vertical co-ordinate.
69CA SUB (HL) Subtract Charlie's vertical co-ordinate.
69CB JR NC,HandleTackWasherBolt_SetDirection Jump to HandleTackWasherBolt_SetDirection if the actor is below Charlie.
69CD SET 0,C The actor is above Charlie, so set bit 0 of the direction (down).
HandleTackWasherBolt_SetDirection 69CF LD (IX+$06),C Set the direction of the actor (byte 06 of the actor).
69D2 JR ChangeActorSpeeds Jump to ChangeActorSpeeds.
Prev: 6930 Up: Map Next: 69D4