Prev: EA0F Up: Map Next: EA6E
EA17: Handle Enemy Collision Chain
Used by the routine at Process_Wall_Bouncing_Enemy.
Reached from Process_Wall_Bouncing_Enemy when the bouncer finds no collision partner. Flags the entity as active, reads the entity type and state, decrements the slot count at Table_SlotCount, and installs the retire handler Process_Entity_Record_Next7. Then appends a replacement entity record (handler Process_Replacement_Enemy_Entity) to the entity list at *Entity_List_Write_Pointer, writes the list terminator Entity_List_Reset, and jumps to Process_Wall_Bouncing_Enemy_Advance to redraw without moving.
Input
HL Entity record pointer
Flag the bouncer as active and save the entity record pointer.
Handle_Enemy_Collision_Chain EA17 EXX Switch to alternate registers.
EA18 DEC HL Step back five bytes to the entity active flag.
EA19 DEC HL
EA1A DEC HL
EA1B DEC HL
EA1C DEC HL
EA1D LD (HL),$01 Set the entity active flag to 01.
EA1F PUSH HL Stash the entity record pointer on the stack.
EA20 EXX Switch to main registers.
Read the entity state and extract the type index.
EA21 DEC HL Step back through the record and read the entity type into B and the count into C.
EA22 DEC HL
EA23 LD B,(HL)
EA24 DEC HL
EA25 LD C,(HL)
EA26 DEC HL Read the entity state byte into A, write the countdown timer 0F and stash the record pointer.
EA27 LD A,(HL)
EA28 LD (HL),$0F
EA2A PUSH HL
EA2B LD E,A Extract the entity type index (upper nibble of A) into DE.
EA2C SRL E
EA2E SRL E
EA30 SRL E
EA32 SRL E
EA34 LD D,$00
Decrement the slot count and install the retire handler.
EA36 LD HL,$C427 Look up the slot count at Table_SlotCount and decrement it.
EA39 ADD HL,DE
EA3A DEC (HL)
EA3B POP HL Restore the entity record pointer from the stack.
EA3C DEC HL Step back to the retire handler field.
EA3D DEC HL
EA3E LD DE,$E02C Write the retire handler Process_Entity_Record_Next7 into the entity record.
EA41 LD (HL),D
EA42 DEC HL
EA43 LD (HL),E
Open a new entity record for the replacement handler.
EA44 LD HL,($C509) Load the entity list write pointer from Entity_List_Write_Pointer and write the Process_Replacement_Enemy_Entity handler and state byte 23.
EA47 LD DE,$EA6E
EA4A LD (HL),E
EA4B INC HL
EA4C LD (HL),D
EA4D INC HL
EA4E LD (HL),$23
EA50 INC HL
Write the entity fields and save the list pointer.
EA51 LD (HL),A Write the entity state, count, type, and count to the replacement record.
EA52 INC HL
EA53 LD (HL),C
EA54 INC HL
EA55 LD (HL),B
EA56 INC HL
EA57 LD (HL),C
EA58 INC HL
EA59 POP DE Restore the entity record pointer from the stack.
EA5A LD (HL),E Write the entity record pointer into the replacement record and save the updated list pointer to Entity_List_Write_Pointer.
EA5B INC HL
EA5C LD (HL),D
EA5D INC HL
EA5E LD ($C509),HL
Close the entity list and advance to the draw step.
EA61 LD DE,$D1A4 Write the list terminator Entity_List_Reset and end marker FF.
EA64 LD (HL),E
EA65 INC HL
EA66 LD (HL),D
EA67 INC HL
EA68 LD (HL),$FF
EA6A EXX Switch to alternate registers and jump to Process_Wall_Bouncing_Enemy_Advance.
EA6B JP Process_Wall_Bouncing_Enemy_Advance
Prev: EA0F Up: Map Next: EA6E