![]() |
Routines |
| Prev: 894F | Up: Map | Next: 899C |
|
Used by the routine at Handler_LocationChoice.
|
||||
| CalculateFlightPath | 896C | LD HL,($7805) | HL=*CurrentLocationCoordinates. | |
| 896F | LD DE,($7807) | DE=*DestinationLocationCoordinates. | ||
|
Calculate X movement vector.
|
||||
| 8973 | LD A,L | A=current X - destination X. | ||
| 8974 | SUB E | |||
| 8975 | LD E,$FF | Assume moving left (negative X direction). | ||
| 8977 | JP P,StoreAbsolute_X_Difference | If the result is positive, skip negation and jump to StoreAbsolute_X_Difference. | ||
| 897A | NEG | Negate A if it's negative. | ||
| 897C | LD E,$01 | Moving right (positive X direction). | ||
| StoreAbsolute_X_Difference | 897E | LD C,A | Store absolute X difference in C. | |
|
Calculate Y movement vector.
|
||||
| 897F | LD A,H | A=current Y - destination Y. | ||
| 8980 | SUB D | |||
| 8981 | LD D,$FF | Assume moving up (negative Y direction). | ||
| 8983 | JR NC,StoreAbsolute_Y_Difference | If result is non-negative, skip negation and jump to StoreAbsolute_Y_Difference. | ||
| 8985 | NEG | Negate A if it's negative. | ||
| 8987 | LD D,$01 | Moving down (positive Y direction). | ||
| StoreAbsolute_Y_Difference | 8989 | LD B,A | Store absolute Y difference in B. | |
|
Store calculated vectors and flags.
|
||||
| 898A | LD ($7801),BC | Write BC to *Flightpath_X_MovementVector. | ||
| 898E | LD ($7809),BC | Write BC to *Flightpath_Minimum_Y_Coordinate. | ||
| 8992 | LD ($7803),DE | Write DE to *Flightpath_Y_MovementVector. | ||
| 8996 | LD HL,$EFFB | Set bit 1 ("Flightpath In-Progress") of *GameState_2. | ||
| 8999 | SET 1,(HL) | |||
| 899B | RET | Return. | ||
| Prev: 894F | Up: Map | Next: 899C |