![]() |
Routines |
| Prev: 59927 | Up: Map | Next: 60151 |
|
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 (2). 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 | 60014 | LD A,(HL) | Jump to Process_Final_Phase_Enemy_Entity if the entity countdown has already expired. | |||||
| 60015 | AND A | |||||||
| 60016 | JP Z,Process_Final_Phase_Enemy_Entity | |||||||
| 60019 | LD B,H | Save the entity pointer in BC and load the associated entity record pointer from offset 5. | ||||||
| 60020 | LD C,L | |||||||
| 60021 | LD DE,5 | |||||||
| 60024 | ADD HL,DE | |||||||
| 60025 | LD E,(HL) | |||||||
| 60026 | INC HL | |||||||
| 60027 | LD D,(HL) | |||||||
| 60028 | LD A,(DE) | Read the associated entity state, restore HL, and jump to Process_Replacement_Enemy_Entity_Retire if settled (2). | ||||||
| 60029 | CP 2 | |||||||
| 60031 | LD H,B | |||||||
| 60032 | LD L,C | |||||||
| 60033 | JR Z,Process_Replacement_Enemy_Entity_Retire | |||||||
| 60035 | DEC (HL) | Decrement the entity countdown. | ||||||
|
Erase the entity with colour INK:
RED,
PAPER:
BLACK
(BRIGHT)
.
|
||||||||
| 60036 | PUSH HL | Stash the entity pointer on the stack. | ||||||
| 60037 | INC HL | Advance to the entity position. | ||||||
| 60038 | EXX | Load INK: RED, PAPER: BLACK (BRIGHT) into B'. | ||||||
| 60039 | LD B,66 | |||||||
| 60041 | EXX | |||||||
| 60042 | CALL Draw_Wide_Entity_Sprite | Call Draw_Wide_Entity_Sprite to erase the entity. | ||||||
| 60045 | POP HL | Restore the entity pointer from the stack. | ||||||
|
Test the countdown and branch.
|
||||||||
| 60046 | LD A,(HL) | Jump to Process_Replacement_Enemy_Entity_Settle if the countdown has reached zero. | ||||||
| 60047 | AND A | |||||||
| 60048 | JR Z,Process_Replacement_Enemy_Entity_Settle | |||||||
| 60050 | INC HL | Advance two bytes into the entity record. | ||||||
| 60051 | INC HL | |||||||
|
Apply a random X nudge to the entity position.
|
||||||||
| 60052 | INC HL | Advance two more bytes to the X position field. | ||||||
| 60053 | INC HL | |||||||
| 60054 | CALL Generate_Random_Byte | Call Generate_Random_Byte to generate a random byte. | ||||||
| 60057 | AND %00001111 | Mask to the lower four bits. | ||||||
| 60059 | SUB 7 | Subtract 7 to produce a nudge in the range 249–7. | ||||||
| 60061 | ADD A,(HL) | Apply the nudge to the entity X position and step back two bytes. | ||||||
| 60062 | DEC HL | |||||||
| 60063 | DEC HL | |||||||
| 60064 | LD (HL),A | |||||||
| 60065 | DEC HL | Step back one more byte to the entity record position field. | ||||||
| 60066 | PUSH HL | Stash the entity record pointer on the stack. | ||||||
|
Generate a random spawn colour and spawn the entity.
|
||||||||
| Process_Replacement_Enemy_Entity_Spawn | 60067 | EXX | Switch to alternate registers. | |||||
| 60068 | CALL Generate_Random_Byte | Call Generate_Random_Byte to generate a random colour byte. | ||||||
| 60071 | AND %00111000 | Mask to bits 3–5 to select the spawn colour. | ||||||
| 60073 | LD B,A | Load the colour into B and switch to main registers. | ||||||
| 60074 | EXX | |||||||
| 60075 | CALL Draw_Wide_Entity_Sprite | Call Draw_Wide_Entity_Sprite to spawn the entity. | ||||||
| 60078 | POP HL | Restore the entity record pointer from the stack. | ||||||
| 60079 | 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 | 60082 | INC HL | Step two bytes ahead, copy HL to DE, step two more, and copy one byte to the destination. | |||||
| 60083 | INC HL | |||||||
| 60084 | LD D,H | |||||||
| 60085 | LD E,L | |||||||
| 60086 | INC HL | |||||||
| 60087 | INC HL | |||||||
| 60088 | LDI | |||||||
| 60090 | LD C,(HL) | Read the countdown into C, reset it to 10 advance, and read the type byte into B. | ||||||
| 60091 | LD (HL),10 | |||||||
| 60093 | INC HL | |||||||
| 60094 | LD B,(HL) | |||||||
| 60095 | LD (HL),255 | Reset the type field to 255 write state value 15 to *DE and 12 to *BC. | ||||||
| 60097 | INC DE | |||||||
| 60098 | LD A,15 | |||||||
| 60100 | LD (DE),A | |||||||
| 60101 | LD A,12 | |||||||
| 60103 | LD (BC),A | |||||||
| 60104 | DEC DE | Step DE back three bytes, stash DE, exchange DE and HL, and jump to Process_Replacement_Enemy_Entity_Spawn. | ||||||
| 60105 | DEC DE | |||||||
| 60106 | DEC DE | |||||||
| 60107 | PUSH DE | |||||||
| 60108 | EX DE,HL | |||||||
| 60109 | JP Process_Replacement_Enemy_Entity_Spawn | |||||||
|
Write the retire handler, erase the sprite, draw, and return.
|
||||||||
| Process_Replacement_Enemy_Entity_Retire | 60112 | LD DE,57347 | Write the retire handler Process_Entity_Record_Fast and state byte 50 into the entity record. | |||||
| 60115 | DEC HL | |||||||
| 60116 | LD (HL),D | |||||||
| 60117 | DEC HL | |||||||
| 60118 | LD (HL),E | |||||||
| 60119 | INC HL | |||||||
| 60120 | INC HL | |||||||
| 60121 | LD (HL),50 | |||||||
| 60123 | INC HL | |||||||
| 60124 | PUSH HL | Stash the entity pointer on the stack. | ||||||
| 60125 | CALL Erase_Wide_Entity_Sprite | Call Erase_Wide_Entity_Sprite to erase the entity sprite. | ||||||
| 60128 | POP HL | Restore the entity pointer from the stack. | ||||||
| 60129 | LD (HL),15 | Write the state timer 15. | ||||||
| 60131 | PUSH HL | Stash the entity pointer on the stack. | ||||||
| 60132 | EXX | Load INK: WHITE, PAPER: BLACK (BRIGHT) into B'. | ||||||
| 60133 | LD B,71 | |||||||
| 60135 | EXX | |||||||
| 60136 | CALL Draw_Entity_Sprite | Call Draw_Entity_Sprite to draw the entity. | ||||||
| 60139 | POP HL | Restore the entity pointer from the stack. | ||||||
| 60140 | INC HL | Advance one byte and copy HL to DE. | ||||||
| 60141 | LD D,H | |||||||
| 60142 | LD E,L | |||||||
| 60143 | INC HL | Step four bytes to the end-marker field. | ||||||
| 60144 | INC HL | |||||||
| 60145 | INC HL | |||||||
| 60146 | INC HL | |||||||
| 60147 | LD (HL),255 | Write the end marker 255. | ||||||
| 60149 | INC HL | Advance to the next entity slot. | ||||||
| 60150 | RET | Return. | ||||||
| Prev: 59927 | Up: Map | Next: 60151 |