![]() |
Routines |
| Prev: 27646 | Up: Map | Next: 27778 |
|
Used by the routine at HandlerAccelerate.
Moves the pointer at CurrentObject so that it still points to the first map point which is within 96 map units of the player's X position.
|
||||
| UpdateCurrentObject | 27693 | XOR A | Write 0 to Flag_PointerMovedBack (it is set to 1 if the pointer moves back). | |
| 27694 | LD (24091),A | |||
| 27697 | LD BC,(24089) | Fetch the pointer to the first map point in view (CurrentObject). | ||
|
Look at the earlier map points to see if the pointer has to move back.
|
||||
| UpdateCurrentObject_Back | 27701 | DEC BC | Decrease BC by three (to the previous map point). | |
| 27702 | DEC BC | |||
| 27703 | DEC BC | |||
| 27704 | LD A,(BC) | Fetch the X position of the map point. | ||
| 27705 | LD D,A | Keep the X position in D. | ||
| 27706 | CALL ScaleValue_DivideByEight | Call ScaleValue_DivideByEight to convert it to map units in DE. | ||
| 27709 | CALL GetMapDistance | Find how far the map point is from the player using GetMapDistance. | ||
| 27712 | JR NC,UpdateCurrentObject_Moved | Jump to UpdateCurrentObject_Moved if the map point is not close enough. | ||
| 27714 | LD A,1 | Write 1 to Flag_PointerMovedBack. | ||
| 27716 | LD (24091),A | |||
| 27719 | JR UpdateCurrentObject_Back | Jump to UpdateCurrentObject_Back. | ||
| UpdateCurrentObject_Moved | 27721 | LD A,(24091) | Fetch the flag which says whether the pointer moved back (Flag_PointerMovedBack). | |
| 27724 | AND A | Jump to UpdateCurrentObject_Forward if the pointer did not move back. | ||
| 27725 | JR Z,UpdateCurrentObject_Forward | |||
| 27727 | INC BC | Increment BC by three (to the first map point which is close enough). | ||
| 27728 | INC BC | |||
| 27729 | INC BC | |||
| UpdateCurrentObject_Store | 27730 | LD (24089),BC | Write BC to CurrentObject. | |
| 27734 | RET | Return. | ||
|
Check whether the pointer has to move forward.
|
||||
| UpdateCurrentObject_Forward | 27735 | LD BC,(24089) | Fetch the pointer to the first map point in view (CurrentObject). | |
| 27739 | LD A,(BC) | Fetch the X position of the map point. | ||
| 27740 | LD D,A | Keep the X position in D. | ||
| 27741 | CALL ScaleValue_DivideByEight | Call ScaleValue_DivideByEight to convert it to map units in DE. | ||
| 27744 | CALL GetMapDistance | Find how far the map point is from the player using GetMapDistance. | ||
| 27747 | RET C | Return if the map point is close enough. | ||
| UpdateCurrentObject_Closer | 27748 | LD (24092),HL | Write the distance to PreviousDistance. | |
| UpdateCurrentObject_NextPoint | 27751 | INC BC | Increment BC by three (to the next map point). | |
| 27752 | INC BC | |||
| 27753 | INC BC | |||
| 27754 | LD A,(BC) | Fetch the X position of the map point. | ||
| 27755 | LD D,A | Keep the X position in D. | ||
| 27756 | CALL ScaleValue_DivideByEight | Call ScaleValue_DivideByEight to convert it to map units in DE. | ||
| 27759 | CALL GetMapDistance | Find how far the map point is from the player using GetMapDistance. | ||
| 27762 | JR C,UpdateCurrentObject_Store | Jump to UpdateCurrentObject_Store if the map point is close enough. | ||
| 27764 | PUSH HL | Stash the distance on the stack. | ||
| 27765 | LD DE,(24092) | Fetch the previous distance from PreviousDistance. | ||
| 27769 | AND A | HL=HL - DE. | ||
| 27770 | SBC HL,DE | |||
| 27772 | POP HL | Restore the distance (HL) from the stack. | ||
| 27773 | JR Z,UpdateCurrentObject_NextPoint | Jump to UpdateCurrentObject_NextPoint if the distance is the same as before. | ||
| 27775 | JR C,UpdateCurrentObject_Closer | Jump to UpdateCurrentObject_Closer if the map point is nearer than the previous one. | ||
| 27777 | RET | Return. | ||
| Prev: 27646 | Up: Map | Next: 27778 |