Prev: E881 Up: Map Next: E974
E92C: Spawn Wall Bouncing Enemies
Used by the routine at Stage_Next_Wave.
Called from Stage_Next_Wave. Reads the wall-bouncing enemy spawn count from *HL and stores it at Bouncing_Enemy_Count. Returns immediately if the count is zero. Otherwise adds the count to the wave enemy total at Active_Enemy_Count and spawns B bouncers, writing each entity record (handler Process_Wall_Bouncing_Enemy, entity type 04 random screen position via Pick_Random_Spawn_Position_Y, and state bytes 0F and 0A) into the entity list at *Entity_List_Write_Pointer. Closes the list with Entity_List_Reset and restores the wave data pointer.
Input
HL Wave data pointer
Spawn_Wall_Bouncing_Enemies E92C LD A,(HL) Read the spawn count from the wave data and store it at Bouncing_Enemy_Count.
E92D LD ($C42F),A
E930 INC HL Advance past the spawn count byte.
E931 AND A Return if no bouncers need spawning.
E932 RET Z
Update the wave enemy total and load the entity list write pointer.
E933 LD B,A Add the spawn count to the wave enemy total at Active_Enemy_Count.
E934 LD A,($C41C)
E937 ADD A,B
E938 LD ($C41C),A
E93B PUSH HL Stash the wave data pointer on the stack.
E93C LD HL,($C509) Load the entity list write pointer from Entity_List_Write_Pointer.
Write the entity record and spawn the bouncer at a random position.
Spawn_Wall_Bouncing_Enemies_Record E93F LD DE,$E881 Write the entity handler address Process_Wall_Bouncing_Enemy into the first two bytes.
E942 LD (HL),E
E943 INC HL
E944 LD (HL),D
E945 INC HL Write entity type 04 and initial state byte 26 to the record.
E946 LD (HL),$04
E948 INC HL
E949 LD (HL),$26
E94B INC HL
E94C PUSH BC Stash the spawn loop counter on the stack.
E94D CALL Pick_Random_Spawn_Position_Y Generate a random spawn position via Pick_Random_Spawn_Position_Y.
E950 DEC HL Step back to the Y position field.
E951 PUSH HL Stash HL on the stack.
E952 DEC HL Step back three bytes and set spawn colour INK: BLUE, PAPER: BLACK (BRIGHT) in B'.
E953 DEC HL
E954 DEC HL
E955 EXX
E956 LD B,$41
E958 EXX
E959 CALL Draw_Wide_Entity_Sprite Spawn the bouncer in the generated position via Draw_Wide_Entity_Sprite.
E95C POP HL Restore the position pointer from the stack.
E95D LD (HL),$0F Write the active state byte 0F and advance.
E95F INC HL
E960 LD (HL),$0A Write the bounce counter 0A and advance.
E962 INC HL
E963 LD (HL),$FF Write the end-of-record marker FF and advance.
E965 INC HL
E966 POP BC Restore the spawn loop counter from the stack.
E967 DJNZ Spawn_Wall_Bouncing_Enemies_Record Loop back to Spawn_Wall_Bouncing_Enemies_Record until all bouncers are spawned.
Save the entity list pointer and write the list terminator.
E969 LD ($C509),HL Save the updated entity list write pointer to Entity_List_Write_Pointer.
E96C LD DE,$D1A4 Write the list terminator address Entity_List_Reset to *HL.
E96F LD (HL),E
E970 INC HL
E971 LD (HL),D
E972 POP HL Restore the wave data pointer from the stack.
E973 RET Return.
Prev: E881 Up: Map Next: E974