Prev: AE47 Up: Map Next: AE7A
AE4B: Animate Attack
Used by the routine at PlayerMovement.
Sets the direction and animation of an attacking Sabreman. If the X velocity is positive then bit 3 of the sprite ID is set and the player attacks to the right, and if it is negative then bit 3 is reset. Every four frames the sprite is changed to one of the first eight frames at random.
Input
IX Actor record of the player
AnimateAttack AE4B LD A,(IX+$06) Fetch the X velocity of the player.
AE4E AND A Jump to AnimateAttack_Frame if the player is not moving left or right.
AE4F JR Z,AnimateAttack_Frame
AE51 JP M,AnimateAttack_Left Jump to AnimateAttack_Left if the player is moving left.
AE54 LD A,(IX+$00) Fetch the sprite ID of the player.
AE57 OR %00001000 Set bit 3 (attacking to the right).
AnimateAttack_Store AE59 LD (IX+$00),A Set the new sprite ID of the player.
AnimateAttack_Frame AE5C LD A,($5C78) Fetch the low byte of FRAMES.
AE5F AND %00000011 Keep only bits 0-1.
AE61 RET NZ Return if this is not every fourth frame.
AE62 LD C,(IX+$00) Fetch the sprite ID of the player into C.
AE65 LD A,($9695) Fetch the random seed from RandomNumber.
AE68 AND %00000111 Keep only bits 0-2.
AE6A LD B,A Stash the random animation frame in B.
AE6B LD A,C Fetch the sprite ID of the player.
AE6C AND %11111000 Keep only bits 3-7.
AE6E OR B Merge in the animation frame.
AE6F LD (IX+$00),A Set the new sprite ID of the player.
AE72 RET Return.
AnimateAttack_Left AE73 LD A,(IX+$00) Fetch the sprite ID of the player.
AE76 AND %11110111 Keep only bits 0-2 and 4-7, which resets bit 3 (attacking to the left).
AE78 JR AnimateAttack_Store Jump to AnimateAttack_Store.
Prev: AE47 Up: Map Next: AE7A