Prev: 9E64 Up: Map Next: 9EB3
9E72: Handler: Hippo And Warthog
Handles a hippo (sprite IDs A0-A3) or a warthog (sprite IDs A8-AB) which is awake. The animal walks along (see MoveActor), animating as it goes, and stays in the same direction until it is blocked by something in the room, at which point it falls asleep (bit 2 of the sprite ID is set, see HandlerSleepingHippoWarthog). If the animal has bumped into the player then it stands still for a short while (the counter in *IX+02 is counted down) and, if the player is hurt, the player is hit.
Input
IX Actor record
HandlerHippoWarthog 9E72 CALL StoreEntity Remember the previous position of the animal.
9E75 CALL AnimateRhino Animate the animal.
9E78 LD A,$20 Write 20 to Actor_Width (the width of the animal).
9E7A LD ($96AD),A
Stand still while the pause counter is running.
9E7D LD A,(IX+$02) Fetch the pause counter of the animal.
9E80 AND A Jump to HandlerHippoWarthog_Pause if the animal is still paused.
9E81 JR NZ,HandlerHippoWarthog_Pause
Work out the new position of the animal and stop it walking through objects in the room.
9E83 CALL MoveActor Move the animal.
9E86 LD BC,$171F Set the height of the animal in B to 17 and the width in C to 1F.
9E89 CALL SlideActorPastObjects Stop the animal passing through objects in the room.
Carry on if the animal moved. If it is stuck then put it to sleep.
9E8C CALL TestPositionUnchanged Test whether the animal has stayed where it was.
9E8F JP NZ,HandlerRhino_Position Jump to HandlerRhino_Position if the animal has moved.
9E92 SET 2,(IX+$00) Set bit 2 of the sprite ID to put the animal to sleep.
9E96 JP UpdateActor Jump to UpdateActor to update the animal.
Count down the pause and test whether the animal has hit the player.
HandlerHippoWarthog_Pause 9E99 DEC A Decrease the pause counter by one.
9E9A LD (IX+$02),A Store the pause counter.
9E9D LD E,(IX+$03) Fetch the X position of the animal into E.
9EA0 LD D,(IX+$04) Fetch the Y position of the animal into D.
9EA3 LD A,(IX+$00) Fetch the sprite ID of the animal.
9EA6 RRCA Rotate the direction bit (bit 1) into bit 0.
9EA7 AND %00000001 Keep only bit 0.
9EA9 LD D,A Set the direction the animal is facing in D.
9EAA LD BC,$0F1C Set how far above and to the right of the animal the player can be in BC to 0F1C.
9EAD CALL TestActorHurtingPlayer Test whether the animal has hurt the player.
9EB0 JP UpdateActor Jump to UpdateActor to update the animal.
Prev: 9E64 Up: Map Next: 9EB3