![]() |
Routines |
| Prev: 56825 | Up: Map | Next: 57634 |
|
Processes one entity slot in the wave entity list. If the slot is active, the enemy's animation colours are updated on screen via Paint_Narrow_Entity_Attributes and its animation counter decremented. If the counter expires the enemy is erased and the slot retired. If the slot holds spawn data (Process_Entity_Record_Inactive), a new enemy position is found and the enemy is placed in the play area.
|
||||||||
| Process_Entity_Record_Fast | 57347 | LD A,(HL) | Read the entity's animation counter. | |||||
| 57348 | JP Process_Entity_Record_Tick | Jump to Process_Entity_Record_Tick. | ||||||
| Process_Entity_Record | 57351 | LD A,(HL) | Read the entity's animation counter. | |||||
| 57352 | AND A | Jump to Process_Entity_Record_Inactive if the entity slot is inactive. | ||||||
| 57353 | JP Z,Process_Entity_Record_Inactive | |||||||
|
Update the enemy's on-screen colour then advance its animation counter. If the counter expires the enemy is erased.
|
||||||||
| Process_Entity_Record_Tick | 57356 | AND %00000111 | Extract the three-bit animation frame number. | |||||
| 57358 | INC HL | Move past the animation counter byte. | ||||||
| 57359 | PUSH HL | Stash the entity data pointer on the stack. | ||||||
| 57360 | EXX | Pass the animation frame number to the colouring routine. | ||||||
| 57361 | LD B,A | |||||||
| 57362 | EXX | |||||||
| 57363 | CALL Paint_Narrow_Entity_Attributes | Call Paint_Narrow_Entity_Attributes to colour the entity on screen. | ||||||
| 57366 | POP HL | Restore the entity data pointer from the stack. | ||||||
| 57367 | DEC HL | Step back to the animation counter byte. | ||||||
| 57368 | DEC (HL) | Advance the animation frame and jump to Process_Entity_Record_Next7 if not yet expired. | ||||||
| 57369 | JP NZ,Process_Entity_Record_Next7 | |||||||
|
The animation counter has run down to zero: remove the enemy from the screen.
|
||||||||
| 57372 | INC HL | Move past the animation counter byte. | ||||||
| 57373 | PUSH HL | Stash the entity data pointer on the stack. | ||||||
| 57374 | CALL Erase_Entity_Sprite | Call Erase_Entity_Sprite to erase the enemy sprite from the screen. | ||||||
| 57377 | POP HL | Restore the entity data pointer from the stack. | ||||||
| 57378 | DEC HL | Step back to the entity handler address field. | ||||||
| 57379 | DEC HL | |||||||
| 57380 | DEC HL | |||||||
| 57381 | LD DE,57388 | Load Process_Entity_Record_Next7 as the replacement entity handler. | ||||||
| 57384 | LD (HL),E | Write Process_Entity_Record_Next7 into the entity handler address field. | ||||||
| 57385 | INC HL | |||||||
| 57386 | LD (HL),D | |||||||
| 57387 | INC HL | |||||||
|
This entry point is used by the routines at Handle_Homing_Enemy and Animate_Wall_Bouncing_Enemy_Death.
|
||||||||
| Process_Entity_Record_Next7 | 57388 | LD DE,7 | Skip to the next entity record and return. | |||||
| 57391 | ADD HL,DE | |||||||
| 57392 | RET | |||||||
|
This slot holds spawn data for a new enemy. Erase any ghost at the target position, check it falls within the play area, then try to place the enemy.
|
||||||||
| Process_Entity_Record_Inactive | 57393 | INC HL | Move past the animation counter byte. | |||||
| 57394 | PUSH HL | Stash the entity data pointer on the stack. | ||||||
| 57395 | CALL Erase_Wide_Entity_Sprite | Call Erase_Wide_Entity_Sprite to erase any residual sprite at the spawn position. | ||||||
| 57398 | POP HL | Restore the entity data pointer from the stack. | ||||||
| 57399 | INC HL | Move to the entity's Y position. | ||||||
| 57400 | EXX | Set the play area boundary data address for the bounds check. | ||||||
| 57401 | LD HL,50388 | |||||||
| 57404 | EXX | |||||||
| 57405 | CALL HitTestBounds8AtHL | Call HitTestBounds8AtHL to test if the spawn position is within the play area. | ||||||
| 57408 | JP NC,Process_Entity_Record_Kill | Jump to Process_Entity_Record_Kill if the position is outside the play area. | ||||||
| 57411 | DEC HL | Step back to the entity type state byte. | ||||||
| 57412 | DEC HL | |||||||
| 57413 | DEC HL | |||||||
| 57414 | CALL Generate_Random_Byte | Call Generate_Random_Byte to determine whether the enemy should change type. | ||||||
| 57417 | CP 240 | Stay with the current enemy type if the random roll is below 240. | ||||||
| 57419 | JP C,Process_Entity_Record_Keep_Type | |||||||
| Process_Entity_Record_Cycle_Type | 57422 | DEC HL | Step back to the entity type state byte. | |||||
| 57423 | LD A,(HL) | Read the entity type state. | ||||||
| 57424 | INC A | Advance to the next animation variant. | ||||||
| 57425 | AND %00110011 | Wrap within the valid entity type range (51). | ||||||
| 57427 | LD (HL),A | Save the new entity type state. | ||||||
| 57428 | INC HL | Move to the entity's animation frame data. | ||||||
| 57429 | JP Process_Entity_Record_Apply_Delta | Jump to Process_Entity_Record_Apply_Delta. | ||||||
|
The random roll was below 240 so the enemy keeps its current type. Load the unchanged type state and fall through to apply a movement step.
|
||||||||
| Process_Entity_Record_Keep_Type | 57432 | DEC HL | Step back to the entity type state byte. | |||||
| 57433 | LD A,(HL) | Read the entity type state. | ||||||
| 57434 | INC HL | Move to the entity's animation frame data. | ||||||
|
Apply a one-step movement from the direction table at Direction_Delta_Table. The direction is derived from the low two bits of the entity type state.
|
||||||||
| Process_Entity_Record_Apply_Delta | 57435 | EX DE,HL | Preserve the entity data pointer in DE. | |||||
| 57436 | AND %00000011 | Isolate the movement direction (two bits). | ||||||
| 57438 | SLA A | Index into the direction delta table at Direction_Delta_Table. | ||||||
| 57440 | LD C,A | |||||||
| 57441 | LD B,0 | |||||||
| 57443 | LD HL,57626 | |||||||
| 57446 | ADD HL,BC | |||||||
| 57447 | EX DE,HL | Restore HL to the entity data and DE to the delta entry. | ||||||
| 57448 | LD A,(DE) | Apply the Y movement delta to the enemy's current Y position. | ||||||
| 57449 | ADD A,(HL) | |||||||
| 57450 | CP 171 | Retry with a new type if the enemy moves below the play area. | ||||||
| 57452 | JP NC,Process_Entity_Record_Cycle_Type | |||||||
| 57455 | CP 16 | Retry with a new type if the enemy moves above the play area. | ||||||
| 57457 | JP C,Process_Entity_Record_Cycle_Type | |||||||
| 57460 | LD C,A | Save the validated Y position. | ||||||
| 57461 | INC HL | Advance to the enemy's X position and the X delta. | ||||||
| 57462 | INC DE | |||||||
| 57463 | LD A,(DE) | Apply the X movement delta to the enemy's current X position. | ||||||
| 57464 | ADD A,(HL) | |||||||
| 57465 | CP 241 | Jump to Process_Entity_Record_Retry if the new X overshoots the right edge. | ||||||
| 57467 | JP NC,Process_Entity_Record_Retry | |||||||
| 57470 | CP 8 | Accept the position if it is within the play area's left boundary. | ||||||
| 57472 | JP NC,Process_Entity_Record_Register | |||||||
| Process_Entity_Record_Retry | 57475 | DEC HL | Step back to the Y delta entry. | |||||
| 57476 | JP Process_Entity_Record_Cycle_Type | Retry with a new enemy type. | ||||||
|
The enemy's new position is inside the play area. Write it to the record and draw the enemy on screen.
|
||||||||
| Process_Entity_Record_Register | 57479 | LD (HL),A | Write the new screen position into the entity record. | |||||
| 57480 | DEC HL | |||||||
| 57481 | LD (HL),C | |||||||
| 57482 | DEC HL | |||||||
| 57483 | PUSH HL | Stash the entity record pointer on the stack. | ||||||
| 57484 | EXX | Set the spawn display attribute (INK: WHITE, PAPER: BLACK (BRIGHT) ) in the shadow register. | ||||||
| 57485 | LD B,71 | |||||||
| 57487 | EXX | |||||||
| 57488 | CALL Draw_Wide_Entity_Sprite | Call Draw_Wide_Entity_Sprite to spawn the enemy and draw it on screen. | ||||||
| 57491 | POP HL | Restore the entity record pointer from the stack. | ||||||
|
This entry point is used by the routines at Handle_Homing_Enemy, Handle_Horizontal_Enemy_Entity, Animate_Wall_Bouncing_Enemy_Death, Process_Replacement_Enemy_Entity and Process_Final_Phase_Enemy_Entity.
|
||||||||
| Process_Entity_Record_Next6 | 57492 | LD DE,6 | Skip to the next entity record and return. | |||||
| 57495 | ADD HL,DE | |||||||
| 57496 | RET | |||||||
|
This entry point is used by the routine at Handle_Horizontal_Enemy_Entity.
The enemy was placed successfully. Increment the scroll position counter before advancing to the next record.
|
||||||||
| Process_Entity_Record_Counter_Up_Next6 | 57497 | EX DE,HL | Preserve the entity list pointer in DE. | |||||
| 57498 | LD HL,(50485) | Add 64 to *50485. | ||||||
| 57501 | LD BC,64 | |||||||
| 57504 | ADD HL,BC | |||||||
| 57505 | LD (50485),HL | |||||||
| 57508 | EX DE,HL | Restore the entity list pointer. | ||||||
| 57509 | JP Process_Entity_Record_Next6 | Jump to Process_Entity_Record_Next6. | ||||||
|
This entry point is used by the routine at Handle_Homing_Enemy.
Same as Process_Entity_Record_Counter_Up_Next6 but steps over a seven-byte record.
|
||||||||
| Process_Entity_Record_Counter_Up_Next7 | 57512 | EX DE,HL | Preserve the entity list pointer in DE. | |||||
| 57513 | LD HL,(50485) | Add 64 to *50485. | ||||||
| 57516 | LD BC,64 | |||||||
| 57519 | ADD HL,BC | |||||||
| 57520 | LD (50485),HL | |||||||
| 57523 | EX DE,HL | Restore the entity list pointer. | ||||||
| 57524 | JP Process_Entity_Record_Next7 | Jump to Process_Entity_Record_Next7. | ||||||
|
The enemy has left the play area. Flash it with its death sprite then add a kill bonus to the player's score.
|
||||||||
| Process_Entity_Record_Kill | 57527 | DEC HL | Rewind to the entity handler address field. | |||||
| 57528 | DEC HL | |||||||
| 57529 | DEC HL | |||||||
| 57530 | DEC HL | |||||||
| 57531 | DEC HL | |||||||
| 57532 | LD (HL),50 | Switch the entity to the kill sequence handler. | ||||||
| 57534 | INC HL | Move to the entity colour attribute byte. | ||||||
| 57535 | LD A,(HL) | Read the entity colour attribute. | ||||||
| 57536 | PUSH AF | Stash the entity colour attribute on the stack. | ||||||
| 57537 | LD A,(50398) | Set the entity's death colour from the current kill tally. | ||||||
| 57540 | ADD A,19 | |||||||
| 57542 | LD (HL),A | |||||||
| 57543 | PUSH HL | Stash the attribute pointer on the stack. | ||||||
| 57544 | EXX | Set the death flash attribute ( WHITE) in the shadow register. | ||||||
| 57545 | LD B,7 | |||||||
| 57547 | EXX | |||||||
| 57548 | CALL Draw_Entity_Sprite | Call Draw_Entity_Sprite to draw the entity's death animation sprite. | ||||||
| 57551 | POP HL | Restore the attribute pointer from the stack. | ||||||
| 57552 | LD A,(50398) | Read the enemy kill value from the wave counter. | ||||||
| 57555 | SLA A | Multiply by 16 for the score contribution. | ||||||
| 57557 | SLA A | |||||||
| 57559 | SLA A | |||||||
| 57561 | SLA A | |||||||
| 57563 | EX DE,HL | Save the entity pointer while accessing the score. | ||||||
| 57564 | LD HL,50181 | Point HL at the player's score. | ||||||
| 57567 | ADD A,(HL) | Add the kill score to the ones digit of the player's score (BCD). | ||||||
| 57568 | DAA | |||||||
| 57569 | LD (HL),A | |||||||
| 57570 | JP NC,Process_Entity_Record_Wave_Count | Jump to Process_Entity_Record_Wave_Count if the ones digit did not overflow. | ||||||
| 57573 | DEC HL | Move to the tens digit. | ||||||
| 57574 | LD A,1 | Carry one into the tens digit of the player's score (BCD). | ||||||
| 57576 | ADD A,(HL) | |||||||
| 57577 | DAA | |||||||
| 57578 | LD (HL),A | |||||||
| 57579 | JP NC,Process_Entity_Record_Wave_Count | Jump to Process_Entity_Record_Wave_Count if the tens digit did not overflow. | ||||||
| 57582 | DEC HL | Move to the hundreds digit. | ||||||
| 57583 | LD A,1 | Carry one into the hundreds digit of the player's score (BCD). | ||||||
| 57585 | ADD A,(HL) | |||||||
| 57586 | DAA | |||||||
| 57587 | LD (HL),A | |||||||
| Process_Entity_Record_Wave_Count | 57588 | LD A,(50398) | Jump to Process_Entity_Record_Decrement_Count if the maximum kill count for this wave is reached. | |||||
| 57591 | CP 5 | |||||||
| 57593 | JP Z,Process_Entity_Record_Decrement_Count | |||||||
| 57596 | INC A | Increment the wave kill counter. | ||||||
| 57597 | LD (50398),A | |||||||
| Process_Entity_Record_Decrement_Count | 57600 | POP AF | Restore the entity colour attribute from the stack. | |||||
| 57601 | SRL A | Extract the entity type to use as a count table index. | ||||||
| 57603 | SRL A | |||||||
| 57605 | SRL A | |||||||
| 57607 | SRL A | |||||||
| 57609 | LD C,A | |||||||
| 57610 | LD B,0 | Form a pointer to the entity count entry for this type. | ||||||
| 57612 | LD HL,50215 | |||||||
| 57615 | ADD HL,BC | |||||||
| 57616 | DEC (HL) | Decrement the on-screen enemy count for this type. | ||||||
| 57617 | EX DE,HL | Restore the entity list pointer. | ||||||
| 57618 | PUSH HL | Stash the entity list pointer on the stack. | ||||||
| 57619 | CALL Clear_Colour_Bar_Column | Call Clear_Colour_Bar_Column to update the score and wave display. | ||||||
| 57622 | POP HL | Restore the entity list pointer from the stack. | ||||||
| 57623 | JP Process_Entity_Record_Next6 | Jump to Process_Entity_Record_Next6. | ||||||
|
Movement delta table: one two-byte entry (Y delta, X delta) per cardinal direction, indexed by the low two bits of the entity type state. Order: up, right, down, left.
|
||||||||
| Direction_Delta_Table | 57626 | DEFB 255,0 | ||||||
| 57628 | DEFB 0,1 | |||||||
| 57630 | DEFB 1,0 | |||||||
| 57632 | DEFB 0,255 | |||||||
| Prev: 56825 | Up: Map | Next: 57634 |