![]() |
Routines |
| Prev: 60151 | Up: Map | Next: 60340 |
|
Used by the routine at Process_Replacement_Enemy_Entity.
Per-frame handler for the final phase of a wall-bouncing enemy, reached from Process_Replacement_Enemy_Entity when the replacement entity countdown expires. Spawns the entity with colour
WHITE, calls Find_Colliding_Entity to search for a player-contact slot, and jumps to Process_Final_Phase_Enemy_Entity_Kill if none is found. Calls HitTestBounds8AtHL to test player contact and jumps to Strip_Attributes_And_Fade to kill the player if touching. Steps back to the direction field and generates a random value; keeps the current direction if below 240 otherwise picks a new direction, wraps it within 51 and writes it back. Looks up Y and X deltas from Enemy_Movement_Delta_Table (direction & 3 × 2), validates the new position within the play area, and spawns the entity. If no contact slot is found, erases the sprite, removes the entity from the list, awards BCD score, and writes the retire handler.
|
||||||||
|
Advance past the countdown byte and spawn with white colour.
|
||||||||
| Process_Final_Phase_Enemy_Entity | 60167 | INC HL | Advance past the countdown field. | |||||
| 60168 | PUSH HL | Stash the entity pointer on the stack. | ||||||
| 60169 | EXX | Load WHITE into B'. | ||||||
| 60170 | LD B,7 | |||||||
| 60172 | EXX | |||||||
| 60173 | CALL Draw_Wide_Entity_Sprite | Call Draw_Wide_Entity_Sprite to spawn the entity. | ||||||
| 60176 | POP HL | Restore the entity pointer from the stack. | ||||||
| 60177 | INC HL | Advance one byte and switch to alternate registers. | ||||||
| 60178 | EXX | |||||||
|
Search for a player-contact slot and test overlap.
|
||||||||
| 60179 | CALL Find_Colliding_Entity | Call Find_Colliding_Entity to search for a player-contact slot and jump to Process_Final_Phase_Enemy_Entity_Kill if none is found. | ||||||
| 60182 | JP NC,Process_Final_Phase_Enemy_Entity_Kill | |||||||
| 60185 | LD HL,50388 | Load the player position at Player_Y_Position and call HitTestBounds8AtHL to test overlap. | ||||||
| 60188 | CALL HitTestBounds8AtHL | |||||||
| 60191 | JP NC,Strip_Attributes_And_Fade | Jump to Strip_Attributes_And_Fade to kill the player if contact is confirmed. | ||||||
| 60194 | EXX | Switch to main registers. | ||||||
|
Step back to the direction field and pick or keep a direction.
|
||||||||
| 60195 | DEC HL | Step back three bytes to the direction field. | ||||||
| 60196 | DEC HL | |||||||
| 60197 | DEC HL | |||||||
| 60198 | CALL Generate_Random_Byte | Call Generate_Random_Byte to generate a random value. | ||||||
| 60201 | CP 240 | Keep the current direction if the value is below 240. | ||||||
| 60203 | JP C,Process_Final_Phase_Enemy_Entity_Keep | |||||||
|
Increment and mask the direction byte.
|
||||||||
| Process_Final_Phase_Enemy_Entity_Retry | 60206 | DEC HL | Step back to the direction field, load it, and increment it. | |||||
| 60207 | LD A,(HL) | |||||||
| 60208 | INC A | |||||||
| 60209 | AND %00110011 | Mask the direction within 51. | ||||||
| 60211 | LD (HL),A | Write the new direction, advance, and jump to Process_Final_Phase_Enemy_Entity_Apply. | ||||||
| 60212 | INC HL | |||||||
| 60213 | JP Process_Final_Phase_Enemy_Entity_Apply | |||||||
| Process_Final_Phase_Enemy_Entity_Keep | 60216 | DEC HL | Step back to the direction field, load it, and advance. | |||||
| 60217 | LD A,(HL) | |||||||
| 60218 | INC HL | |||||||
|
Look up movement deltas and validate the new position.
|
||||||||
| Process_Final_Phase_Enemy_Entity_Apply | 60219 | EX DE,HL | Exchange DE and HL. | |||||
| 60220 | AND %00000011 | Mask the direction to the low 2 bits. | ||||||
| 60222 | SLA A | Double the index, load the movement table base at Enemy_Movement_Delta_Table, and step to the entry. | ||||||
| 60224 | LD C,A | |||||||
| 60225 | LD B,0 | |||||||
| 60227 | LD HL,60340 | |||||||
| 60230 | ADD HL,BC | |||||||
| 60231 | EX DE,HL | Add the Y delta to the entity Y position and jump to Process_Final_Phase_Enemy_Entity_Retry if outside 16–170. | ||||||
| 60232 | LD A,(DE) | |||||||
| 60233 | ADD A,(HL) | |||||||
| 60234 | CP 171 | |||||||
| 60236 | JP NC,Process_Final_Phase_Enemy_Entity_Retry | |||||||
| 60239 | CP 16 | |||||||
| 60241 | JP C,Process_Final_Phase_Enemy_Entity_Retry | |||||||
| 60244 | LD C,A | Save the validated Y position in C. | ||||||
| 60245 | INC HL | Advance to the X position, apply the X delta, and jump to Process_Final_Phase_Enemy_Entity_X_Retry if outside the play area. | ||||||
| 60246 | INC DE | |||||||
| 60247 | LD A,(DE) | |||||||
| 60248 | ADD A,(HL) | |||||||
| 60249 | CP 241 | |||||||
| 60251 | JP NC,Process_Final_Phase_Enemy_Entity_X_Retry | |||||||
| 60254 | CP 8 | |||||||
| 60256 | JP NC,Process_Final_Phase_Enemy_Entity_Write | |||||||
| Process_Final_Phase_Enemy_Entity_X_Retry | 60259 | DEC HL | Step back one byte and jump to Process_Final_Phase_Enemy_Entity_Retry to retry. | |||||
| 60260 | JP Process_Final_Phase_Enemy_Entity_Retry | |||||||
|
Write the validated coordinates and spawn with a random colour.
|
||||||||
| Process_Final_Phase_Enemy_Entity_Write | 60263 | LD (HL),A | Write the validated X and Y coordinates to the entity record. | |||||
| 60264 | DEC HL | |||||||
| 60265 | LD (HL),C | |||||||
| 60266 | DEC HL | |||||||
| 60267 | PUSH HL | Stash the entity pointer on the stack. | ||||||
| 60268 | EXX | Switch to alternate registers. | ||||||
| 60269 | CALL Generate_Random_Byte | Call Generate_Random_Byte to generate a random colour byte. | ||||||
| 60272 | AND %00111000 | Mask to bits 3–5 to select the spawn colour. | ||||||
| 60274 | LD B,A | Load the colour into B and switch to main registers. | ||||||
| 60275 | EXX | |||||||
| 60276 | CALL Draw_Wide_Entity_Sprite | Call Draw_Wide_Entity_Sprite to spawn the entity. | ||||||
| 60279 | POP HL | Restore the entity pointer from the stack. | ||||||
| 60280 | JP Process_Entity_Record_Next6 | Jump to Process_Entity_Record_Next6 to advance the entity pointer. | ||||||
|
Erase the entity, remove it from the list, and award the score.
|
||||||||
| Process_Final_Phase_Enemy_Entity_Kill | 60283 | LD DE,6 | Step back six bytes to the entity record and save the address in Entity_Record_Pointer. | |||||
| 60286 | SBC HL,DE | |||||||
| 60288 | LD (50394),HL | |||||||
| 60291 | CALL Erase_Narrow_Entity_Sprite | Call Erase_Narrow_Entity_Sprite to erase the entity sprite. | ||||||
| 60294 | CALL Remove_Entity_From_List | Call Remove_Entity_From_List to remove the entity from the list. | ||||||
| 60297 | LD E,0 | Load code 0 and call Initialise_Entity_State to initialise the entity state. | ||||||
| 60299 | CALL Initialise_Entity_State | |||||||
|
Increment the BCD score and propagate carry to higher digits.
|
||||||||
| 60302 | LD HL,50181 | Load 50181, add 1 BCD, write it back, and jump to Process_Final_Phase_Enemy_Entity_Score_Bar if no carry. | ||||||
| 60305 | LD A,(HL) | |||||||
| 60306 | ADD A,1 | |||||||
| 60308 | DAA | |||||||
| 60309 | LD (HL),A | |||||||
| 60310 | JR NC,Process_Final_Phase_Enemy_Entity_Score_Bar | |||||||
| 60312 | DEC HL | Carry to the tens digit: load, add 1 BCD, write back, and jump to Process_Final_Phase_Enemy_Entity_Score_Bar if no carry. | ||||||
| 60313 | LD A,(HL) | |||||||
| 60314 | ADD A,1 | |||||||
| 60316 | DAA | |||||||
| 60317 | LD (HL),A | |||||||
| 60318 | JR NC,Process_Final_Phase_Enemy_Entity_Score_Bar | |||||||
| 60320 | DEC HL | Carry to the hundreds digit: load, add 1 BCD, and write back. | ||||||
| 60321 | LD A,(HL) | |||||||
| 60322 | ADD A,1 | |||||||
| 60324 | DAA | |||||||
| 60325 | LD (HL),A | |||||||
|
Refresh the colour bar and write the retire handler.
|
||||||||
| Process_Final_Phase_Enemy_Entity_Score_Bar | 60326 | CALL Clear_Colour_Bar_Column | Call Clear_Colour_Bar_Column to refresh the colour bar. | |||||
| 60329 | EXX | Switch to main registers. | ||||||
| 60330 | DEC HL | Step back three bytes to the entity handler field. | ||||||
| 60331 | DEC HL | |||||||
| 60332 | DEC HL | |||||||
| 60333 | LD DE,57388 | Write the retire handler Process_Entity_Record_Next7 into the entity record. | ||||||
| 60336 | LD (HL),D | |||||||
| 60337 | DEC HL | |||||||
| 60338 | LD (HL),E | |||||||
| 60339 | RET | Return. | ||||||
| Prev: 60151 | Up: Map | Next: 60340 |