![]() |
Routines |
| Prev: DDF9 | Up: Map | Next: E122 |
|
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 | E003 | LD A,(HL) | Read the entity's animation counter. | |||||
| E004 | JP Process_Entity_Record_Tick | Jump to Process_Entity_Record_Tick. | ||||||
| Process_Entity_Record | E007 | LD A,(HL) | Read the entity's animation counter. | |||||
| E008 | AND A | Jump to Process_Entity_Record_Inactive if the entity slot is inactive. | ||||||
| E009 | 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 | E00C | AND %00000111 | Extract the three-bit animation frame number. | |||||
| E00E | INC HL | Move past the animation counter byte. | ||||||
| E00F | PUSH HL | Stash the entity data pointer on the stack. | ||||||
| E010 | EXX | Pass the animation frame number to the colouring routine. | ||||||
| E011 | LD B,A | |||||||
| E012 | EXX | |||||||
| E013 | CALL Paint_Narrow_Entity_Attributes | Call Paint_Narrow_Entity_Attributes to colour the entity on screen. | ||||||
| E016 | POP HL | Restore the entity data pointer from the stack. | ||||||
| E017 | DEC HL | Step back to the animation counter byte. | ||||||
| E018 | DEC (HL) | Advance the animation frame and jump to Process_Entity_Record_Next7 if not yet expired. | ||||||
| E019 | JP NZ,Process_Entity_Record_Next7 | |||||||
|
The animation counter has run down to zero: remove the enemy from the screen.
|
||||||||
| E01C | INC HL | Move past the animation counter byte. | ||||||
| E01D | PUSH HL | Stash the entity data pointer on the stack. | ||||||
| E01E | CALL Erase_Entity_Sprite | Call Erase_Entity_Sprite to erase the enemy sprite from the screen. | ||||||
| E021 | POP HL | Restore the entity data pointer from the stack. | ||||||
| E022 | DEC HL | Step back to the entity handler address field. | ||||||
| E023 | DEC HL | |||||||
| E024 | DEC HL | |||||||
| E025 | LD DE,$E02C | Load Process_Entity_Record_Next7 as the replacement entity handler. | ||||||
| E028 | LD (HL),E | Write Process_Entity_Record_Next7 into the entity handler address field. | ||||||
| E029 | INC HL | |||||||
| E02A | LD (HL),D | |||||||
| E02B | INC HL | |||||||
|
This entry point is used by the routines at Handle_Homing_Enemy and Animate_Wall_Bouncing_Enemy_Death.
|
||||||||
| Process_Entity_Record_Next7 | E02C | LD DE,$0007 | Skip to the next entity record and return. | |||||
| E02F | ADD HL,DE | |||||||
| E030 | 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 | E031 | INC HL | Move past the animation counter byte. | |||||
| E032 | PUSH HL | Stash the entity data pointer on the stack. | ||||||
| E033 | CALL Erase_Wide_Entity_Sprite | Call Erase_Wide_Entity_Sprite to erase any residual sprite at the spawn position. | ||||||
| E036 | POP HL | Restore the entity data pointer from the stack. | ||||||
| E037 | INC HL | Move to the entity's Y position. | ||||||
| E038 | EXX | Set the play area boundary data address for the bounds check. | ||||||
| E039 | LD HL,$C4D4 | |||||||
| E03C | EXX | |||||||
| E03D | CALL HitTestBounds8AtHL | Call HitTestBounds8AtHL to test if the spawn position is within the play area. | ||||||
| E040 | JP NC,Process_Entity_Record_Kill | Jump to Process_Entity_Record_Kill if the position is outside the play area. | ||||||
| E043 | DEC HL | Step back to the entity type state byte. | ||||||
| E044 | DEC HL | |||||||
| E045 | DEC HL | |||||||
| E046 | CALL Generate_Random_Byte | Call Generate_Random_Byte to determine whether the enemy should change type. | ||||||
| E049 | CP $F0 | Stay with the current enemy type if the random roll is below F0. | ||||||
| E04B | JP C,Process_Entity_Record_Keep_Type | |||||||
| Process_Entity_Record_Cycle_Type | E04E | DEC HL | Step back to the entity type state byte. | |||||
| E04F | LD A,(HL) | Read the entity type state. | ||||||
| E050 | INC A | Advance to the next animation variant. | ||||||
| E051 | AND %00110011 | Wrap within the valid entity type range (33). | ||||||
| E053 | LD (HL),A | Save the new entity type state. | ||||||
| E054 | INC HL | Move to the entity's animation frame data. | ||||||
| E055 | JP Process_Entity_Record_Apply_Delta | Jump to Process_Entity_Record_Apply_Delta. | ||||||
|
The random roll was below F0 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 | E058 | DEC HL | Step back to the entity type state byte. | |||||
| E059 | LD A,(HL) | Read the entity type state. | ||||||
| E05A | 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 | E05B | EX DE,HL | Preserve the entity data pointer in DE. | |||||
| E05C | AND %00000011 | Isolate the movement direction (two bits). | ||||||
| E05E | SLA A | Index into the direction delta table at Direction_Delta_Table. | ||||||
| E060 | LD C,A | |||||||
| E061 | LD B,$00 | |||||||
| E063 | LD HL,$E11A | |||||||
| E066 | ADD HL,BC | |||||||
| E067 | EX DE,HL | Restore HL to the entity data and DE to the delta entry. | ||||||
| E068 | LD A,(DE) | Apply the Y movement delta to the enemy's current Y position. | ||||||
| E069 | ADD A,(HL) | |||||||
| E06A | CP $AB | Retry with a new type if the enemy moves below the play area. | ||||||
| E06C | JP NC,Process_Entity_Record_Cycle_Type | |||||||
| E06F | CP $10 | Retry with a new type if the enemy moves above the play area. | ||||||
| E071 | JP C,Process_Entity_Record_Cycle_Type | |||||||
| E074 | LD C,A | Save the validated Y position. | ||||||
| E075 | INC HL | Advance to the enemy's X position and the X delta. | ||||||
| E076 | INC DE | |||||||
| E077 | LD A,(DE) | Apply the X movement delta to the enemy's current X position. | ||||||
| E078 | ADD A,(HL) | |||||||
| E079 | CP $F1 | Jump to Process_Entity_Record_Retry if the new X overshoots the right edge. | ||||||
| E07B | JP NC,Process_Entity_Record_Retry | |||||||
| E07E | CP $08 | Accept the position if it is within the play area's left boundary. | ||||||
| E080 | JP NC,Process_Entity_Record_Register | |||||||
| Process_Entity_Record_Retry | E083 | DEC HL | Step back to the Y delta entry. | |||||
| E084 | 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 | E087 | LD (HL),A | Write the new screen position into the entity record. | |||||
| E088 | DEC HL | |||||||
| E089 | LD (HL),C | |||||||
| E08A | DEC HL | |||||||
| E08B | PUSH HL | Stash the entity record pointer on the stack. | ||||||
| E08C | EXX | Set the spawn display attribute (INK: WHITE, PAPER: BLACK (BRIGHT) ) in the shadow register. | ||||||
| E08D | LD B,$47 | |||||||
| E08F | EXX | |||||||
| E090 | CALL Draw_Wide_Entity_Sprite | Call Draw_Wide_Entity_Sprite to spawn the enemy and draw it on screen. | ||||||
| E093 | 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 | E094 | LD DE,$0006 | Skip to the next entity record and return. | |||||
| E097 | ADD HL,DE | |||||||
| E098 | 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 | E099 | EX DE,HL | Preserve the entity list pointer in DE. | |||||
| E09A | LD HL,($C535) | Add 40 to *C535. | ||||||
| E09D | LD BC,$0040 | |||||||
| E0A0 | ADD HL,BC | |||||||
| E0A1 | LD ($C535),HL | |||||||
| E0A4 | EX DE,HL | Restore the entity list pointer. | ||||||
| E0A5 | 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 | E0A8 | EX DE,HL | Preserve the entity list pointer in DE. | |||||
| E0A9 | LD HL,($C535) | Add 40 to *C535. | ||||||
| E0AC | LD BC,$0040 | |||||||
| E0AF | ADD HL,BC | |||||||
| E0B0 | LD ($C535),HL | |||||||
| E0B3 | EX DE,HL | Restore the entity list pointer. | ||||||
| E0B4 | 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 | E0B7 | DEC HL | Rewind to the entity handler address field. | |||||
| E0B8 | DEC HL | |||||||
| E0B9 | DEC HL | |||||||
| E0BA | DEC HL | |||||||
| E0BB | DEC HL | |||||||
| E0BC | LD (HL),$32 | Switch the entity to the kill sequence handler. | ||||||
| E0BE | INC HL | Move to the entity colour attribute byte. | ||||||
| E0BF | LD A,(HL) | Read the entity colour attribute. | ||||||
| E0C0 | PUSH AF | Stash the entity colour attribute on the stack. | ||||||
| E0C1 | LD A,($C4DE) | Set the entity's death colour from the current kill tally. | ||||||
| E0C4 | ADD A,$13 | |||||||
| E0C6 | LD (HL),A | |||||||
| E0C7 | PUSH HL | Stash the attribute pointer on the stack. | ||||||
| E0C8 | EXX | Set the death flash attribute ( WHITE) in the shadow register. | ||||||
| E0C9 | LD B,$07 | |||||||
| E0CB | EXX | |||||||
| E0CC | CALL Draw_Entity_Sprite | Call Draw_Entity_Sprite to draw the entity's death animation sprite. | ||||||
| E0CF | POP HL | Restore the attribute pointer from the stack. | ||||||
| E0D0 | LD A,($C4DE) | Read the enemy kill value from the wave counter. | ||||||
| E0D3 | SLA A | Multiply by 10 for the score contribution. | ||||||
| E0D5 | SLA A | |||||||
| E0D7 | SLA A | |||||||
| E0D9 | SLA A | |||||||
| E0DB | EX DE,HL | Save the entity pointer while accessing the score. | ||||||
| E0DC | LD HL,$C405 | Point HL at the player's score. | ||||||
| E0DF | ADD A,(HL) | Add the kill score to the ones digit of the player's score (BCD). | ||||||
| E0E0 | DAA | |||||||
| E0E1 | LD (HL),A | |||||||
| E0E2 | JP NC,Process_Entity_Record_Wave_Count | Jump to Process_Entity_Record_Wave_Count if the ones digit did not overflow. | ||||||
| E0E5 | DEC HL | Move to the tens digit. | ||||||
| E0E6 | LD A,$01 | Carry one into the tens digit of the player's score (BCD). | ||||||
| E0E8 | ADD A,(HL) | |||||||
| E0E9 | DAA | |||||||
| E0EA | LD (HL),A | |||||||
| E0EB | JP NC,Process_Entity_Record_Wave_Count | Jump to Process_Entity_Record_Wave_Count if the tens digit did not overflow. | ||||||
| E0EE | DEC HL | Move to the hundreds digit. | ||||||
| E0EF | LD A,$01 | Carry one into the hundreds digit of the player's score (BCD). | ||||||
| E0F1 | ADD A,(HL) | |||||||
| E0F2 | DAA | |||||||
| E0F3 | LD (HL),A | |||||||
| Process_Entity_Record_Wave_Count | E0F4 | LD A,($C4DE) | Jump to Process_Entity_Record_Decrement_Count if the maximum kill count for this wave is reached. | |||||
| E0F7 | CP $05 | |||||||
| E0F9 | JP Z,Process_Entity_Record_Decrement_Count | |||||||
| E0FC | INC A | Increment the wave kill counter. | ||||||
| E0FD | LD ($C4DE),A | |||||||
| Process_Entity_Record_Decrement_Count | E100 | POP AF | Restore the entity colour attribute from the stack. | |||||
| E101 | SRL A | Extract the entity type to use as a count table index. | ||||||
| E103 | SRL A | |||||||
| E105 | SRL A | |||||||
| E107 | SRL A | |||||||
| E109 | LD C,A | |||||||
| E10A | LD B,$00 | Form a pointer to the entity count entry for this type. | ||||||
| E10C | LD HL,$C427 | |||||||
| E10F | ADD HL,BC | |||||||
| E110 | DEC (HL) | Decrement the on-screen enemy count for this type. | ||||||
| E111 | EX DE,HL | Restore the entity list pointer. | ||||||
| E112 | PUSH HL | Stash the entity list pointer on the stack. | ||||||
| E113 | CALL Clear_Colour_Bar_Column | Call Clear_Colour_Bar_Column to update the score and wave display. | ||||||
| E116 | POP HL | Restore the entity list pointer from the stack. | ||||||
| E117 | 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 | E11A | DEFB $FF,$00 | ||||||
| E11C | DEFB $00,$01 | |||||||
| E11E | DEFB $01,$00 | |||||||
| E120 | DEFB $00,$FF | |||||||
| Prev: DDF9 | Up: Map | Next: E122 |