Prev: 43000 Up: Map Next: 43186
43096: Handler: Wulf
Handles the Sabre Wulf (sprite IDs 80 to 87) 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 43096 CALL StoreEntity Remember the previous position of the Wulf.
43099 LD A,32 Set the width of the Wulf in Actor_Width to 32.
43101 LD (38573),A
43104 CALL AnimateActor Animate the Wulf.
43107 CALL ChooseWulfDirection Choose the direction of the Wulf.
43110 CALL TestWulfPounce Test whether the Wulf should pounce.
This entry point is used by the routine at HandlerWulfLanding.
HandlerWulf_Move 43113 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.
43116 LD BC,5919 Set the height of the Wulf in B to 23 and the width in C to 31.
43119 CALL SlideActorPastObjects Stop the Wulf passing through objects in the room.
43122 CALL TestPositionUnchanged Test whether the Wulf has stayed where it was.
43125 JR NZ,HandlerWulf_Position Jump to HandlerWulf_Position if the Wulf has moved.
43127 CALL TurnWulfAround Turn the Wulf around.
HandlerWulf_Position 43130 LD (IX+3),E Set the X position of the Wulf.
43133 LD (IX+4),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 43136 LD A,(38663) Fetch the colour of the player from 38663.
43139 CP 71 Jump to HandlerWulf_Draw if the player does not have the normal colour (INK:WHITE, PAPER:BLACK (BRIGHT)).
43141 JR NZ,HandlerWulf_Draw
43143 LD A,(38659) Fetch the room of the player from 38659.
43146 CP (IX+1) Jump to HandlerWulf_Draw if the Wulf is in a different room to the player.
43149 JR NZ,HandlerWulf_Draw
43151 LD BC,3868 Set the reach used to test whether the Wulf is touching the player in BC to 3868.
43154 CALL TestPlayerTouchingActor Test whether the Wulf is touching the player.
43157 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.
43159 LD A,(IX+0) Fetch the sprite ID of the Wulf.
43162 CPL Flip the bits.
43163 RRCA Rotate right twice, so bit 2 is now in bit 0.
43164 RRCA
43165 AND %00000001 Keep only bit 0.
43167 INC A Add one, giving a hit direction of 1 or 2.
43168 LD (38660),A Store the hit direction in 38660.
Turn the Wulf around unless the player is attacking.
43171 LD A,(38658) Fetch the sprite ID of the player from ImmortalData.
43174 SUB 32 Subtract 32 (the first attacking Sabreman sprite ID).
43176 CP 16 Jump to HandlerWulf_Draw if the player is attacking.
43178 JR C,HandlerWulf_Draw
43180 CALL TurnWulfAround Turn the Wulf around.
HandlerWulf_Draw 43183 JP UpdateActor Jump to UpdateActor to update the Wulf.
Prev: 43000 Up: Map Next: 43186