Prev: 9E72 Up: Map Next: 9F06
9EB3: Handler: Sleeping Hippo And Warthog
Handles a hippo (sprite IDs A4-A7) or a warthog (sprite IDs AC-AF) which is asleep. If BringActorCloser has moved the animal to another room then it wakes up as a hippo or a warthog chosen at random (see WakeAnimal).
If the player touches the animal (see TestActorHurtingPlayer), unless the start-of-turn delay is running or the player is not alive, then the animal wakes up, turns around, stands still for a short while (the counter in *IX+02) and makes a noise.
Input
IX Actor record
If the animal has been moved to another room then wake it up.
HandlerSleepingHippoWarthog 9EB3 LD C,(IX+$01) Fetch the room of the animal into C.
9EB6 PUSH BC Stash the room on the stack.
9EB7 CALL BringActorCloser Move the animal into the row above or below the player if it is two or more rows away.
9EBA POP BC Restore the old room of the animal from the stack.
9EBB LD A,(IX+$01) Fetch the new room of the animal.
9EBE CP C Compare with the old room.
9EBF CALL NZ,WakeAnimal Wake the animal up if it has moved to a different room.
Do nothing else unless the animal is in the same room as the player.
9EC2 LD A,($9703) Fetch the room of the player from 9703.
9EC5 CP (IX+$01) Compare with the room of the animal.
9EC8 RET NZ Return if the animal is in a different room to the player.
9EC9 CALL StoreEntity Remember the previous position of the animal.
9ECC LD A,$20 Write 20 to Actor_Width (the width of the animal).
9ECE LD ($96AD),A
9ED1 LD A,(IX+$00) Fetch the sprite ID of the animal.
9ED4 RRCA Rotate the direction bit (bit 1) into bit 0.
9ED5 AND %00000001 Keep only bit 0.
9ED7 LD D,A Set the direction the animal is facing in D.
9ED8 LD BC,$0F1C Set how far above and to the right of the animal the player can be in BC to 0F1C.
9EDB LD A,($96B5) Fetch the start-of-turn delay from GameDelayTimer.
9EDE AND A Set the flags.
9EDF JR NZ,HandlerSleepingHippoWarthog_NoHurt Jump to HandlerSleepingHippoWarthog_NoHurt if the start-of-turn delay is running.
9EE1 LD A,($9702) Fetch the sprite ID of the player from ImmortalData.
9EE4 SUB $10 Subtract 10 (the first Sabreman sprite ID).
9EE6 CP $20 Jump to HandlerSleepingHippoWarthog_NoHurt if the player is not alive.
9EE8 JR NC,HandlerSleepingHippoWarthog_NoHurt
9EEA CALL TestActorHurtingPlayer Test whether the animal is touching the player.
HandlerSleepingHippoWarthog_Touch 9EED JP NC,DisplayActor Jump to DisplayActor to display the animal if the player is not touching it.
The player is touching the animal so it wakes up and turns around.
9EF0 RES 2,(IX+$00) Reset bit 2 of the sprite ID to wake the animal up.
9EF4 CALL TurnRhinoAround Turn the animal around.
9EF7 LD (IX+$02),$0F Set the pause counter of the animal to 0F so that it stands still.
9EFB CALL DisplayActor Display the animal.
9EFE JP PlayWarbleSound Jump to PlayWarbleSound to play the warble sound.
Test whether the player is touching the animal, without hurting the player.
HandlerSleepingHippoWarthog_NoHurt 9F01 CALL TestPlayerTouchingActor_Reach Test whether the player is touching the animal.
9F04 JR HandlerSleepingHippoWarthog_Touch Jump to HandlerSleepingHippoWarthog_Touch.
Prev: 9E72 Up: Map Next: 9F06