Prev: E7AF Up: Map Next: E863
E7CF: Spawn Tracked Enemy Entities
Used by the routine at Evaluate_And_Spawn_Tracked_Enemies.
Initialises the tracked-enemy active count at C42D to zero, copies the per-wave count byte into C42C and adds it to the total wave enemy count at Active_Enemy_Count, then stashes the wave data pointer. If the count is zero, jumps to Spawn_Tracked_Enemy_Entities_Terminate; otherwise loops B times: writes a 14-byte entity record (handler Process_Tracked_Enemy_Entity, entity type B0 random type variant, random screen position via Pick_Random_Spawn_Position_Y, three initial bytes from the wave data for velocity seeds, and FF as the terminator) into the entity list via *Entity_List_Write_Pointer, spawning each entity via Draw_Wide_Entity_Sprite. Closes the entity list with the D1A4 terminator.
Spawn_Tracked_Enemy_Entities E7CF XOR A Clear C42D copy the spawn count into C42C and accumulate it into the wave enemy count at Active_Enemy_Count.
E7D0 LD ($C42D),A
E7D3 LD A,(HL)
E7D4 LD ($C42C),A
E7D7 PUSH AF
E7D8 LD B,A Stash the wave data pointer, load the entity list write pointer, and jump to Spawn_Tracked_Enemy_Entities_Terminate if the count is zero.
E7D9 LD A,($C41C)
E7DC ADD A,B
E7DD LD ($C41C),A
E7E0 POP AF
E7E1 INC HL
E7E2 AND A
E7E3 PUSH HL
E7E4 LD HL,($C509)
This entry point is used by the routine at 9063.
Spawn_Tracked_Enemy_Entities_0 E7E7 JP Z,Spawn_Tracked_Enemy_Entities_Terminate
E7EA LD B,A
Spawn_Tracked_Enemy_Entities_Record E7EB PUSH BC Write the Process_Tracked_Enemy_Entity handler and entity type B0 to the entity list record.
E7EC LD DE,$E360
E7EF LD (HL),E
E7F0 INC HL
E7F1 LD (HL),D
E7F2 INC HL
E7F3 LD (HL),$B0
E7F5 INC HL
E7F6 LD (HL),$04 Generate a random entity type variant via Generate_Random_Byte.
E7F8 INC HL
E7F9 CALL Generate_Random_Byte Mask to 2 bits for the type variant and add 28.
E7FC AND $03
E7FE ADD A,$28
E800 LD (HL),A Write the entity type variant and advance.
E801 INC HL
E802 PUSH HL Point HL at the spawn buffer, write the type variant, and call Pick_Random_Spawn_Position_Y to generate a valid random screen position.
E803 LD HL,$C511
E806 LD (HL),A
E807 INC HL
E808 CALL Pick_Random_Spawn_Position_Y
E80B LD DE,$C53B
E80E LDD Copy three bytes from the wave data at C53B using LDD×4 and apply the direction delta via Apply_Direction_Delta.
E810 LDD
E812 LDD
E814 PUSH HL
E815 LDD
E817 LD A,(HL)
E818 LD (DE),A
E819 EX DE,HL
E81A CALL Apply_Direction_Delta
E81D EXX Set colour INK: RED, PAPER: BLACK (BRIGHT) in B' and spawn the entity via Draw_Wide_Entity_Sprite.
E81E LD B,$42
E820 EXX
E821 CALL Draw_Wide_Entity_Sprite
E824 POP HL Write three velocity seed bytes, initial deltas, and the FF record terminator; loop back to Spawn_Tracked_Enemy_Entities_Record for the next entity.
E825 POP DE
E826 XOR A
E827 LDI
E829 LD (DE),A
E82A INC DE
E82B LDI
E82D LD (DE),A
E82E INC DE
E82F PUSH DE
E830 CALL Advance_RNG_Seed
E833 LD DE,$0000
E836 CALL Clamp_Entity_Velocity
E839 POP DE
E83A EX DE,HL
E83B LD (HL),D
E83C INC HL
E83D LD (HL),E
E83E INC HL
E83F PUSH HL
E840 CALL Advance_RNG_Seed
E843 LD DE,$0000
E846 CALL Clamp_Entity_Velocity
E849 POP DE
E84A EX DE,HL
E84B LD (HL),D
E84C INC HL
E84D LD (HL),E
E84E INC HL
E84F LD (HL),$FF
E851 INC HL
E852 POP BC
E853 DJNZ Spawn_Tracked_Enemy_Entities_Record
Spawn_Tracked_Enemy_Entities_Terminate E855 LD DE,$D1A4 Save the entity list pointer to *Entity_List_Write_Pointer and write the D1A4 terminator.
E858 LD ($C509),HL
E85B LD (HL),E
E85C INC HL
E85D LD (HL),D Write FF and advance HL.
E85E INC HL
E85F LD (HL),$FF Restore the wave data pointer and return.
E861 POP HL
E862 RET
Prev: E7AF Up: Map Next: E863