Routines |
Prev: 896C | Up: Map | Next: 8A07 |
Used by the routine at GameInitialise.
|
||||
This routine uses Bresenham's line algorithm to plot a point between the source and destination co-ordinates to show Trashman travelling from one location to another.
|
||||
Handler_FlightPath | 899C | LD B,$01 | B=01. | |
899E | LD HL,$EFFF | Set bit 0 of *EFFF. | ||
89A1 | SET 0,(HL) | |||
89A3 | CALL $8055 | Call 8055. | ||
89A6 | LD A,($EFFC) | A=*EFFC. | ||
89A9 | AND %00001111 | Keep only bits 0-3. | ||
89AB | CP $08 | Jump to Handler_FlightPath if A is not equal to 08. | ||
89AD | JR NZ,Handler_FlightPath | |||
89AF | LD BC,($7801) | BC=*Flightpath_X_MovementVector. | ||
89B3 | LD DE,($7803) | DE=*Flightpath_Y_MovementVector. | ||
89B7 | LD HL,($7805) | HL=*CurrentLocationCoordinates. | ||
89BA | LD A,C | Compare C and B to determine the movement direction. Jump to FlightPath_NegativeDirection if C is lower than B. | ||
89BB | CP B | |||
89BC | JR C,FlightPath_NegativeDirection | |||
Handle movement in positive X direction.
|
||||
89BE | SUB B | C-=B. | ||
89BF | LD C,A | |||
Move in Y direction.
|
||||
89C0 | LD A,E | L+=E. | ||
89C1 | ADD A,L | |||
89C2 | LD L,A | |||
89C3 | LD A,($780A) | Load *Flightpath_Maximum_Y_Coordinate into B. | ||
89C6 | LD B,A | |||
Compare with remaining X movement.
|
||||
89C7 | CP C | Jump to FlightPath_CheckArrived if *Flightpath_Maximum_Y_Coordinate is lower than C. | ||
89C8 | JR C,FlightPath_CheckArrived | |||
89CA | SUB C | Adjust Y co-ordinate. | ||
89CB | LD B,A | |||
89CC | LD A,($7809) | Load *Flightpath_Minimum_Y_Coordinate into C. | ||
89CF | LD C,A | |||
89D0 | LD A,($7804) | Adjust X co-ordinate. | ||
89D3 | ADD A,H | |||
89D4 | LD H,A | |||
89D5 | JR FlightPath_CheckArrived | Jump to FlightPath_CheckArrived. | ||
Handle movement in negative X direction.
|
||||
FlightPath_NegativeDirection | 89D7 | LD A,B | B-=C (remaining X movement). | |
89D8 | SUB C | |||
89D9 | LD B,A | |||
89DA | LD A,D | Move in Y direction. | ||
89DB | ADD A,H | |||
89DC | LD H,A | |||
89DD | LD A,($7809) | Load *Flightpath_Minimum_Y_Coordinate into C. | ||
89E0 | LD C,A | |||
89E1 | CP B | Jump to FlightPath_CheckArrived if C is lower than B. | ||
89E2 | JR C,FlightPath_CheckArrived | |||
89E4 | SUB B | Adjust Y co-ordinate. | ||
89E5 | LD C,A | |||
89E6 | LD A,($780A) | Load *Flightpath_Maximum_Y_Coordinate into B. | ||
89E9 | LD B,A | |||
89EA | LD A,($7803) | Adjust X co-ordinate. | ||
89ED | ADD A,L | |||
89EE | LD L,A | |||
89EF | JR FlightPath_CheckArrived | Jump to FlightPath_CheckArrived. | ||
Update position and check if destination reached.
|
||||
FlightPath_CheckArrived | 89F1 | LD ($7805),HL | Write new X/ Y co-ordinates to *CurrentLocationCoordinates. | |
89F4 | LD ($7801),BC | Write updated movement vector to *Flightpath_X_MovementVector. | ||
89F8 | AND A | Compare current position with destination. | ||
89F9 | LD DE,($7807) | |||
89FD | SBC HL,DE | |||
89FF | JR NZ,Handler_FlightPath | Jump to Handler_FlightPath until destination is reached. | ||
8A01 | LD HL,$EFFB | Reset bit 1 ("Flightpath Complete") of *GameState_2. | ||
8A04 | RES 1,(HL) | |||
8A06 | RET | Return. |
Prev: 896C | Up: Map | Next: 8A07 |