Prev: 33099 Up: Map Next: 33243
33148: Set Weapon Velocity
Used by the routines at ThrowAxe, ThrowFireball and ThrowSword.
Gets a weapon ready to be launched. The lifetime of the weapon is set to 48 and its flags are cleared. The velocity is 4 pixels per frame in the direction that the player is moving, or if the player is standing still then in the direction that the player is facing.
Input
IX The player entity
Reset the weapon.
SetWeaponVelocity 33148 LD HL,60062 Point HL at the X velocity of the weapon at PlayerWeapon_X_Velocity.
33151 LD A,48 Write 48 to 60071 (the lifetime of the weapon).
33153 LD (60071),A
33156 LD A,0 Write 0 to 60058 (the flags of the weapon).
33158 LD (60058),A
If the player is moving then the weapon follows the direction of the movement.
33161 LD A,(IX+6) Fetch the X velocity of the player.
33164 OR (IX+7) Jump to SetWeaponVelocity_Facing if the player is not moving.
33167 JR Z,SetWeaponVelocity_Facing
33169 LD A,(IX+6) Fetch the X velocity of the player.
33172 AND A Jump to SetWeaponVelocity_StoreX if the player is not moving horizontally.
33173 JR Z,SetWeaponVelocity_StoreX
33175 JP M,SetWeaponVelocity_Left Jump to SetWeaponVelocity_Left if the player is moving left.
33178 LD A,4 A=4 (the velocity for moving right).
33180 JR SetWeaponVelocity_StoreX Jump to SetWeaponVelocity_StoreX to store the X velocity of the weapon.
SetWeaponVelocity_Left 33182 LD A,252 A=252 (-4 the velocity for moving left).
SetWeaponVelocity_StoreX 33184 LD (HL),A Update the X velocity of the weapon.
33185 INC HL Move HL on to the Y velocity of the weapon.
33186 LD A,(IX+7) Fetch the Y velocity of the player.
33189 AND A Jump to SetWeaponVelocity_StoreY if the player is not moving vertically.
33190 JR Z,SetWeaponVelocity_StoreY
33192 JP M,SetWeaponVelocity_Up Jump to SetWeaponVelocity_Up if the player is moving up.
33195 LD A,4 A=4 (the velocity for moving down).
33197 JR SetWeaponVelocity_StoreY Jump to SetWeaponVelocity_StoreY to store the Y velocity of the weapon.
SetWeaponVelocity_Up 33199 LD A,252 A=252 (-4 the velocity for moving up).
SetWeaponVelocity_StoreY 33201 LD (HL),A Update the Y velocity of the weapon.
33202 RET Return.
The player is standing still, so use the direction that the sprite is facing.
SetWeaponVelocity_Facing 33203 LD A,(IX+0) Fetch the sprite ID of the player.
33206 DEC A Decrease A by one.
33207 AND %00001100 Keep only bits 2-3, which is the direction.
33209 JR Z,SetWeaponVelocity_FacingLeft Jump to SetWeaponVelocity_FacingLeft if the player is facing left.
33211 CP 4 Jump to SetWeaponVelocity_FacingRight if the player is facing right.
33213 JR Z,SetWeaponVelocity_FacingRight
33215 CP 8 Jump to SetWeaponVelocity_FacingDown if the player is not facing up.
33217 JR NZ,SetWeaponVelocity_FacingDown
33219 LD (HL),0 Write 0 to the X velocity of the weapon.
33221 INC HL Move HL on to the Y velocity of the weapon.
33222 LD (HL),252 Write 252 (-4) to the Y velocity of the weapon.
33224 RET Return.
SetWeaponVelocity_FacingLeft 33225 LD (HL),252 Write 252 (-4) to the X velocity of the weapon.
33227 INC HL Move HL on to the Y velocity of the weapon.
33228 LD (HL),0 Write 0 to the Y velocity of the weapon.
33230 RET Return.
SetWeaponVelocity_FacingRight 33231 LD (HL),4 Write 4 to the X velocity of the weapon.
33233 INC HL Move HL on to the Y velocity of the weapon.
33234 LD (HL),0 Write 0 to the Y velocity of the weapon.
33236 RET Return.
SetWeaponVelocity_FacingDown 33237 LD (HL),0 Write 0 to the X velocity of the weapon.
33239 INC HL Move HL on to the Y velocity of the weapon.
33240 LD (HL),4 Write 4 to the Y velocity of the weapon.
33242 RET Return.
Prev: 33099 Up: Map Next: 33243