Prev: 6996 Up: Map Next: 6A05
69D4: Handle Chocolate
The handler for the chocolate (IDs 10 and 11), which drifts about in random directions. Every 10 frames a new random direction is picked and stored in byte 06 of the actor (bit 0 is set for down, and bit 1 is set for right). The speeds are changed by one every other frame towards that direction, up to a maximum speed of 02 in either direction.
While the chocolate is still entering from the right of the screen (a horizontal co-ordinate of C4 or more) it is only moved.
Input
IX Actor
HandleChocolate 69D4 CALL StoreEntity Record the position of the sprite using StoreEntity.
69D7 LD HL,$5F1B Point HL at ActorsInPlay.
69DA INC (HL) Increase the number of actors in play by one.
69DB LD A,(IX+$01) Fetch the horizontal co-ordinate.
69DE CP $C4 Jump to ChangeActorSpeeds_Move if the chocolate is still entering from the right.
69E0 JR NC,ChangeActorSpeeds_Move
69E2 CALL TestCharlieCollision Test whether the actor has hit Charlie using TestCharlieCollision.
69E5 DEC E Has Charlie been hit (is E now zero)?
69E6 JP Z,LoseHat Jump to LoseHat if Charlie has been hit.
69E9 CALL TestFlourCollision Test whether a flour shot has hit the actor using TestFlourCollision.
69EC BIT 7,(IX+$00) Jump to HandleHitActor if the actor has been hit.
69F0 JP NZ,HandleHitActor
69F3 LD (IX+$03),$42 Set the actor colour to 42 (red).
69F7 LD A,(IX+$07) Fetch the frame counter (byte 07 of the actor).
69FA AND %00001111 Keep only bits 0-3.
69FC JR NZ,ChangeActorSpeeds Jump to ChangeActorSpeeds if the counter is not a multiple of 10.
69FE LD A,R Fetch a random number.
6A00 AND %00000011 Keep only bits 0-1.
6A02 LD (IX+$06),A Set a random direction (byte 06 of the actor).
Prev: 6996 Up: Map Next: 6A05