![]() |
Routines |
| Prev: 27638 | Up: Map | Next: 27693 |
|
Used by the routine at NewGame.
Finds the first map point whose X position is not less than the player's X position minus 96 and writes its address to CurrentObject. If there is not one then the pointer is reset to the start of the map points.
|
||||
| FindFirstObject | 27646 | LD BC,30737 | Point BC at the first map point (MapPoints). | |
| 27649 | LD HL,(24069) | Fetch the player's X position on the map (PlayerMapPosition). | ||
| 27652 | LD DE,96 | Set the furthest distance in view, 0096. | ||
| 27655 | AND A | HL=HL - DE (the left edge of the view). | ||
| 27656 | SBC HL,DE | |||
| 27658 | EX DE,HL | Exchange DE and HL. | ||
| FindFirstObject_Next | 27659 | EX DE,HL | Exchange them back so HL holds the left edge of the view again. | |
| 27660 | LD A,(BC) | Fetch the X position of the map point. | ||
| 27661 | INC BC | Move on to the Y position of the map point. | ||
| 27662 | LD D,A | Keep the X position in D. | ||
| 27663 | CALL ScaleValue_DivideByEight | Call ScaleValue_DivideByEight to convert it to map units in DE. | ||
| 27666 | EX DE,HL | Exchange DE and HL. | ||
| 27667 | AND A | HL=HL - DE (the distance from the left edge of the view). | ||
| 27668 | SBC HL,DE | |||
| 27670 | JR NC,FindFirstObject_Found | Jump to FindFirstObject_Found if the map point is not to the left of the left edge. | ||
| 27672 | INC BC | Move on to the next map point. | ||
| 27673 | INC BC | |||
| 27674 | LD HL,31958 | Point HL at the end of the map points (Sprite_Car_1, one byte past the end of MapPoints). | ||
| 27677 | AND A | HL=HL - BC. | ||
| 27678 | SBC HL,BC | |||
| 27680 | JR NZ,FindFirstObject_Next | Jump to FindFirstObject_Next if there are more map points. | ||
| 27682 | LD BC,30737 | Point BC at the first map point (MapPoints), to go back to the start. | ||
| FindFirstObject_Store | 27685 | LD (24089),BC | Write BC to CurrentObject. | |
| 27689 | RET | Return. | ||
| FindFirstObject_Found | 27690 | DEC BC | Decrease BC by one (back to the X position). | |
| 27691 | JR FindFirstObject_Store | Jump to FindFirstObject_Store. | ||
| Prev: 27638 | Up: Map | Next: 27693 |