![]() |
Routines |
| Prev: 8792 | Up: Map | Next: 87F6 |
|
Used by the routine at RunLife.
Called once a frame to decide whether to start another enemy. A new enemy is started every eight calls, with a special enemy started part of the way through the countdown, as long as fewer than eight enemies are alive.
|
||||
| UpdateEnemySpawning | 87AF | LD A,($8E2B) | Fetch the number of enemies that are alive from 8E2B. | |
| 87B2 | CP $08 | Return if there are eight of them. | ||
| 87B4 | RET NC | |||
| 87B5 | LD A,($87F5) | Fetch the bonus timer from 87F5. | ||
| 87B8 | AND A | Test it. | ||
| 87B9 | JR NZ,UpdateEnemySpawning_Timer | Jump to UpdateEnemySpawning_Timer if the timer is running. | ||
| 87BB | LD A,($9BCB) | Fetch the random seed. | ||
| 87BE | CP $6A | Jump to UpdateEnemySpawning_Countdown if it is not the same. | ||
| 87C0 | JR NZ,UpdateEnemySpawning_Countdown | |||
| 87C2 | LD A,($9BCC) | Fetch the second byte of the seed. | ||
| 87C5 | AND %00000011 | Test the bottom two bits. | ||
| 87C7 | JR NZ,UpdateEnemySpawning_Countdown | Jump to UpdateEnemySpawning_Countdown if they are not zero. | ||
| 87C9 | OR %10000000 | Set bit 7 of A, which is zero. | ||
| 87CB | LD ($87F5),A | Start the bonus timer. | ||
| 87CE | JR UpdateEnemySpawning_Countdown | Jump to UpdateEnemySpawning_Countdown. | ||
| UpdateEnemySpawning_Timer | 87D0 | DEC A | Count the bonus timer down. | |
| 87D1 | LD ($87F5),A | |||
| UpdateEnemySpawning_Countdown | 87D4 | LD A,($8790) | Count down the spawn timer in 8790. | |
| 87D7 | DEC A | |||
| 87D8 | LD ($8790),A | |||
| 87DB | CP $07 | Jump to SpawnSpecialEnemy if it is 07. | ||
| 87DD | JP Z,SpawnSpecialEnemy | |||
| 87E0 | AND A | Return if the countdown has not reached zero. | ||
| 87E1 | RET NZ | |||
| 87E2 | LD A,$08 | Restart the countdown at eight. | ||
| 87E4 | LD ($8790),A | |||
|
This entry point is used by the routine at UpdateEnemies.
|
||||
| UpdateEnemySpawning_Spawn | 87E7 | LD A,($8791) | Fetch the number of slots to search from 8791. | |
| 87EA | LD IX,$9974 | Use the first enemy slot. | ||
| 87EE | CALL FindFreeSlot | Search for a free enemy slot. | ||
| 87F1 | JP Z,SpawnEnemy | Spawn an enemy if there is a free slot. | ||
| 87F4 | RET | Return. | ||
| 87F5 | DEFB $00 | |||
| Prev: 8792 | Up: Map | Next: 87F6 |