![]() |
Routines |
| Prev: EA17 | Up: Map | Next: EAF7 |
|
Per-frame handler for the replacement entity spawned by Handle_Enemy_Collision_Chain. Jumps to Process_Final_Phase_Enemy_Entity if the countdown has already expired. Otherwise locates the associated entity record pointer and jumps to Process_Replacement_Enemy_Entity_Retire to retire if the associated record is in settled state (02). Decrements the countdown and calls Draw_Wide_Entity_Sprite to erase. If the countdown is still non-zero, applies a random X nudge (±7) and spawns via Draw_Wide_Entity_Sprite. If the countdown reaches zero, copies entity data, resets state, and spawns via Process_Replacement_Enemy_Entity_Spawn. When settled, installs the retire handler Process_Entity_Record_Fast.
|
||||||||
|
Test the countdown and locate the associated entity record.
|
||||||||
| Process_Replacement_Enemy_Entity | EA6E | LD A,(HL) | Jump to Process_Final_Phase_Enemy_Entity if the entity countdown has already expired. | |||||
| EA6F | AND A | |||||||
| EA70 | JP Z,Process_Final_Phase_Enemy_Entity | |||||||
| EA73 | LD B,H | Save the entity pointer in BC and load the associated entity record pointer from offset 05. | ||||||
| EA74 | LD C,L | |||||||
| EA75 | LD DE,$0005 | |||||||
| EA78 | ADD HL,DE | |||||||
| EA79 | LD E,(HL) | |||||||
| EA7A | INC HL | |||||||
| EA7B | LD D,(HL) | |||||||
| EA7C | LD A,(DE) | Read the associated entity state, restore HL, and jump to Process_Replacement_Enemy_Entity_Retire if settled (02). | ||||||
| EA7D | CP $02 | |||||||
| EA7F | LD H,B | |||||||
| EA80 | LD L,C | |||||||
| EA81 | JR Z,Process_Replacement_Enemy_Entity_Retire | |||||||
| EA83 | DEC (HL) | Decrement the entity countdown. | ||||||
|
Erase the entity with colour INK:
RED,
PAPER:
BLACK
(BRIGHT)
.
|
||||||||
| EA84 | PUSH HL | Stash the entity pointer on the stack. | ||||||
| EA85 | INC HL | Advance to the entity position. | ||||||
| EA86 | EXX | Load INK: RED, PAPER: BLACK (BRIGHT) into B'. | ||||||
| EA87 | LD B,$42 | |||||||
| EA89 | EXX | |||||||
| EA8A | CALL Draw_Wide_Entity_Sprite | Call Draw_Wide_Entity_Sprite to erase the entity. | ||||||
| EA8D | POP HL | Restore the entity pointer from the stack. | ||||||
|
Test the countdown and branch.
|
||||||||
| EA8E | LD A,(HL) | Jump to Process_Replacement_Enemy_Entity_Settle if the countdown has reached zero. | ||||||
| EA8F | AND A | |||||||
| EA90 | JR Z,Process_Replacement_Enemy_Entity_Settle | |||||||
| EA92 | INC HL | Advance two bytes into the entity record. | ||||||
| EA93 | INC HL | |||||||
|
Apply a random X nudge to the entity position.
|
||||||||
| EA94 | INC HL | Advance two more bytes to the X position field. | ||||||
| EA95 | INC HL | |||||||
| EA96 | CALL Generate_Random_Byte | Call Generate_Random_Byte to generate a random byte. | ||||||
| EA99 | AND %00001111 | Mask to the lower four bits. | ||||||
| EA9B | SUB $07 | Subtract 07 to produce a nudge in the range F9–07. | ||||||
| EA9D | ADD A,(HL) | Apply the nudge to the entity X position and step back two bytes. | ||||||
| EA9E | DEC HL | |||||||
| EA9F | DEC HL | |||||||
| EAA0 | LD (HL),A | |||||||
| EAA1 | DEC HL | Step back one more byte to the entity record position field. | ||||||
| EAA2 | PUSH HL | Stash the entity record pointer on the stack. | ||||||
|
Generate a random spawn colour and spawn the entity.
|
||||||||
| Process_Replacement_Enemy_Entity_Spawn | EAA3 | EXX | Switch to alternate registers. | |||||
| EAA4 | CALL Generate_Random_Byte | Call Generate_Random_Byte to generate a random colour byte. | ||||||
| EAA7 | AND %00111000 | Mask to bits 3–5 to select the spawn colour. | ||||||
| EAA9 | LD B,A | Load the colour into B and switch to main registers. | ||||||
| EAAA | EXX | |||||||
| EAAB | CALL Draw_Wide_Entity_Sprite | Call Draw_Wide_Entity_Sprite to spawn the entity. | ||||||
| EAAE | POP HL | Restore the entity record pointer from the stack. | ||||||
| EAAF | JP Process_Entity_Record_Next6 | Jump to Process_Entity_Record_Next6 to advance the entity pointer. | ||||||
|
Copy entity data and reset the settle state.
|
||||||||
| Process_Replacement_Enemy_Entity_Settle | EAB2 | INC HL | Step two bytes ahead, copy HL to DE, step two more, and copy one byte to the destination. | |||||
| EAB3 | INC HL | |||||||
| EAB4 | LD D,H | |||||||
| EAB5 | LD E,L | |||||||
| EAB6 | INC HL | |||||||
| EAB7 | INC HL | |||||||
| EAB8 | LDI | |||||||
| EABA | LD C,(HL) | Read the countdown into C, reset it to 0A advance, and read the type byte into B. | ||||||
| EABB | LD (HL),$0A | |||||||
| EABD | INC HL | |||||||
| EABE | LD B,(HL) | |||||||
| EABF | LD (HL),$FF | Reset the type field to FF write state value 0F to *DE and 0C to *BC. | ||||||
| EAC1 | INC DE | |||||||
| EAC2 | LD A,$0F | |||||||
| EAC4 | LD (DE),A | |||||||
| EAC5 | LD A,$0C | |||||||
| EAC7 | LD (BC),A | |||||||
| EAC8 | DEC DE | Step DE back three bytes, stash DE, exchange DE and HL, and jump to Process_Replacement_Enemy_Entity_Spawn. | ||||||
| EAC9 | DEC DE | |||||||
| EACA | DEC DE | |||||||
| EACB | PUSH DE | |||||||
| EACC | EX DE,HL | |||||||
| EACD | JP Process_Replacement_Enemy_Entity_Spawn | |||||||
|
Write the retire handler, erase the sprite, draw, and return.
|
||||||||
| Process_Replacement_Enemy_Entity_Retire | EAD0 | LD DE,$E003 | Write the retire handler Process_Entity_Record_Fast and state byte 32 into the entity record. | |||||
| EAD3 | DEC HL | |||||||
| EAD4 | LD (HL),D | |||||||
| EAD5 | DEC HL | |||||||
| EAD6 | LD (HL),E | |||||||
| EAD7 | INC HL | |||||||
| EAD8 | INC HL | |||||||
| EAD9 | LD (HL),$32 | |||||||
| EADB | INC HL | |||||||
| EADC | PUSH HL | Stash the entity pointer on the stack. | ||||||
| EADD | CALL Erase_Wide_Entity_Sprite | Call Erase_Wide_Entity_Sprite to erase the entity sprite. | ||||||
| EAE0 | POP HL | Restore the entity pointer from the stack. | ||||||
| EAE1 | LD (HL),$0F | Write the state timer 0F. | ||||||
| EAE3 | PUSH HL | Stash the entity pointer on the stack. | ||||||
| EAE4 | EXX | Load INK: WHITE, PAPER: BLACK (BRIGHT) into B'. | ||||||
| EAE5 | LD B,$47 | |||||||
| EAE7 | EXX | |||||||
| EAE8 | CALL Draw_Entity_Sprite | Call Draw_Entity_Sprite to draw the entity. | ||||||
| EAEB | POP HL | Restore the entity pointer from the stack. | ||||||
| EAEC | INC HL | Advance one byte and copy HL to DE. | ||||||
| EAED | LD D,H | |||||||
| EAEE | LD E,L | |||||||
| EAEF | INC HL | Step four bytes to the end-marker field. | ||||||
| EAF0 | INC HL | |||||||
| EAF1 | INC HL | |||||||
| EAF2 | INC HL | |||||||
| EAF3 | LD (HL),$FF | Write the end marker FF. | ||||||
| EAF5 | INC HL | Advance to the next entity slot. | ||||||
| EAF6 | RET | Return. | ||||||
| Prev: EA17 | Up: Map | Next: EAF7 |