Prev: AC77 Up: Map Next: AD46
AD07: Handler: Rhino
Handles a rhino (sprite IDs 30 to 33). Bit 1 of the sprite ID is set when the rhino is facing right.
The rhino moves with its X velocity (see MoveActor) and stops and turns around if it is blocked, when its speed is also reset. If it touches the player then the player is hurt and the rhino turns around, unless the player is attacking, in which case the rhino is knocked back instead (see KnockBackRhino).
Input
IX Actor record of the rhino
HandlerRhino AD07 CALL StoreEntity Remember the previous position of the rhino.
AD0A CALL AnimateRhino Animate the rhino.
AD0D LD A,$20 Set the width of the rhino in Actor_Width to 20.
AD0F LD ($96AD),A
AD12 CALL MoveActor Work out the new position of the rhino.
Stop the rhino moving through objects in the room. If it did not manage to move then turn it around.
AD15 LD BC,$171F Set the height of the rhino in B to 17 and the width in C to 1F.
AD18 CALL SlideActorPastObjects Stop the rhino passing through objects in the room.
AD1B CALL TestPositionUnchanged Test whether the rhino has stayed where it was.
AD1E JR NZ,HandlerRhino_Position Jump to HandlerRhino_Position if the rhino has moved.
AD20 LD A,$30 Set the speed of the rhino in A to 30.
AD22 CALL SetVelocityMagnitude Set the speed of the rhino, keeping its direction.
AD25 CALL TurnRhinoAround Turn the rhino around.
This entry point is used by the routine at HandlerHippoWarthog.
HandlerRhino_Position AD28 LD (IX+$03),E Set the X position of the rhino.
AD2B LD (IX+$04),D Set the Y position of the rhino.
Test whether the rhino has touched the player.
AD2E LD A,(IX+$00) Fetch the sprite ID of the rhino.
AD31 RRCA Rotate right, so bit 1 is now in bit 0.
AD32 AND %00000001 Keep only bit 0.
AD34 LD D,A Store the result in D (the hit direction for TestActorHurtingPlayer).
AD35 LD BC,$0F1C Set the reach used to test whether the rhino is touching the player in BC to 0F1C.
AD38 CALL TestActorHurtingPlayer Test whether the rhino is hurting the player.
AD3B JR NC,UpdateActor Jump to UpdateActor if the rhino is not touching the player.
AD3D LD A,($9704) Fetch the hit direction of the player from 9704.
AD40 AND A Jump to KnockBackRhino if the player was not hit, which means the rhino was hit by the sword.
AD41 JR Z,KnockBackRhino
AD43 CALL TurnRhinoAround Turn the rhino around.
Prev: AC77 Up: Map Next: AD46