Prev: 35180 Up: Map Next: 35335
35228: Handler: Flight Path
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 35228 LD B,1 B=1.
35230 LD HL,61439 Set bit 0 of *61439.
35233 SET 0,(HL)
35235 CALL 32853 Call 32853.
35238 LD A,(61436) A=*61436.
35241 AND %00001111 Keep only bits 0-3.
35243 CP 8 Jump to Handler_FlightPath if A is not equal to 8.
35245 JR NZ,Handler_FlightPath
35247 LD BC,(30721) BC=*Flightpath_X_MovementVector.
35251 LD DE,(30723) DE=*Flightpath_Y_MovementVector.
35255 LD HL,(30725) HL=*CurrentLocationCoordinates.
35258 LD A,C Compare C and B to determine the movement direction. Jump to FlightPath_NegativeDirection if C is lower than B.
35259 CP B
35260 JR C,FlightPath_NegativeDirection
Handle movement in positive X direction.
35262 SUB B C-=B.
35263 LD C,A
Move in Y direction.
35264 LD A,E L+=E.
35265 ADD A,L
35266 LD L,A
35267 LD A,(30730) Load *Flightpath_Maximum_Y_Coordinate into B.
35270 LD B,A
Compare with remaining X movement.
35271 CP C Jump to FlightPath_CheckArrived if *Flightpath_Maximum_Y_Coordinate is lower than C.
35272 JR C,FlightPath_CheckArrived
35274 SUB C Adjust Y co-ordinate.
35275 LD B,A
35276 LD A,(30729) Load *Flightpath_Minimum_Y_Coordinate into C.
35279 LD C,A
35280 LD A,(30724) Adjust X co-ordinate.
35283 ADD A,H
35284 LD H,A
35285 JR FlightPath_CheckArrived Jump to FlightPath_CheckArrived.
Handle movement in negative X direction.
FlightPath_NegativeDirection 35287 LD A,B B-=C (remaining X movement).
35288 SUB C
35289 LD B,A
35290 LD A,D Move in Y direction.
35291 ADD A,H
35292 LD H,A
35293 LD A,(30729) Load *Flightpath_Minimum_Y_Coordinate into C.
35296 LD C,A
35297 CP B Jump to FlightPath_CheckArrived if C is lower than B.
35298 JR C,FlightPath_CheckArrived
35300 SUB B Adjust Y co-ordinate.
35301 LD C,A
35302 LD A,(30730) Load *Flightpath_Maximum_Y_Coordinate into B.
35305 LD B,A
35306 LD A,(30723) Adjust X co-ordinate.
35309 ADD A,L
35310 LD L,A
35311 JR FlightPath_CheckArrived Jump to FlightPath_CheckArrived.
Update position and check if destination reached.
FlightPath_CheckArrived 35313 LD (30725),HL Write new X/ Y co-ordinates to *CurrentLocationCoordinates.
35316 LD (30721),BC Write updated movement vector to *Flightpath_X_MovementVector.
35320 AND A Compare current position with destination.
35321 LD DE,(30727)
35325 SBC HL,DE
35327 JR NZ,Handler_FlightPath Jump to Handler_FlightPath until destination is reached.
35329 LD HL,61435 Reset bit 1 ("Flightpath Complete") of *GameState_2.
35332 RES 1,(HL)
35334 RET Return.
Prev: 35180 Up: Map Next: 35335