![]() |
Routines |
| Prev: 64538 | Up: Map | Next: 64694 |
|
Used by the routine at RunHandlers.
|
|||||||||||||||||||
|
Are vehicles permitted to be spawned on this level?
|
|||||||||||||||||||
| Handler_Vehicle | 64569 | LD A,(54273) | Return if vehicle spawning is set to be off (*VehicleCounter is equal to 254). | ||||||||||||||||
| 64572 | CP 254 | ||||||||||||||||||
| 64574 | RET Z | ||||||||||||||||||
|
Just return if a a vehicle is already being displayed.
|
|||||||||||||||||||
| 64575 | CP 255 | Jump to Handler_Vehicle_Movement if a vehicle is already active (*VehicleCounter is equal to 255). | |||||||||||||||||
| 64577 | JR Z,Handler_Vehicle_Movement | ||||||||||||||||||
|
Else the counter is a counter, so count it down.
|
|||||||||||||||||||
| 64579 | DEC A | Decrease *VehicleCounter by one. | |||||||||||||||||
| 64580 | LD (54273),A | ||||||||||||||||||
| 64583 | RET NZ | Return if *VehicleCounter is still in progress. | |||||||||||||||||
|
Else the countdown is complete so set the counter/ state that a vehicle is spawned and spawn a random vehicle!
|
|||||||||||||||||||
| 64584 | LD A,255 | Write 255 to *VehicleCounter. | |||||||||||||||||
| 64586 | LD (54273),A | ||||||||||||||||||
|
Spawn a new vehicle:
There are four vehicle types.
|
|||||||||||||||||||
| 64589 | CALL RandomNumber | Get a random number between 0-3. | |||||||||||||||||
| 64592 | AND %00000011 | ||||||||||||||||||
| 64594 | LD (54274),A | Write A to *VehicleType. | |||||||||||||||||
|
Randomly bring the vehicle in from either the left or right hand side of the play area.
|
|||||||||||||||||||
| 64597 | CALL RandomNumber | Get a random number which is either zero or one. | |||||||||||||||||
| 64600 | AND %00000001 | ||||||||||||||||||
| 64602 | JR NZ,Handler_SpawnVehicleRight | Jump to Handler_SpawnVehicleRight if the random number is one. | |||||||||||||||||
|
Vehicle moves from left-to-right.
|
|||||||||||||||||||
| 64604 | LD A,20 | Write 20 to *VehicleYPosition. | |||||||||||||||||
| 64606 | LD (54276),A | ||||||||||||||||||
| 64609 | LD A,250 | Write 250 to *VehicleXPosition. | |||||||||||||||||
| 64611 | LD (54275),A | ||||||||||||||||||
| 64614 | JR Handler_Vehicle_Movement | Jump to Handler_Vehicle_Movement. | |||||||||||||||||
|
Bit 7 signifies that this vehicle moves from right-to-left.
|
|||||||||||||||||||
| Handler_SpawnVehicleRight | 64616 | LD A,148 | Write 148 (20 + bit 7 set) to *VehicleYPosition. | ||||||||||||||||
| 64618 | LD (54276),A | ||||||||||||||||||
| 64621 | LD A,32 | Write 32 to *VehicleXPosition. | |||||||||||||||||
| 64623 | LD (54275),A | ||||||||||||||||||
| Handler_Vehicle_Movement | 64626 | LD A,(54276) | A=*VehicleYPosition. | ||||||||||||||||
| 64629 | CP 128 | Jump to Handler_MoveVehicle_RightToLeft if A is higher than 128 (if bit 7 is set). | |||||||||||||||||
| 64631 | JR NC,Handler_MoveVehicle_RightToLeft | ||||||||||||||||||
| 64633 | LD B,A | B=vehicle Y position. | |||||||||||||||||
|
Handles moving the vehicle from the left-to-right hand side of the play area.
|
|||||||||||||||||||
| 64634 | LD A,(54275) | A=*VehicleXPosition. | |||||||||||||||||
| 64637 | INC A | Increment A by one. | |||||||||||||||||
| Handler_Vehicle_SetXPos | 64638 | LD (54275),A | Write A to *VehicleXPosition. | ||||||||||||||||
|
Check if the vehicle is off-screen.
|
|||||||||||||||||||
| 64641 | CP 32 | Jump to Handler_Vehicle_SetCountdown if A is equal to 32. | |||||||||||||||||
| 64643 | JR Z,Handler_Vehicle_SetCountdown | ||||||||||||||||||
| 64645 | LD C,A | C=vehicle X position. | |||||||||||||||||
|
Has the vehicle been destroyed?
|
|||||||||||||||||||
| 64646 | LD A,(54274) | A=*VehicleType. | |||||||||||||||||
| 64649 | CP 3 | Return if the vehicle has been destroyed (*VehicleType is equal to 3). | |||||||||||||||||
| 64651 | RET Z | ||||||||||||||||||
| 64652 | ADD A,A | A=59+(A*2).
|
|||||||||||||||||
| 64653 | ADD A,59 | ||||||||||||||||||
| 64655 | CALL PrintSprite | Call PrintSprite. | |||||||||||||||||
| 64658 | XOR A | Write 0 to *Flag_Orientation. | |||||||||||||||||
| 64659 | LD (53831),A | ||||||||||||||||||
| 64662 | RET | Return. | |||||||||||||||||
|
Handles moving the vehicle from the right-to-left hand side of the play area.
|
|||||||||||||||||||
| Handler_MoveVehicle_RightToLeft | 64663 | AND %01111111 | Strip off the right-to-left flag. | ||||||||||||||||
| 64665 | LD B,A | B=vehicle Y position. | |||||||||||||||||
| 64666 | LD A,1 | Write 1 to *Flag_Orientation. | |||||||||||||||||
| 64668 | LD (53831),A | ||||||||||||||||||
| 64671 | LD A,(54275) | A=*VehicleXPosition. | |||||||||||||||||
| 64674 | DEC A | Decrease A by one. | |||||||||||||||||
|
Check if the vehicle is off-screen.
|
|||||||||||||||||||
| 64675 | CP 250 | Jump to Handler_Vehicle_SetXPos if A is not equal to 250. | |||||||||||||||||
| 64677 | JR NZ,Handler_Vehicle_SetXPos | ||||||||||||||||||
|
Initialise a new countdown.
|
|||||||||||||||||||
| Handler_Vehicle_SetCountdown | 64679 | CALL RandomNumber | Get a random number between 8-23. | ||||||||||||||||
| 64682 | AND %00001111 | ||||||||||||||||||
| 64684 | ADD A,8 | ||||||||||||||||||
| 64686 | LD (54273),A | Write the random number to *VehicleCounter. | |||||||||||||||||
| 64689 | XOR A | Write 0 to *Flag_Orientation. | |||||||||||||||||
| 64690 | LD (53831),A | ||||||||||||||||||
| 64693 | RET | Return. | |||||||||||||||||
| Prev: 64538 | Up: Map | Next: 64694 |