Prev: 59521 Up: Map Next: 59764
59692: 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 4 random screen position via Pick_Random_Spawn_Position_Y, and state bytes 15 and 10) 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 59692 LD A,(HL) Read the spawn count from the wave data and store it at Bouncing_Enemy_Count.
59693 LD (50223),A
59696 INC HL Advance past the spawn count byte.
59697 AND A Return if no bouncers need spawning.
59698 RET Z
Update the wave enemy total and load the entity list write pointer.
59699 LD B,A Add the spawn count to the wave enemy total at Active_Enemy_Count.
59700 LD A,(50204)
59703 ADD A,B
59704 LD (50204),A
59707 PUSH HL Stash the wave data pointer on the stack.
59708 LD HL,(50441) 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 59711 LD DE,59521 Write the entity handler address Process_Wall_Bouncing_Enemy into the first two bytes.
59714 LD (HL),E
59715 INC HL
59716 LD (HL),D
59717 INC HL Write entity type 4 and initial state byte 38 to the record.
59718 LD (HL),4
59720 INC HL
59721 LD (HL),38
59723 INC HL
59724 PUSH BC Stash the spawn loop counter on the stack.
59725 CALL Pick_Random_Spawn_Position_Y Generate a random spawn position via Pick_Random_Spawn_Position_Y.
59728 DEC HL Step back to the Y position field.
59729 PUSH HL Stash HL on the stack.
59730 DEC HL Step back three bytes and set spawn colour INK: BLUE, PAPER: BLACK (BRIGHT) in B'.
59731 DEC HL
59732 DEC HL
59733 EXX
59734 LD B,65
59736 EXX
59737 CALL Draw_Wide_Entity_Sprite Spawn the bouncer in the generated position via Draw_Wide_Entity_Sprite.
59740 POP HL Restore the position pointer from the stack.
59741 LD (HL),15 Write the active state byte 15 and advance.
59743 INC HL
59744 LD (HL),10 Write the bounce counter 10 and advance.
59746 INC HL
59747 LD (HL),255 Write the end-of-record marker 255 and advance.
59749 INC HL
59750 POP BC Restore the spawn loop counter from the stack.
59751 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.
59753 LD (50441),HL Save the updated entity list write pointer to Entity_List_Write_Pointer.
59756 LD DE,53668 Write the list terminator address Entity_List_Reset to *HL.
59759 LD (HL),E
59760 INC HL
59761 LD (HL),D
59762 POP HL Restore the wave data pointer from the stack.
59763 RET Return.
Prev: 59521 Up: Map Next: 59764