![]() |
Routines |
| Prev: E290 | Up: Map | Next: E2FD |
|
Used by the routines at Spawn_Horizontal_Wave_Enemies, Spawn_Tracked_Enemy_Entities and Spawn_Wall_Bouncing_Enemies.
Generates a random Y coordinate in the range 10-A7 and a random X coordinate in the range 08-E7 writing both to *HL with initial velocities 10/10 then tests whether the chosen position overlaps the player spawn zone via HitTestBounds8AtHL; retries the whole selection if it does. Called from Spawn_Horizontal_Wave_Enemies and Spawn_Wall_Bouncing_Enemies.
|
||||
| Pick_Random_Spawn_Position_Y | E2C8 | CALL Generate_Random_Byte | Generate random bytes until a valid Y coordinate (10-A7) is found and write it to *HL. | |
| E2CB | CP $10 | |||
| E2CD | JP C,Pick_Random_Spawn_Position_Y | |||
| E2D0 | CP $A8 | |||
| E2D2 | JP NC,Pick_Random_Spawn_Position_Y | |||
| E2D5 | LD (HL),A | |||
| E2D6 | INC HL | |||
| Pick_Random_Spawn_Position_X | E2D7 | CALL Generate_Random_Byte | Generate random bytes until a valid X coordinate (08-E7) is found and write it to *HL. | |
| E2DA | CP $08 | |||
| E2DC | JP C,Pick_Random_Spawn_Position_X | |||
| E2DF | CP $E8 | |||
| E2E1 | JP NC,Pick_Random_Spawn_Position_X | |||
| E2E4 | LD (HL),A | |||
| E2E5 | INC HL | Write initial Y and X velocities (10 each) to the entity record. | ||
| E2E6 | LD (HL),$10 | |||
| E2E8 | INC HL | |||
| E2E9 | LD (HL),$10 | |||
| E2EB | DEC HL | Step back three bytes and set the player spawn area address in alternate HL via Entity_Spawn_Handler. | ||
| E2EC | DEC HL | |||
| E2ED | DEC HL | |||
| E2EE | EXX | |||
| E2EF | LD HL,$D1C7 | |||
| E2F2 | EXX | |||
| E2F3 | CALL HitTestBounds8AtHL | Test whether the position overlaps the player spawn zone via HitTestBounds8AtHL; return if clear. | ||
| E2F6 | RET C | |||
| E2F7 | DEC HL | Retry the whole position selection from Pick_Random_Spawn_Position_Y if it overlaps. | ||
| E2F8 | DEC HL | |||
| E2F9 | DEC HL | |||
| E2FA | JP Pick_Random_Spawn_Position_Y | |||
| Prev: E290 | Up: Map | Next: E2FD |