Prev: 59919 Up: Map Next: 60014
59927: 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 59927 EXX Switch to alternate registers.
59928 DEC HL Step back five bytes to the entity active flag.
59929 DEC HL
59930 DEC HL
59931 DEC HL
59932 DEC HL
59933 LD (HL),1 Set the entity active flag to 1.
59935 PUSH HL Stash the entity record pointer on the stack.
59936 EXX Switch to main registers.
Read the entity state and extract the type index.
59937 DEC HL Step back through the record and read the entity type into B and the count into C.
59938 DEC HL
59939 LD B,(HL)
59940 DEC HL
59941 LD C,(HL)
59942 DEC HL Read the entity state byte into A, write the countdown timer 15 and stash the record pointer.
59943 LD A,(HL)
59944 LD (HL),15
59946 PUSH HL
59947 LD E,A Extract the entity type index (upper nibble of A) into DE.
59948 SRL E
59950 SRL E
59952 SRL E
59954 SRL E
59956 LD D,0
Decrement the slot count and install the retire handler.
59958 LD HL,50215 Look up the slot count at Table_SlotCount and decrement it.
59961 ADD HL,DE
59962 DEC (HL)
59963 POP HL Restore the entity record pointer from the stack.
59964 DEC HL Step back to the retire handler field.
59965 DEC HL
59966 LD DE,57388 Write the retire handler Process_Entity_Record_Next7 into the entity record.
59969 LD (HL),D
59970 DEC HL
59971 LD (HL),E
Open a new entity record for the replacement handler.
59972 LD HL,(50441) Load the entity list write pointer from Entity_List_Write_Pointer and write the Process_Replacement_Enemy_Entity handler and state byte 35.
59975 LD DE,60014
59978 LD (HL),E
59979 INC HL
59980 LD (HL),D
59981 INC HL
59982 LD (HL),35
59984 INC HL
Write the entity fields and save the list pointer.
59985 LD (HL),A Write the entity state, count, type, and count to the replacement record.
59986 INC HL
59987 LD (HL),C
59988 INC HL
59989 LD (HL),B
59990 INC HL
59991 LD (HL),C
59992 INC HL
59993 POP DE Restore the entity record pointer from the stack.
59994 LD (HL),E Write the entity record pointer into the replacement record and save the updated list pointer to Entity_List_Write_Pointer.
59995 INC HL
59996 LD (HL),D
59997 INC HL
59998 LD (50441),HL
Close the entity list and advance to the draw step.
60001 LD DE,53668 Write the list terminator Entity_List_Reset and end marker 255.
60004 LD (HL),E
60005 INC HL
60006 LD (HL),D
60007 INC HL
60008 LD (HL),255
60010 EXX Switch to alternate registers and jump to Process_Wall_Bouncing_Enemy_Advance.
60011 JP Process_Wall_Bouncing_Enemy_Advance
Prev: 59919 Up: Map Next: 60014