Prev: 34706 Up: Map Next: 34806
34735: Update Enemy Spawning
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 34735 LD A,(36395) Fetch the number of enemies that are alive from 36395.
34738 CP 8 Return if there are eight of them.
34740 RET NC
34741 LD A,(34805) Fetch the bonus timer from 34805.
34744 AND A Test it.
34745 JR NZ,UpdateEnemySpawning_Timer Jump to UpdateEnemySpawning_Timer if the timer is running.
34747 LD A,(39883) Fetch the random seed.
34750 CP 106 Jump to UpdateEnemySpawning_Countdown if it is not the same.
34752 JR NZ,UpdateEnemySpawning_Countdown
34754 LD A,(39884) Fetch the second byte of the seed.
34757 AND %00000011 Test the bottom two bits.
34759 JR NZ,UpdateEnemySpawning_Countdown Jump to UpdateEnemySpawning_Countdown if they are not zero.
34761 OR %10000000 Set bit 7 of A, which is zero.
34763 LD (34805),A Start the bonus timer.
34766 JR UpdateEnemySpawning_Countdown Jump to UpdateEnemySpawning_Countdown.
UpdateEnemySpawning_Timer 34768 DEC A Count the bonus timer down.
34769 LD (34805),A
UpdateEnemySpawning_Countdown 34772 LD A,(34704) Count down the spawn timer in 34704.
34775 DEC A
34776 LD (34704),A
34779 CP 7 Jump to SpawnSpecialEnemy if it is 7.
34781 JP Z,SpawnSpecialEnemy
34784 AND A Return if the countdown has not reached zero.
34785 RET NZ
34786 LD A,8 Restart the countdown at eight.
34788 LD (34704),A
This entry point is used by the routine at UpdateEnemies.
UpdateEnemySpawning_Spawn 34791 LD A,(34705) Fetch the number of slots to search from 34705.
34794 LD IX,39284 Use the first enemy slot.
34798 CALL FindFreeSlot Search for a free enemy slot.
34801 JP Z,SpawnEnemy Spawn an enemy if there is a free slot.
34804 RET Return.
34805 DEFB 0
Prev: 34706 Up: Map Next: 34806