![]() |
Routines |
| Prev: 57347 | Up: Map | Next: 57782 |
|
Used by the routine at Stage_Next_Wave.
Reads three spawn-count bytes from HL (slots 16 32 48) and populates the entity list at *Entity_List_Working_Pointer with entities via Spawn_Wave_Enemies_Populate_Slot. Each record has a random screen position and a slot-typed variant; Draw_Wide_Entity_Sprite spawns each entity. Terminates the list with 53668 and updates *Entity_List_Write_Pointer.
|
||||
| Spawn_Wave_Enemies | 57634 | LD DE,(50441) | DE=*Entity_List_Write_Pointer (current entity list write pointer). | |
| 57638 | LD (50445),DE | Copy DE to *Entity_List_Working_Pointer and *Entity_List_Snapshot. | ||
| 57642 | LD (50443),DE | |||
| 57646 | LD C,16 | Call Spawn_Wave_Enemies_Populate_Slot with enemy slot 16. | ||
| 57648 | CALL Spawn_Wave_Enemies_Populate_Slot | |||
| 57651 | LD C,32 | Call Spawn_Wave_Enemies_Populate_Slot with enemy slot 32. | ||
| 57653 | CALL Spawn_Wave_Enemies_Populate_Slot | |||
| 57656 | LD C,48 | Call Spawn_Wave_Enemies_Populate_Slot with enemy slot 48. | ||
| 57658 | CALL Spawn_Wave_Enemies_Populate_Slot | |||
| 57661 | EX DE,HL | Save the final entity list write pointer to *Entity_List_Write_Pointer. | ||
| 57662 | LD (50441),HL | |||
| 57665 | LD BC,53668 | Write the entity list terminator 53668 to *HL. | ||
| 57668 | LD (HL),C | |||
| 57669 | INC HL | |||
| 57670 | LD (HL),B | |||
| 57671 | EX DE,HL | Restore HL and DE. | ||
| 57672 | RET | Return. | ||
|
Reads the count byte from *HL. Caches it in the entity count table at 50215+index. If zero, jumps to Spawn_Wave_Enemies_Update_Pointer; otherwise loops B times, writing a nine-byte entity record and calling Draw_Wide_Entity_Sprite.
|
||||
| Spawn_Wave_Enemies_Populate_Slot | 57673 | PUSH HL | Stash the source pointer on the stack. | |
| 57674 | LD D,(HL) | D=*HL (entity count for this slot). | ||
| 57675 | LD A,C | Save the slot ID in A. | ||
| 57676 | SRL C | Shift C right four times to derive the slot count table index. | ||
| 57678 | SRL C | |||
| 57680 | SRL C | |||
| 57682 | SRL C | |||
| 57684 | LD B,0 | Write entity count (D) to *50215+index. | ||
| 57686 | LD HL,50215 | |||
| 57689 | ADD HL,BC | |||
| 57690 | LD (HL),D | |||
| 57691 | POP HL | Restore the source pointer. | ||
| 57692 | LD C,A | C=A (restore the slot ID). | ||
| 57693 | LD A,D | A=B=entity count (B drives the entity spawn loop). | ||
| 57694 | LD B,A | |||
| 57695 | AND A | Test if the entity count is zero. | ||
| 57696 | PUSH HL | Stash the source pointer on the stack. | ||
| 57697 | LD HL,(50445) | HL=*Entity_List_Working_Pointer (entity list write pointer). | ||
| 57700 | JP Z,Spawn_Wave_Enemies_Update_Pointer | Jump to Spawn_Wave_Enemies_Update_Pointer if the entity count is zero. | ||
|
Build one entity record at *HL: entity handler 57351 zero byte, type nibble, random Y (16-170), random X (8-240), then 13 7 255; call Draw_Wide_Entity_Sprite to spawn. Loop B times.
|
||||
| Spawn_Wave_Enemies_Write_Record | 57703 | LD DE,57351 | DE=57351 (entity update handler address). | |
| 57706 | LD (HL),E | Write DE to *HL as a little-endian word. | ||
| 57707 | INC HL | |||
| 57708 | LD (HL),D | |||
| 57709 | INC HL | |||
| 57710 | LD (HL),0 | Write 0 to *HL; advance HL. | ||
| 57712 | INC HL | |||
| 57713 | CALL Generate_Random_Byte | Call Generate_Random_Byte to generate a random byte. | ||
| 57716 | AND %00000011 | Mask to the low two bits. | ||
| 57718 | OR C | Write entity type (slot ORed with random bits) to *HL. | ||
| 57719 | LD (HL),A | |||
| 57720 | INC HL | |||
| Spawn_Wave_Enemies_Get_Y | 57721 | CALL Generate_Random_Byte | Call Generate_Random_Byte to generate a random byte. | |
| 57724 | CP 16 | Retry if below 16 (outside valid Y range). | ||
| 57726 | JP C,Spawn_Wave_Enemies_Get_Y | |||
| 57729 | CP 171 | Retry if 171 or greater (outside valid Y range). | ||
| 57731 | JP NC,Spawn_Wave_Enemies_Get_Y | |||
| 57734 | LD (HL),A | Write random Y coordinate to *HL; advance HL. | ||
| 57735 | INC HL | |||
| Spawn_Wave_Enemies_Get_X | 57736 | CALL Generate_Random_Byte | Call Generate_Random_Byte to generate a random byte. | |
| 57739 | CP 8 | Retry if below 8 (outside valid X range). | ||
| 57741 | JP C,Spawn_Wave_Enemies_Get_X | |||
| 57744 | CP 241 | Retry if 241 or greater (outside valid X range). | ||
| 57746 | JP NC,Spawn_Wave_Enemies_Get_X | |||
| 57749 | LD (HL),A | Write random X coordinate to *HL. | ||
| 57750 | PUSH HL | Stash HL on the stack; step HL back to the type byte. | ||
| 57751 | DEC HL | |||
| 57752 | DEC HL | |||
| 57753 | EXX | Set B'=INK: WHITE, PAPER: BLACK (BRIGHT) via shadow registers. | ||
| 57754 | LD B,71 | |||
| 57756 | EXX | |||
| 57757 | PUSH BC | Spawn the entity via Draw_Wide_Entity_Sprite, preserving BC. | ||
| 57758 | CALL Draw_Wide_Entity_Sprite | |||
| 57761 | POP BC | |||
| 57762 | POP HL | Restore HL (X coordinate position). | ||
| 57763 | INC HL | Write trailing record bytes 13 7 and 255. | ||
| 57764 | LD (HL),13 | |||
| 57766 | INC HL | |||
| 57767 | LD (HL),7 | |||
| 57769 | INC HL | |||
| 57770 | LD (HL),255 | |||
| 57772 | INC HL | Advance HL; loop back to Spawn_Wave_Enemies_Write_Record for the next entity. | ||
| 57773 | DJNZ Spawn_Wave_Enemies_Write_Record | |||
| Spawn_Wave_Enemies_Update_Pointer | 57775 | LD (50445),HL | Save the entity list write pointer to *Entity_List_Working_Pointer. | |
| 57778 | EX DE,HL | Restore DE. | ||
| 57779 | POP HL | Restore the source pointer; advance past the count byte. | ||
| 57780 | INC HL | |||
| 57781 | RET | Return. | ||
| Prev: 57347 | Up: Map | Next: 57782 |