![]() |
Routines |
| Prev: 96EF | Up: Map | Next: 979B |
|
Used by the routine at RunFrame.
Called every frame. Once in every 40 frames, on average, it creates a pickup (see CreatePickup). It then goes through the spawn points of the level, which have seven bytes each, counting down the delay of each one and, when the delay has run out, trying to create the entity the spawn point makes.
|
||||
| UpdateSpawnPoints | 9748 | LD A,($5F9A) | Fetch the low byte of the random seed from RandomNumber_Seed. | |
| 974B | AND %00111111 | Keep only bits 0-5. | ||
| 974D | CALL Z,CreatePickup | Call CreatePickup to create a pickup if they are all zero. | ||
| 9750 | LD A,($BD73) | Fetch the number of spawn points from ObjectCount. | ||
| 9753 | AND A | Test it. | ||
| 9754 | RET Z | Return if there are none. | ||
| 9755 | LD B,A | Set the spawn point counter in B. | ||
| 9756 | LD IY,$BD74 | Point IY at the first spawn point at BD74. | ||
| UpdateSpawnPoints_Loop | 975A | PUSH BC | Stash the spawn point counter on the stack. | |
| 975B | PUSH IY | Stash the address of the spawn point on the stack. | ||
| 975D | LD A,(IY+$05) | Fetch the delay of the spawn point. | ||
| 9760 | AND A | Test it. | ||
| 9761 | JR Z,UpdateSpawnPoints_Create | Jump to UpdateSpawnPoints_Create if it has run out. | ||
| 9763 | DEC A | Decrease the delay by one. | ||
| 9764 | LD (IY+$05),A | Store it. | ||
| 9767 | JR UpdateSpawnPoints_Next | Jump to UpdateSpawnPoints_Next to go on to the next spawn point. | ||
| UpdateSpawnPoints_Create | 9769 | LD E,(IY+$06) | Fetch the kind of the spawn point. | |
| 976C | LD A,E | Copy it into A. | ||
| 976D | CP $03 | Jump to UpdateSpawnPoints_Next if it is 03, which makes nothing. | ||
| 976F | JR Z,UpdateSpawnPoints_Next | |||
| 9771 | ADD A,A | Multiply it by seven... | ||
| 9772 | ADD A,A | |||
| 9773 | ADD A,A | |||
| 9774 | SUB E | ...by multiplying by eight and subtracting the kind. | ||
| 9775 | LD E,A | Move it into E. | ||
| 9776 | LD D,$00 | Clear D. | ||
| 9778 | LD IY,$988B | Point IY at SpawnKinds. | ||
| 977C | ADD IY,DE | Add the offset of the kind to find its entry. | ||
| 977E | LD L,(IY+$00) | Fetch the low byte of the address of the first entity slot of the kind. | ||
| 9781 | LD H,(IY+$01) | Fetch the high byte of the address of the first entity slot of the kind. | ||
| 9784 | PUSH HL | Copy it into IX (using the stack). | ||
| 9785 | POP IX | |||
| 9787 | LD B,(IY+$02) | Fetch the number of entity slots of the kind into B. | ||
| 978A | CALL FindFreeEntity | Call FindFreeEntity to find a free slot. | ||
| 978D | JP Z,CreateSpawnedEntity | Jump to CreateSpawnedEntity if there is one, to create the entity. | ||
|
This entry point is used by the routine at CreateSpawnedEntity.
|
||||
| UpdateSpawnPoints_Next | 9790 | POP IY | Restore the address of the spawn point from the stack. | |
|
This entry point is used by the routines at CreateSpawnedEntity, CreateShot, CreateSpawnedEntity_Creature and CreateSpawnedEntity_GrowingBubble.
|
||||
| UpdateSpawnPoints_Advance | 9792 | LD BC,$0007 | BC is 07 the size of a spawn point. | |
| 9795 | ADD IY,BC | Move onto the next spawn point. | ||
| 9797 | POP BC | Restore the spawn point counter from the stack. | ||
| 9798 | DJNZ UpdateSpawnPoints_Loop | Decrease the spawn point counter by one and jump back to UpdateSpawnPoints_Loop until all of the spawn points have been done. | ||
| 979A | RET | Return. | ||
| Prev: 96EF | Up: Map | Next: 979B |