Prev: 26928 Up: Map Next: 27092
27030: Handle Tack, Washer And Bolt
The handler for the tack, the washer and the bolt (IDs 30 to 35), which chase Charlie. Every 16 frames the actor works out which way Charlie is from it, and stores this in byte 6 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 2 in either direction.
Input
IX Actor
HandleTackWasherBolt 27030 CALL StoreEntity Record the position of the sprite using StoreEntity.
27033 LD HL,24347 Point HL at ActorsInPlay.
27036 INC (HL) Increase the number of actors in play by one.
27037 CALL TestCharlieCollision Test whether the actor has hit Charlie using TestCharlieCollision.
27040 DEC E Has Charlie been hit (is E now zero)?
27041 JP Z,LoseHat Jump to LoseHat if Charlie has been hit.
27044 CALL TestFlourCollision Test whether a flour shot has hit the actor using TestFlourCollision.
27047 BIT 7,(IX+0) Jump to HandleHitActor if the actor has been hit.
27051 JP NZ,HandleHitActor
27054 LD (IX+3),69 Set the actor colour to 69 (cyan).
27058 LD A,(IX+7) Fetch the frame counter (byte 7 of the actor).
27061 AND %00001111 Keep only bits 0-3.
27063 JR NZ,ChangeActorSpeeds Jump to ChangeActorSpeeds if the counter is not a multiple of 16.
Work out which direction Charlie is in.
27065 LD C,0 Set the direction to 0 (left and up).
27067 LD HL,24374 Point HL at ActorCharlie_X.
27070 LD A,(IX+1) Fetch the horizontal co-ordinate.
27073 SUB (HL) Subtract Charlie's horizontal co-ordinate.
27074 JR NC,HandleTackWasherBolt_Vertical Jump to HandleTackWasherBolt_Vertical if the actor is to the right of Charlie.
27076 LD C,2 The actor is left of Charlie, so set the direction to 2 (right).
HandleTackWasherBolt_Vertical 27078 INC HL Move on to Charlie's vertical co-ordinate.
27079 LD A,(IX+2) Fetch the vertical co-ordinate.
27082 SUB (HL) Subtract Charlie's vertical co-ordinate.
27083 JR NC,HandleTackWasherBolt_SetDirection Jump to HandleTackWasherBolt_SetDirection if the actor is below Charlie.
27085 SET 0,C The actor is above Charlie, so set bit 0 of the direction (down).
HandleTackWasherBolt_SetDirection 27087 LD (IX+6),C Set the direction of the actor (byte 6 of the actor).
27090 JR ChangeActorSpeeds Jump to ChangeActorSpeeds.
Prev: 26928 Up: Map Next: 27092