![]() |
Routines |
| Prev: 56828 | Up: Map | Next: 56921 |
|
Makes an object face the direction that it is moving in, and tests whether it can move that way. The direction along the X axis is used first, and then the one along the Y axis, so that an object that is moving along both axes ends up facing along the Y axis (if the velocity along that axis is not zero).
|
||||||||
|
Face along the X axis first.
|
||||||||
| SetDirectionFromVelocity | 56845 | LD A,(IX+10) | Jump to SetDirectionFromVelocity_Y if the velocity along the X axis is zero. | |||||
| 56848 | AND A | |||||||
| 56849 | JR Z,SetDirectionFromVelocity_Y | |||||||
| 56851 | LD A,64 | Face right... | ||||||
| 56853 | JP P,SetDirectionFromVelocity_X | |||||||
| 56856 | OR %10000000 | ... or face left, if the velocity is negative. | ||||||
| SetDirectionFromVelocity_X | 56858 | LD C,A | Keep the direction. | |||||
| 56859 | LD A,(IX+6) | Set the direction of the object. | ||||||
| 56862 | AND 63 | |||||||
| 56864 | OR C | |||||||
| 56865 | LD (IX+6),A | |||||||
| 56868 | LD A,(IX+11) | Stash the velocity along the Y axis, and set it to zero. | ||||||
| 56871 | PUSH AF | |||||||
| 56872 | LD (IX+11),0 | |||||||
| 56876 | CALL TestMove | Test whether the object can move that way. | ||||||
| 56879 | POP AF | Restore the velocity along the Y axis from the stack. | ||||||
| 56880 | LD (IX+11),A | |||||||
|
Then face along the Y axis.
|
||||||||
| SetDirectionFromVelocity_Y | 56883 | LD A,(IX+11) | Return if the velocity along the Y axis is zero. | |||||
| 56886 | AND A | |||||||
| 56887 | RET Z | |||||||
| 56888 | LD A,0 | Face up the screen... | ||||||
| 56890 | JP P,SetDirectionFromVelocity_Set | |||||||
| 56893 | OR %10000000 | ... or face down the screen, if the velocity is negative. | ||||||
| SetDirectionFromVelocity_Set | 56895 | LD C,A | Keep the direction. | |||||
| 56896 | LD A,(IX+6) | Set the direction of the object. | ||||||
| 56899 | AND 63 | |||||||
| 56901 | OR C | |||||||
| 56902 | LD (IX+6),A | |||||||
| 56905 | LD A,(IX+10) | Keep the velocity along the X axis, and set it to zero. | ||||||
| 56908 | PUSH AF | |||||||
| 56909 | LD (IX+10),0 | |||||||
| 56913 | CALL TestMove_Keep | Test whether the object can move that way. | ||||||
| 56916 | POP AF | Restore the velocity along the X axis from the stack. | ||||||
| 56917 | LD (IX+10),A | |||||||
| 56920 | RET | Return. | ||||||
| Prev: 56828 | Up: Map | Next: 56921 |