![]() |
Routines |
| Prev: 36567 | Up: Map | Next: 36710 |
|
Used by the routine at ControlPlayer.
Changes the velocities of an entity that is controlled by ControlPlayer, and works out how many whole pixels it will move this frame. Each velocity (at offsets 6 and 7) has the change added, and is then limited to the fastest speed in either direction. The top four bits of the velocity are the pixels to move, which is GetWholePixels. While the steps of an automatic walk are being counted down by AutoWalkStep (the bottom four bits of offset 2) the pixels moved are 0 or 2 instead, depending on whether the velocity is below 16 with the sign of the velocity.
|
||||||||||||||||
| UpdateVelocity | 36591 | LD A,(IX+2) | Fetch offset 2 of the entity. | |||||||||||||
| 36594 | AND %00001111 | Keep only bits 0-3. | ||||||||||||||
| 36596 | JR NZ,UpdateVelocity_Walk | Jump to UpdateVelocity_Walk if an automatic walk is under way. | ||||||||||||||
|
Change the X velocity, and keep it within the fastest speed.
|
||||||||||||||||
| 36598 | LD A,E | Fetch the change in the X velocity from E. | ||||||||||||||
| 36599 | ADD A,(IX+6) | Add the X velocity. | ||||||||||||||
| 36602 | JP M,UpdateVelocity_NegativeX | Jump to UpdateVelocity_NegativeX if the result is negative. | ||||||||||||||
| 36605 | CP L | Jump to UpdateVelocity_SetX if the X velocity is slower than the fastest X velocity. | ||||||||||||||
| 36606 | JR C,UpdateVelocity_SetX | |||||||||||||||
| 36608 | LD A,L | Use the fastest X velocity. | ||||||||||||||
| UpdateVelocity_SetX | 36609 | LD (IX+6),A | Update the X velocity. | |||||||||||||
|
Change the Y velocity, and keep it within the fastest speed.
|
||||||||||||||||
| 36612 | LD A,D | Fetch the change in the Y velocity from D. | ||||||||||||||
| 36613 | ADD A,(IX+7) | Add the Y velocity. | ||||||||||||||
| 36616 | JP M,UpdateVelocity_NegativeY | Jump to UpdateVelocity_NegativeY if the result is negative. | ||||||||||||||
| 36619 | CP H | Jump to UpdateVelocity_SetY if the Y velocity is slower than the fastest Y velocity. | ||||||||||||||
| 36620 | JR C,UpdateVelocity_SetY | |||||||||||||||
| 36622 | LD A,H | Use the fastest Y velocity. | ||||||||||||||
| UpdateVelocity_SetY | 36623 | LD (IX+7),A | Update the Y velocity. | |||||||||||||
|
Get the whole pixels from the velocities.
|
||||||||||||||||
| 36626 | LD A,(IX+6) | Fetch the X velocity. | ||||||||||||||
| 36629 | CALL GetWholePixels | Call GetWholePixels to convert the velocity to whole pixels. | ||||||||||||||
| 36632 | LD E,A | Keep the whole pixels of the X velocity in E. | ||||||||||||||
| 36633 | LD A,(IX+7) | Fetch the Y velocity. | ||||||||||||||
| 36636 | CALL GetWholePixels | Call GetWholePixels to convert the velocity to whole pixels. | ||||||||||||||
| 36639 | LD D,A | Keep the whole pixels of the Y velocity in D. | ||||||||||||||
| 36640 | RET | Return. | ||||||||||||||
|
The X velocity is negative, so limit it using its size.
|
||||||||||||||||
| UpdateVelocity_NegativeX | 36641 | NEG | Make the X velocity positive. | |||||||||||||
| 36643 | CP L | Jump to UpdateVelocity_NegateX if the X velocity is slower than the fastest X velocity. | ||||||||||||||
| 36644 | JR C,UpdateVelocity_NegateX | |||||||||||||||
| 36646 | LD A,L | Use the fastest X velocity. | ||||||||||||||
| UpdateVelocity_NegateX | 36647 | NEG | Make the X velocity negative again. | |||||||||||||
| 36649 | JR UpdateVelocity_SetX | Jump to UpdateVelocity_SetX to set the X velocity. | ||||||||||||||
|
The Y velocity is negative, so limit it using its size.
|
||||||||||||||||
| UpdateVelocity_NegativeY | 36651 | NEG | Make the Y velocity positive. | |||||||||||||
| 36653 | CP H | Jump to UpdateVelocity_NegateY if the Y velocity is slower than the fastest Y velocity. | ||||||||||||||
| 36654 | JR C,UpdateVelocity_NegateY | |||||||||||||||
| 36656 | LD A,H | Use the fastest Y velocity. | ||||||||||||||
| UpdateVelocity_NegateY | 36657 | NEG | Make the Y velocity negative again. | |||||||||||||
| 36659 | JR UpdateVelocity_SetY | Jump to UpdateVelocity_SetY to set the Y velocity. | ||||||||||||||
|
An automatic walk is under way, so move by two pixels on an axis if its velocity is 16 or more, or else not at all.
|
||||||||||||||||
| UpdateVelocity_Walk | 36661 | LD A,(IX+6) | Fetch the X velocity. | |||||||||||||
| 36664 | AND A | Jump to UpdateVelocity_WalkNegativeX if the X velocity is negative. | ||||||||||||||
| 36665 | JP M,UpdateVelocity_WalkNegativeX | |||||||||||||||
| 36668 | AND %11110000 | Keep only bits 4-7. | ||||||||||||||
| 36670 | JR Z,UpdateVelocity_WalkY | Jump to UpdateVelocity_WalkY if the result is zero. | ||||||||||||||
| 36672 | LD A,2 | A=2 (move two pixels right). | ||||||||||||||
| UpdateVelocity_WalkY | 36674 | LD E,A | Keep the X move in E. | |||||||||||||
| 36675 | LD A,(IX+7) | Fetch the Y velocity. | ||||||||||||||
| 36678 | AND A | Jump to UpdateVelocity_WalkNegativeY if the Y velocity is negative. | ||||||||||||||
| 36679 | JP M,UpdateVelocity_WalkNegativeY | |||||||||||||||
| 36682 | AND %11110000 | Keep only bits 4-7. | ||||||||||||||
| 36684 | JR Z,UpdateVelocity_WalkEnd | Jump to UpdateVelocity_WalkEnd if the result is zero. | ||||||||||||||
| 36686 | LD A,2 | A=2 (move two pixels down). | ||||||||||||||
| UpdateVelocity_WalkEnd | 36688 | LD D,A | Keep the Y move in D. | |||||||||||||
| 36689 | RET | Return. | ||||||||||||||
| UpdateVelocity_WalkNegativeX | 36690 | NEG | Make the X velocity positive. | |||||||||||||
| 36692 | AND %11110000 | Keep only bits 4-7. | ||||||||||||||
| 36694 | JR Z,UpdateVelocity_WalkY | Jump to UpdateVelocity_WalkY if the result is zero. | ||||||||||||||
| 36696 | LD A,254 | A=-2 (move two pixels left). | ||||||||||||||
| 36698 | JR UpdateVelocity_WalkY | Jump to UpdateVelocity_WalkY to do the walk on the Y axis. | ||||||||||||||
| UpdateVelocity_WalkNegativeY | 36700 | NEG | Make the Y velocity positive. | |||||||||||||
| 36702 | AND %11110000 | Keep only bits 4-7. | ||||||||||||||
| 36704 | JR Z,UpdateVelocity_WalkEnd | Jump to UpdateVelocity_WalkEnd if the result is zero. | ||||||||||||||
| 36706 | LD A,254 | A=-2 (move two pixels up). | ||||||||||||||
| 36708 | JR UpdateVelocity_WalkEnd | Jump to UpdateVelocity_WalkEnd to finish the walk. | ||||||||||||||
| Prev: 36567 | Up: Map | Next: 36710 |