![]() |
Routines |
| Prev: 33411 | Up: Map | Next: 33521 |
|
Used by the routine at HandlerSword.
Chooses the sprite of the sword in flight from its velocity. The sprite ID is 56 plus a direction number from 0 to 7 which is worked out in C from the signs of the Y and X velocities of the weapon.
|
||||||||
| SwordDirection | 33475 | LD C,0 | C=0 (the direction number for down). | |||||
| 33477 | LD A,(HL) | Jump to SwordDirection_Horizontal if the weapon is not moving vertically. | ||||||
| 33478 | AND A | |||||||
| 33479 | JR Z,SwordDirection_Horizontal | |||||||
| 33481 | JP P,SwordDirection_CheckX | Jump to SwordDirection_CheckX if the weapon is moving down. | ||||||
| 33484 | LD C,4 | C=4 (the direction number for up). | ||||||
| SwordDirection_CheckX | 33486 | DEC HL | Point HL at the X velocity of the weapon. | |||||
| 33487 | LD A,(HL) | Fetch the X velocity of the weapon. | ||||||
| 33488 | AND A | Jump to SwordDirection_SetSprite if the weapon is not moving horizontally. | ||||||
| 33489 | JR Z,SwordDirection_SetSprite | |||||||
| 33491 | JP P,SwordDirection_Right | Jump to SwordDirection_Right if the weapon is moving right. | ||||||
| 33494 | DEC C | Decrease the direction number by one, as the weapon is moving left. | ||||||
| SwordDirection_SetSprite | 33495 | LD A,C | Fetch the direction number. | |||||
| 33496 | AND %00000111 | Keep only bits 0-2 (there are 8 animation frames). | ||||||
| 33498 | ADD A,56 | Add 56 to point to the correct frame/ sprite ID (the sword base sprite ID is: 56). | ||||||
| 33500 | LD HL,60056 | Point HL at the player weapon at PlayerWeapon. | ||||||
| 33503 | LD (HL),A | Write the new frame/ sprite ID to the weapon. | ||||||
| 33504 | RET | Return. | ||||||
| SwordDirection_Right | 33505 | INC C | Increase the direction number by one, as the weapon is moving right. | |||||
| 33506 | JR SwordDirection_SetSprite | Jump to SwordDirection_SetSprite to set the sprite of the sword. | ||||||
|
The weapon is moving horizontally only.
|
||||||||
| SwordDirection_Horizontal | 33508 | DEC HL | Point HL at the X velocity of the weapon. | |||||
| 33509 | BIT 7,(HL) | Jump to SwordDirection_MovingRight if the weapon is moving right. | ||||||
| 33511 | JR Z,SwordDirection_MovingRight | |||||||
| 33513 | LD C,6 | C=6 (the direction number for left). | ||||||
| 33515 | JR SwordDirection_SetSprite | Jump to SwordDirection_SetSprite to set the sprite of the sword. | ||||||
| SwordDirection_MovingRight | 33517 | LD C,2 | C=2 (the direction number for right). | |||||
| 33519 | JR SwordDirection_SetSprite | Jump to SwordDirection_SetSprite to set the sprite of the sword. | ||||||
| Prev: 33411 | Up: Map | Next: 33521 |