![]() |
Routines |
| Prev: 33289 | Up: Map | Next: 33475 |
|
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 (56 to 63), as worked out by the same method that SwordDirection uses.
|
||||||||
| ThrowSword | 33411 | LD A,(60056) | Return if a weapon is already in flight. | |||||
| 33414 | AND A | |||||||
| 33415 | RET NZ | |||||||
| 33416 | LD A,(24109) | Return if the player is in a doorway. | ||||||
| 33419 | AND A | |||||||
| 33420 | RET NZ | |||||||
| 33421 | CALL SoundsSword | Call SoundsSword to make the sword sound. | ||||||
| 33424 | CALL SetWeaponVelocity | Call SetWeaponVelocity to set the velocity of the weapon. | ||||||
| 33427 | LD C,0 | C=0 (the direction number for down). | ||||||
|
HL points at the Y velocity of the weapon.
|
||||||||
| 33429 | LD A,(HL) | Fetch the Y velocity of the weapon. | ||||||
| 33430 | AND A | Jump to ThrowSword_Horizontal if the weapon is not moving vertically. | ||||||
| 33431 | JR Z,ThrowSword_Horizontal | |||||||
| 33433 | JP P,ThrowSword_CheckX | Jump to ThrowSword_CheckX if the weapon is moving down. | ||||||
| 33436 | LD C,4 | C=4 (the direction number for up). | ||||||
| ThrowSword_CheckX | 33438 | DEC HL | Point HL at the X velocity of the weapon. | |||||
| 33439 | LD A,(HL) | Fetch the X velocity of the weapon. | ||||||
| 33440 | AND A | Jump to ThrowSword_SetSprite if the weapon is not moving horizontally. | ||||||
| 33441 | JR Z,ThrowSword_SetSprite | |||||||
| 33443 | JP P,ThrowSword_Right | Jump to ThrowSword_Right if the weapon is moving right. | ||||||
| 33446 | DEC C | Decrease the direction number by one, as the weapon is moving left. | ||||||
| ThrowSword_SetSprite | 33447 | LD A,C | Fetch the direction number. | |||||
| 33448 | AND %00000111 | Keep only bits 0-2 (there are 8 sword sprites). | ||||||
| 33450 | ADD A,56 | Add 56 to point to the correct sprite ID (the sword base sprite ID is: 56). | ||||||
| 33452 | LD HL,60056 | Point HL at the player weapon at PlayerWeapon. | ||||||
| 33455 | LD (HL),A | Write the sprite ID to the weapon. | ||||||
| 33456 | JP LaunchWeapon | Jump to LaunchWeapon to launch the sword. | ||||||
| ThrowSword_Right | 33459 | INC C | Increase the direction number by one, as the weapon is moving right. | |||||
| 33460 | JR ThrowSword_SetSprite | Jump to ThrowSword_SetSprite to set the sprite of the sword. | ||||||
|
The weapon is moving horizontally only.
|
||||||||
| ThrowSword_Horizontal | 33462 | DEC HL | Point HL at the X velocity of the weapon. | |||||
| 33463 | BIT 7,(HL) | Jump to ThrowSword_MovingRight if the weapon is moving right. | ||||||
| 33465 | JR Z,ThrowSword_MovingRight | |||||||
| 33467 | LD C,6 | C=6 (the direction number for left). | ||||||
| 33469 | JR ThrowSword_SetSprite | Jump to ThrowSword_SetSprite to set the sprite of the sword. | ||||||
| ThrowSword_MovingRight | 33471 | LD C,2 | C=2 (the direction number for right). | |||||
| 33473 | JR ThrowSword_SetSprite | Jump to ThrowSword_SetSprite to set the sprite of the sword. | ||||||
| Prev: 33289 | Up: Map | Next: 33475 |