Prev: ADBF Up: Map Next: AE34
ADD0: Handler: Attacking Sabreman
Handles the player while they are attacking with the sword (sprite IDs 20 to 2F). Bit 3 of the sprite ID is set when the player is attacking to the right.
While the player is holding down "fire" they can move about with a fixed speed in any direction. When "fire" is released, or if the player has an orchid effect, the player is made to walk again by StopAttack. If the player has been hit (the hit direction in IX+02 is not zero) then they are knocked back by KnockPlayerBack.
Input
IX Actor record of the player
PlayerMovement ADD0 CALL StoreEntity Remember the previous position of the player.
ADD3 CALL TestPlayerProgress Check the progress of the player.
ADD6 LD A,$10 Set the width of the player in Actor_Width to 10.
ADD8 LD ($96AD),A
ADDB LD A,(IX+$02) Fetch the hit direction of the player.
ADDE AND A Jump to KnockPlayerBack if the player has been hit.
ADDF JP NZ,KnockPlayerBack
Initialise the player movement (0000 == no movement).
ADE2 LD DE,$0000 Clear the movement of the player in DE.
Read the controls.
ADE5 CALL HandlerControls Read the controls.
Check if the player is under the influence of an orchid.
ADE8 LD A,(IX+$05) Fetch the colour of the player.
ADEB CP $47 Jump to StopAttack if the player is not using attribute INK:WHITE, PAPER:BLACK (BRIGHT).
ADED JR NZ,StopAttack
Check that "fire" is still being pressed.
ADEF BIT 4,C Jump to StopAttack if "fire" is not being pressed.
ADF1 JR Z,StopAttack
Handle "right".
ADF3 BIT 1,C Jump to PlayerMovement_Left if "right" is not being pressed.
ADF5 JR Z,PlayerMovement_Left
ADF7 LD A,E Add 20 to the X movement in E.
ADF8 ADD A,$20
ADFA LD E,A
Handle "left".
PlayerMovement_Left ADFB BIT 0,C Jump to PlayerMovement_Up if "left" is not being pressed.
ADFD JR Z,PlayerMovement_Up
ADFF LD A,E Subtract 20 from the X movement in E.
AE00 SUB $20
AE02 LD E,A
Handle "up".
PlayerMovement_Up AE03 BIT 2,C Jump to PlayerMovement_Down if "up" is not being pressed.
AE05 JR Z,PlayerMovement_Down
AE07 LD A,D Subtract 20 from the Y movement in D.
AE08 SUB $20
AE0A LD D,A
Handle "down".
PlayerMovement_Down AE0B BIT 3,C Jump to PlayerMovement_Move if "down" is not being pressed.
AE0D JR Z,PlayerMovement_Move
AE0F LD A,D Add 20 to the Y movement in D.
AE10 ADD A,$20
AE12 LD D,A
Update the player actor record and move the player.
PlayerMovement_Move AE13 LD (IX+$06),E Set the X velocity of the player.
AE16 LD (IX+$07),D Set the Y velocity of the player.
AE19 CALL MoveActor Work out the new position of the player.
AE1C LD BC,$160E Set the height of the player in B to 16 and the width in C to 0E.
AE1F CALL SlideActorPastObjects Stop the player passing through objects in the room.
AE22 CALL AnimateAttack Animate the attacking player.
AE25 CALL TestPositionUnchanged Test whether the player has stayed where it was.
AE28 LD (IX+$03),E Set the X position of the player.
AE2B LD (IX+$04),D Set the Y position of the player.
AE2E CALL NZ,PlayFootstepSound Play the footstep sound if the player moved.
AE31 JP DisplayActor Jump to DisplayActor to display the player.
Prev: ADBF Up: Map Next: AE34