![]() |
Routines |
| Prev: 58000 | Up: Map | Next: 58109 |
|
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 16-167 and a random X coordinate in the range 8-231 writing both to *HL with initial velocities 16/16 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 | 58056 | CALL Generate_Random_Byte | Generate random bytes until a valid Y coordinate (16-167) is found and write it to *HL. | |
| 58059 | CP 16 | |||
| 58061 | JP C,Pick_Random_Spawn_Position_Y | |||
| 58064 | CP 168 | |||
| 58066 | JP NC,Pick_Random_Spawn_Position_Y | |||
| 58069 | LD (HL),A | |||
| 58070 | INC HL | |||
| Pick_Random_Spawn_Position_X | 58071 | CALL Generate_Random_Byte | Generate random bytes until a valid X coordinate (8-231) is found and write it to *HL. | |
| 58074 | CP 8 | |||
| 58076 | JP C,Pick_Random_Spawn_Position_X | |||
| 58079 | CP 232 | |||
| 58081 | JP NC,Pick_Random_Spawn_Position_X | |||
| 58084 | LD (HL),A | |||
| 58085 | INC HL | Write initial Y and X velocities (16 each) to the entity record. | ||
| 58086 | LD (HL),16 | |||
| 58088 | INC HL | |||
| 58089 | LD (HL),16 | |||
| 58091 | DEC HL | Step back three bytes and set the player spawn area address in alternate HL via Entity_Spawn_Handler. | ||
| 58092 | DEC HL | |||
| 58093 | DEC HL | |||
| 58094 | EXX | |||
| 58095 | LD HL,53703 | |||
| 58098 | EXX | |||
| 58099 | CALL HitTestBounds8AtHL | Test whether the position overlaps the player spawn zone via HitTestBounds8AtHL; return if clear. | ||
| 58102 | RET C | |||
| 58103 | DEC HL | Retry the whole position selection from Pick_Random_Spawn_Position_Y if it overlaps. | ||
| 58104 | DEC HL | |||
| 58105 | DEC HL | |||
| 58106 | JP Pick_Random_Spawn_Position_Y | |||
| Prev: 58000 | Up: Map | Next: 58109 |