Routines |
Prev: F10E | Up: Map | Next: F2CA |
Used by the routine at RunHandlers.
|
||||
Just return if the number of active helicopters is already at the maximum amount for this level.
|
||||
Handler_SpawnHelicopters | F28B | LD A,($D212) | Return if *NumberActiveHelicopters is equal to *MaxHelicopterCount. | |
F28E | LD B,A | |||
F28F | LD A,($D3F5) | |||
F292 | CP B | |||
F293 | RET Z | |||
Add a hint of randomness to whether we proceed or not. Roughly 50% chance.
|
||||
F294 | CALL RandomNumber | A=random number between 00-FF. | ||
F297 | CP $80 | Return if A is higher than 80. | ||
F299 | RET NC | |||
Loop to find an empty slot.
|
||||
F29A | LD HL,$D292 | HL=D292 (Table_Helicopters-03). | ||
Handler_SpawnHelicopters_FindSlot | F29D | INC HL | Move the table pointer to the next helicopter table data. | |
F29E | INC HL | |||
F29F | INC HL | |||
F2A0 | LD A,(HL) | Jump to Handler_SpawnHelicopters_FindSlot if this helicopter is already active. | ||
F2A1 | AND A | |||
F2A2 | JR NZ,Handler_SpawnHelicopters_FindSlot | |||
50/50 chance of jumping to Handler_SpawnForegroundHelicopter.
|
||||
F2A4 | CALL RandomNumber | Get a random number of either zero or one. | ||
F2A7 | AND %00000001 | |||
F2A9 | JR Z,Handler_SpawnForegroundHelicopter | Jump to Handler_SpawnForegroundHelicopter if the result is zero. | ||
Creates a background helicopter.
|
||||
F2AB | LD (HL),$40 | Write 40 (background) to helicopter state. | ||
F2AD | INC HL | Increment the helicopter table pointer by one. | ||
F2AE | LD (HL),$FC | Write FC to helicopter X position. | ||
F2B0 | JR Handler_Helicopter_SetYPos | Jump to Handler_Helicopter_SetYPos. | ||
Creates a foreground helicopter.
|
||||
Handler_SpawnForegroundHelicopter | F2B2 | LD (HL),$80 | Write 80 (foreground) to helicopter state. | |
F2B4 | INC HL | Increment the helicopter table pointer by one. | ||
F2B5 | LD (HL),$24 | Write 24 to helicopter X position. | ||
Handler_Helicopter_SetYPos | F2B7 | INC HL | Increment the helicopter table pointer by one. | |
F2B8 | LD (HL),$03 | Write 03 to helicopter Y position. | ||
25% chance of jumping to Helicopter_Update_Count.
|
||||
F2BA | CALL RandomNumber | Get a random number between 0-3. | ||
F2BD | AND %00000011 | |||
F2BF | JR Z,Helicopter_Update_Count | Jump to Helicopter_Update_Count if the random number is 0. | ||
F2C1 | LD (HL),A | Write the random number to helicopter Y position. | ||
Keep track of the number of active helicopters.
|
||||
Helicopter_Update_Count | F2C2 | LD A,($D3F5) | Increment *NumberActiveHelicopters by one. | |
F2C5 | INC A | |||
F2C6 | LD ($D3F5),A | |||
F2C9 | RET | Return. |
Prev: F10E | Up: Map | Next: F2CA |