![]() |
Routines |
| Prev: 36205 | Up: Map | Next: 36292 |
|
Moves the entity of a character, using the controls. Called by the handlers of the knight and the serf (and the wizard). The velocities of the entity are kept at offsets 6 (X) and 7 (Y), and have four bits after the point, so only the top four bits make up the whole pixels moved each frame. They are changed by UpdateVelocity, slowed by SlowVelocity and limited by CheckRoomBounds and CheckObstacles before ApplyMovement moves the entity. The bits at offset 2 are the number of steps still to be taken in the bottom four, and in bits 4-5 a flag that is set when movement is blocked along the X axis (bit 4) or the Y axis (bit 5).
|
||||||||||||||||
| ControlPlayer | 36215 | LD A,(60049) | Fetch the room of the player from PlayerRoom. | |||||||||||||
| 36218 | LD (61017),A | Write A to 61017 (the room of the entity at Initialisation_Blank). | ||||||||||||||
| 36221 | PUSH BC | Stash the speed limits (BC), the slowing (DE) and HL on the stack. | ||||||||||||||
| 36222 | PUSH DE | |||||||||||||||
| 36223 | PUSH HL | |||||||||||||||
| 36224 | CALL AutoWalkStep | Call AutoWalkStep to take a step of the auto walk. | ||||||||||||||
| 36227 | LD A,(IX+2) | Fetch offset 2 of the entity. | ||||||||||||||
| 36230 | OR %00110000 | Set bits 4-5, to stop all movement until a check shows it is possible. | ||||||||||||||
| 36232 | LD (IX+2),A | Update offset 2 of the entity. | ||||||||||||||
| 36235 | CALL StoreEntity | Call StoreEntity to save the position of the entity. | ||||||||||||||
|
Read the controls (a bit is zero when the control is used) and work out the change in velocity for each axis.
|
||||||||||||||||
| 36238 | CALL ReadControls | Call ReadControls to read the controls. | ||||||||||||||
| 36241 | LD C,A | Keep the controls in C. | ||||||||||||||
| 36242 | POP HL | Restore HL from the stack. | ||||||||||||||
| 36243 | LD DE,0 | DE=0000 (no change in either velocity). | ||||||||||||||
| 36246 | BIT 1,C | Jump to ControlPlayer_Right if bit 1 (left) is not used. | ||||||||||||||
| 36248 | JR NZ,ControlPlayer_Right | |||||||||||||||
| 36250 | LD A,B | Fetch the change in velocity. | ||||||||||||||
| 36251 | NEG | Reverse the change, so that it is negative. | ||||||||||||||
| 36253 | LD E,A | E=A (the X change is -B). | ||||||||||||||
| ControlPlayer_Right | 36254 | BIT 0,C | Jump to ControlPlayer_Down if bit 0 (right) is not used. | |||||||||||||
| 36256 | JR NZ,ControlPlayer_Down | |||||||||||||||
| 36258 | LD E,B | E=B (the X change is B). | ||||||||||||||
| ControlPlayer_Down | 36259 | BIT 2,C | Jump to ControlPlayer_Up if bit 2 (down) is not used. | |||||||||||||
| 36261 | JR NZ,ControlPlayer_Up | |||||||||||||||
| 36263 | LD D,B | D=B (the Y change is B). | ||||||||||||||
| ControlPlayer_Up | 36264 | BIT 3,C | Jump to ControlPlayer_Move if bit 3 (up) is not used. | |||||||||||||
| 36266 | JR NZ,ControlPlayer_Move | |||||||||||||||
| 36268 | LD A,B | Fetch the change in velocity. | ||||||||||||||
| 36269 | NEG | Reverse the change, so that it is negative. | ||||||||||||||
| 36271 | LD D,A | D=A (the Y change is -B). | ||||||||||||||
|
Slow the velocities, change them, check for obstacles and then move the entity.
|
||||||||||||||||
| ControlPlayer_Move | 36272 | POP HL | Restore the amounts of slowing from the stack into HL. | |||||||||||||
| 36273 | CALL SlowVelocity | Call SlowVelocity to slow the entity down. | ||||||||||||||
| 36276 | POP HL | Restore the fastest velocities from the stack into HL. | ||||||||||||||
| 36277 | CALL UpdateVelocity | Call UpdateVelocity to update the velocities of the entity. | ||||||||||||||
| 36280 | CALL CheckRoomBounds | Call CheckRoomBounds to check whether the entity is inside the room. | ||||||||||||||
| 36283 | CALL CheckDoorway | Call CheckDoorway to check the doorway. | ||||||||||||||
| 36286 | CALL CheckObstacles | Call CheckObstacles to check whether the entity would hit an item. | ||||||||||||||
| 36289 | JP ApplyMovement | Jump to ApplyMovement to move the entity by its velocities. | ||||||||||||||
| Prev: 36205 | Up: Map | Next: 36292 |