Prev: A7F8 Up: Map Next: A8B2
A858: Handler: Wulf
Handles the Sabre Wulf (sprite IDs 50 to 57) when it is running. Bit 2 of the sprite ID is set when the Wulf is facing right.
Each time the Wulf is handled it animates, works out whether to head for the player (see ChooseWulfDirection) or pounce at them (see TestWulfPounce), moves with its velocity (see MoveActor), turns around if it was blocked and then hurts the player if it is touching them.
Input
IX Actor record of the Wulf
HandlerWulf A858 CALL StoreEntity Remember the previous position of the Wulf.
A85B LD A,$20 Set the width of the Wulf in Actor_Width to 20.
A85D LD ($96AD),A
A860 CALL AnimateActor Animate the Wulf.
A863 CALL ChooseWulfDirection Choose the direction of the Wulf.
A866 CALL TestWulfPounce Test whether the Wulf should pounce.
This entry point is used by the routine at HandlerWulfLanding.
HandlerWulf_Move A869 CALL MoveActor Work out the new position of the Wulf.
Stop the Wulf moving through objects in the room. If it did not manage to move then turn it around.
A86C LD BC,$171F Set the height of the Wulf in B to 17 and the width in C to 1F.
A86F CALL SlideActorPastObjects Stop the Wulf passing through objects in the room.
A872 CALL TestPositionUnchanged Test whether the Wulf has stayed where it was.
A875 JR NZ,HandlerWulf_Position Jump to HandlerWulf_Position if the Wulf has moved.
A877 CALL TurnWulfAround Turn the Wulf around.
HandlerWulf_Position A87A LD (IX+$03),E Set the X position of the Wulf.
A87D LD (IX+$04),D Set the Y position of the Wulf.
This entry point is used by the routine at HandlerWulfPouncing.
The Wulf can only hurt the player if the player is in the same room and has the normal colour.
HandlerWulf_Touch A880 LD A,($9707) Fetch the colour of the player from 9707.
A883 CP $47 Jump to HandlerWulf_Draw if the player does not have the normal colour (INK:WHITE, PAPER:BLACK (BRIGHT)).
A885 JR NZ,HandlerWulf_Draw
A887 LD A,($9703) Fetch the room of the player from 9703.
A88A CP (IX+$01) Jump to HandlerWulf_Draw if the Wulf is in a different room to the player.
A88D JR NZ,HandlerWulf_Draw
A88F LD BC,$0F1C Set the reach used to test whether the Wulf is touching the player in BC to 0F1C.
A892 CALL TestPlayerTouchingActor Test whether the Wulf is touching the player.
A895 JR NC,HandlerWulf_Draw Jump to HandlerWulf_Draw if the Wulf is not touching the player.
Knock the player in the direction the Wulf is facing.
A897 LD A,(IX+$00) Fetch the sprite ID of the Wulf.
A89A CPL Flip the bits.
A89B RRCA Rotate right twice, so bit 2 is now in bit 0.
A89C RRCA
A89D AND %00000001 Keep only bit 0.
A89F INC A Add one, giving a hit direction of 01 or 02.
A8A0 LD ($9704),A Store the hit direction in 9704.
Turn the Wulf around unless the player is attacking.
A8A3 LD A,($9702) Fetch the sprite ID of the player from ImmortalData.
A8A6 SUB $20 Subtract 20 (the first attacking Sabreman sprite ID).
A8A8 CP $10 Jump to HandlerWulf_Draw if the player is attacking.
A8AA JR C,HandlerWulf_Draw
A8AC CALL TurnWulfAround Turn the Wulf around.
HandlerWulf_Draw A8AF JP UpdateActor Jump to UpdateActor to update the Wulf.
Prev: A7F8 Up: Map Next: A8B2