![]() |
Routines |
| Prev: 8283 | Up: Map | Next: 82F1 |
|
Used by the routine at HandlerSword.
Chooses the sprite of the sword in flight from its velocity. The sprite ID is 38 plus a direction number from 00 to 07 which is worked out in C from the signs of the Y and X velocities of the weapon.
|
||||||||
| SwordDirection | 82C3 | LD C,$00 | C=00 (the direction number for down). | |||||
| 82C5 | LD A,(HL) | Jump to SwordDirection_Horizontal if the weapon is not moving vertically. | ||||||
| 82C6 | AND A | |||||||
| 82C7 | JR Z,SwordDirection_Horizontal | |||||||
| 82C9 | JP P,SwordDirection_CheckX | Jump to SwordDirection_CheckX if the weapon is moving down. | ||||||
| 82CC | LD C,$04 | C=04 (the direction number for up). | ||||||
| SwordDirection_CheckX | 82CE | DEC HL | Point HL at the X velocity of the weapon. | |||||
| 82CF | LD A,(HL) | Fetch the X velocity of the weapon. | ||||||
| 82D0 | AND A | Jump to SwordDirection_SetSprite if the weapon is not moving horizontally. | ||||||
| 82D1 | JR Z,SwordDirection_SetSprite | |||||||
| 82D3 | JP P,SwordDirection_Right | Jump to SwordDirection_Right if the weapon is moving right. | ||||||
| 82D6 | DEC C | Decrease the direction number by one, as the weapon is moving left. | ||||||
| SwordDirection_SetSprite | 82D7 | LD A,C | Fetch the direction number. | |||||
| 82D8 | AND %00000111 | Keep only bits 0-2 (there are 8 animation frames). | ||||||
| 82DA | ADD A,$38 | Add 38 to point to the correct frame/ sprite ID (the sword base sprite ID is: 38). | ||||||
| 82DC | LD HL,$EA98 | Point HL at the player weapon at PlayerWeapon. | ||||||
| 82DF | LD (HL),A | Write the new frame/ sprite ID to the weapon. | ||||||
| 82E0 | RET | Return. | ||||||
| SwordDirection_Right | 82E1 | INC C | Increase the direction number by one, as the weapon is moving right. | |||||
| 82E2 | JR SwordDirection_SetSprite | Jump to SwordDirection_SetSprite to set the sprite of the sword. | ||||||
|
The weapon is moving horizontally only.
|
||||||||
| SwordDirection_Horizontal | 82E4 | DEC HL | Point HL at the X velocity of the weapon. | |||||
| 82E5 | BIT 7,(HL) | Jump to SwordDirection_MovingRight if the weapon is moving right. | ||||||
| 82E7 | JR Z,SwordDirection_MovingRight | |||||||
| 82E9 | LD C,$06 | C=06 (the direction number for left). | ||||||
| 82EB | JR SwordDirection_SetSprite | Jump to SwordDirection_SetSprite to set the sprite of the sword. | ||||||
| SwordDirection_MovingRight | 82ED | LD C,$02 | C=02 (the direction number for right). | |||||
| 82EF | JR SwordDirection_SetSprite | Jump to SwordDirection_SetSprite to set the sprite of the sword. | ||||||
| Prev: 8283 | Up: Map | Next: 82F1 |