![]() |
Routines |
| Prev: 28557 | Up: Map | Next: 28802 |
|
Used by the routine at Handler_Cars.
Handles a car driving left across the screen. When it reaches the left boundary it reinitialises from the right edge. Speed is fixed at 1.
|
||||
| Handler_CarType3 | 28712 | LD IX,56008 | IX=Sprite02_3Wide_X_Position. | |
| 28716 | LD HL,29195 | HL=CarSpeed. | ||
| 28719 | LD (HL),1 | Write 1 to *HL (fixed speed of 1). | ||
|
If the room is being initialised, set up the car.
|
||||
| 28721 | LD A,(24507) | Jump to Handler_CarType3_Initialise if *RespawnFlag is set. | ||
| 28724 | OR A | |||
| 28725 | JR NZ,Handler_CarType3_Initialise | |||
|
If the car crash timer is active, handle the crash animation.
|
||||
| 28727 | LD A,(29192) | Jump to Handler_Car_Type1_0 if *CarCrashTimer is active. | ||
| 28730 | OR A | |||
| 28731 | JP NZ,Handler_Car_Type1_0 | |||
|
Check which road the car is on.
|
||||
| 28734 | LD A,(IX+1) | A=*IX+1 (car Y position). | ||
| 28737 | CP 144 | Jump to Handler_CarType3_DriveRight if the car is on the upper road. | ||
| 28739 | JR Z,Handler_CarType3_DriveRight | |||
|
Car is on the lower road — driving left.
|
||||
| 28741 | LD A,(IX+0) | A=*IX+0 (car X position). | ||
| 28744 | SUB (HL) | A-=*HL (subtract speed). | ||
| 28745 | JR C,Handler_CarType3_Initialise | Jump to Handler_CarType3_Initialise if the result underflowed (reinitialise). | ||
| 28747 | JP Handler_CarType2_UpdateLeft | Jump to Handler_CarType2_UpdateLeft. | ||
|
Initialise car type 3 — pick a random colour (rejecting 1) and start from the right edge.
|
||||
| Handler_CarType3_Initialise | 28750 | PUSH HL | Stash HL on the stack. | |
| 28751 | CALL GenerateRandomNumber | Call GenerateRandomNumber. | ||
| 28754 | POP HL | Restore HL from the stack. | ||
| 28755 | AND %00000011 | Keep only bits 0-1 (random colour from BLACK,BLUE,RED,MAGENTA). | ||
| 28757 | CP 1 | Jump to Handler_CarType3_Initialise if the colour is BLUE (pick again). | ||
| 28759 | JR Z,Handler_CarType3_Initialise | |||
| 28761 | LD (IX+2),A | Write A to *IX+2 (front colour). | ||
| 28764 | LD (IX+6),A | Write A to *IX+6 (rear colour). | ||
| 28767 | XOR A | A=0 (start from the left edge). | ||
| 28768 | JP Handler_CarType2_UpdateRight | Jump to Handler_CarType2_UpdateRight. | ||
|
Car is on the upper road — driving right.
|
||||
| Handler_CarType3_DriveRight | 28771 | LD A,(IX+0) | A=*IX+0 (car X position). | |
| 28774 | ADD A,(HL) | A+=*HL (add speed). | ||
| 28775 | CP 40 | Jump to Handler_CarType3_Restart if past the boundary. | ||
| 28777 | JR NC,Handler_CarType3_Restart | |||
| 28779 | JP Handler_CarType2_UpdateRight | Jump to Handler_CarType2_UpdateRight. | ||
|
Pick a new bright colour and restart from 40.
|
||||
| Handler_CarType3_Restart | 28782 | PUSH HL | Stash HL on the stack. | |
| 28783 | CALL GenerateRandomNumber | Call GenerateRandomNumber. | ||
| 28786 | POP HL | Restore HL from the stack. | ||
| 28787 | AND %00000011 | Keep only bits 0-1. | ||
| 28789 | ADD A,4 | A+=4 (bright colour range). | ||
| 28791 | LD (IX+2),A | Write A to *IX+2 (front colour). | ||
| 28794 | LD (IX+6),A | Write A to *IX+6 (rear colour). | ||
| 28797 | LD A,40 | A=40. | ||
| 28799 | JP Handler_CarType2_UpdateLeft | Jump to Handler_CarType2_UpdateLeft. | ||
| Prev: 28557 | Up: Map | Next: 28802 |