![]() |
Routines |
| Prev: 32971 | Up: Map | Next: 33076 |
|
The handler for the wizard, which has the sprite IDs 17 to 32. The speed limits and the friction are passed to ControlPlayer, which reads the controls and moves the player. Then, every fourth frame while the player is moving, the walking frame is advanced and the sprite is turned to face the direction of the strongest movement. If the fire button is pressed then a fireball is thrown by ThrowFireball. The routine finishes by jumping to the code that is shared with the other characters at HandlerCharacter_Finish.
|
||||||||
|
Control the player. BC holds the speed limits (C for X and B for Y, where B is also the acceleration) and DE holds the friction (E for X and D for Y). HL is not used by ControlPlayer.
|
||||||||
| HandlerWizard | 32978 | LD BC,8224 | Set the speed limits in BC to 32 on both axes. | |||||
| 32981 | LD DE,8224 | Set the friction in DE to 32 on both axes. | ||||||
| 32984 | LD HL,8224 | HL=8224, which is not used by ControlPlayer. | ||||||
| 32987 | CALL ControlPlayer | Call ControlPlayer to control the player. | ||||||
|
Only change the walking frame if the player is moving.
|
||||||||
| 32990 | LD E,(IX+6) | Fetch the X velocity of the player into E. | ||||||
| 32993 | LD D,(IX+7) | Fetch the Y velocity of the player into D. | ||||||
| 32996 | LD A,D | Jump to HandlerWizard_Fire if the player is not moving. | ||||||
| 32997 | OR E | |||||||
| 32998 | JR Z,HandlerWizard_Fire | |||||||
|
The walking frame only changes every fourth frame.
|
||||||||
| 33000 | LD A,(23672) | Fetch FRAMES. | ||||||
| 33003 | AND %00000011 | Keep only bits 0-1. | ||||||
| 33005 | JR NZ,HandlerWizard_Fire | Jump to HandlerWizard_Fire if the result is not zero. | ||||||
|
Move on to the next of the four walking frames.
|
||||||||
| 33007 | LD A,(IX+0) | Fetch the sprite ID of the player. | ||||||
| 33010 | AND %00000011 | Keep only bits 0-1. | ||||||
| 33012 | ADD A,17 | Add 17 which gives the next walking frame. | ||||||
| 33014 | LD (IX+0),A | Write the new sprite ID back to the player. | ||||||
|
Make a copy of the Y speed, ignoring the direction.
|
||||||||
| 33017 | LD A,D | Fetch the Y velocity from D, then jump to HandlerWizard_AbsoluteX if it is positive. | ||||||
| 33018 | AND A | |||||||
| 33019 | JP P,HandlerWizard_AbsoluteX | |||||||
| 33022 | NEG | Make the Y speed positive. | ||||||
| HandlerWizard_AbsoluteX | 33024 | LD C,A | Keep the Y speed in C. | |||||
|
Make a copy of the X speed, ignoring the direction.
|
||||||||
| 33025 | LD A,E | Fetch the X velocity from E, then jump to HandlerWizard_CompareAxes if it is positive. | ||||||
| 33026 | AND A | |||||||
| 33027 | JP P,HandlerWizard_CompareAxes | |||||||
| 33030 | NEG | Make the X speed positive. | ||||||
| HandlerWizard_CompareAxes | 33032 | CP C | Jump to HandlerWizard_Horizontal if the X speed is the strongest movement. | |||||
| 33033 | JR NC,HandlerWizard_Horizontal | |||||||
|
The Y movement is the strongest, so face up or down.
|
||||||||
| 33035 | LD A,D | Test the sign of the Y velocity. | ||||||
| 33036 | AND A | |||||||
| 33037 | LD A,(IX+0) | Fetch the sprite ID of the player. | ||||||
| 33040 | JP M,HandlerWizard_Vertical | Jump to HandlerWizard_Vertical if the player is moving up. | ||||||
| 33043 | ADD A,4 | Add 4 to select the sprites for moving down. | ||||||
| HandlerWizard_Vertical | 33045 | ADD A,8 | Add 8. | |||||
| HandlerWizard_SetSprite | 33047 | LD (IX+0),A | Write the new sprite ID back to the player. | |||||
| 33050 | CALL SoundsWalking | Call SoundsWalking to make the walking sound. | ||||||
|
Check if the fire button is being pressed.
|
||||||||
| HandlerWizard_Fire | 33053 | CALL ReadControls | Call ReadControls to read the controls. | |||||
| 33056 | AND %00010000 | Keep only bit 4. | ||||||
| 33058 | CALL Z,ThrowFireball | Call ThrowFireball if the fire button is pressed. | ||||||
| 33061 | JP HandlerCharacter_Finish | Jump to HandlerCharacter_Finish to finish handling the character. | ||||||
|
The X movement is the strongest, so face left or right.
|
||||||||
| HandlerWizard_Horizontal | 33064 | LD A,E | Test the sign of the X velocity. | |||||
| 33065 | AND A | |||||||
| 33066 | LD A,(IX+0) | Fetch the sprite ID of the player. | ||||||
| 33069 | JP M,HandlerWizard_SetSprite | Jump to HandlerWizard_SetSprite if the player is moving left. | ||||||
| 33072 | ADD A,4 | Add 4 to select the sprites for moving right. | ||||||
| 33074 | JR HandlerWizard_SetSprite | Jump to HandlerWizard_SetSprite to set the sprite of the wizard. | ||||||
| Prev: 32971 | Up: Map | Next: 33076 |