![]() |
Routines |
| Prev: 8209 | Up: Map | Next: 82C3 |
|
Used by the routine at HandlerSerf.
Launches a sword for the serf, unless a weapon is already in flight or the player is in a doorway. The sprite ID of the sword depends on the direction that the weapon is travelling in (38 to 3F), as worked out by the same method that SwordDirection uses.
|
||||||||
| ThrowSword | 8283 | LD A,($EA98) | Return if a weapon is already in flight. | |||||
| 8286 | AND A | |||||||
| 8287 | RET NZ | |||||||
| 8288 | LD A,($5E2D) | Return if the player is in a doorway. | ||||||
| 828B | AND A | |||||||
| 828C | RET NZ | |||||||
| 828D | CALL SoundsSword | Call SoundsSword to make the sword sound. | ||||||
| 8290 | CALL SetWeaponVelocity | Call SetWeaponVelocity to set the velocity of the weapon. | ||||||
| 8293 | LD C,$00 | C=00 (the direction number for down). | ||||||
|
HL points at the Y velocity of the weapon.
|
||||||||
| 8295 | LD A,(HL) | Fetch the Y velocity of the weapon. | ||||||
| 8296 | AND A | Jump to ThrowSword_Horizontal if the weapon is not moving vertically. | ||||||
| 8297 | JR Z,ThrowSword_Horizontal | |||||||
| 8299 | JP P,ThrowSword_CheckX | Jump to ThrowSword_CheckX if the weapon is moving down. | ||||||
| 829C | LD C,$04 | C=04 (the direction number for up). | ||||||
| ThrowSword_CheckX | 829E | DEC HL | Point HL at the X velocity of the weapon. | |||||
| 829F | LD A,(HL) | Fetch the X velocity of the weapon. | ||||||
| 82A0 | AND A | Jump to ThrowSword_SetSprite if the weapon is not moving horizontally. | ||||||
| 82A1 | JR Z,ThrowSword_SetSprite | |||||||
| 82A3 | JP P,ThrowSword_Right | Jump to ThrowSword_Right if the weapon is moving right. | ||||||
| 82A6 | DEC C | Decrease the direction number by one, as the weapon is moving left. | ||||||
| ThrowSword_SetSprite | 82A7 | LD A,C | Fetch the direction number. | |||||
| 82A8 | AND %00000111 | Keep only bits 0-2 (there are 8 sword sprites). | ||||||
| 82AA | ADD A,$38 | Add 38 to point to the correct sprite ID (the sword base sprite ID is: 38). | ||||||
| 82AC | LD HL,$EA98 | Point HL at the player weapon at PlayerWeapon. | ||||||
| 82AF | LD (HL),A | Write the sprite ID to the weapon. | ||||||
| 82B0 | JP LaunchWeapon | Jump to LaunchWeapon to launch the sword. | ||||||
| ThrowSword_Right | 82B3 | INC C | Increase the direction number by one, as the weapon is moving right. | |||||
| 82B4 | JR ThrowSword_SetSprite | Jump to ThrowSword_SetSprite to set the sprite of the sword. | ||||||
|
The weapon is moving horizontally only.
|
||||||||
| ThrowSword_Horizontal | 82B6 | DEC HL | Point HL at the X velocity of the weapon. | |||||
| 82B7 | BIT 7,(HL) | Jump to ThrowSword_MovingRight if the weapon is moving right. | ||||||
| 82B9 | JR Z,ThrowSword_MovingRight | |||||||
| 82BB | LD C,$06 | C=06 (the direction number for left). | ||||||
| 82BD | JR ThrowSword_SetSprite | Jump to ThrowSword_SetSprite to set the sprite of the sword. | ||||||
| ThrowSword_MovingRight | 82BF | LD C,$02 | C=02 (the direction number for right). | |||||
| 82C1 | JR ThrowSword_SetSprite | Jump to ThrowSword_SetSprite to set the sprite of the sword. | ||||||
| Prev: 8209 | Up: Map | Next: 82C3 |