Prev: D570 Up: Map Next: D620
D5B1: Remove Entity from List
Removes the entity whose record is pointed to by Entity_Record_Pointer from the entity list. Steps back to the start of the entity's 12-byte record, then block-copies all subsequent records down by 12 bytes via LDIR, closing the gap. The entity list end pointer at Playfield_Entity_List_Pointer is decremented by 12 to reflect the shorter list. Returns with HL pointing to the record that now occupies the removed entity's slot.
Remove_Entity_From_List D5B1 LD HL,($C4DA) Load the entity record pointer from Entity_Record_Pointer.
This entry point is used by the routines at Kill_Tracked_Enemy_Entity and Process_Cluster_Entity.
Remove_Entity_From_List_Step D5B4 DEC HL Step back to the start of the entity record and save the updated pointer to Entity_Record_Pointer.
D5B5 DEC HL
D5B6 LD ($C4DA),HL
D5B9 LD DE,$000C Compute the start of the next entity record (12 bytes ahead) in DE.
D5BC ADD HL,DE
D5BD EX DE,HL
D5BE LD HL,($C4D1) Load the entity list end pointer from Playfield_Entity_List_Pointer, subtract the destination address to get the copy byte count, and load that count into BC.
D5C1 SBC HL,DE
D5C3 INC HL
D5C4 INC HL
D5C5 INC HL
D5C6 LD B,H
D5C7 LD C,L
D5C8 LD HL,($C4DA) Set source to the start of the next entity record and shift all remaining records down by 12 bytes via LDIR.
D5CB EX DE,HL
D5CC LDIR
D5CE LD HL,($C4D1) Decrement the entity list end pointer at Playfield_Entity_List_Pointer by 12 bytes and return with HL pointing to the new occupant of the vacated slot.
D5D1 LD DE,$000C
D5D4 SBC HL,DE
D5D6 LD ($C4D1),HL
D5D9 LD HL,($C4DA)
D5DC RET Return.
Entity movement handler, stored as the entity handler address in entity records that use the narrow sprite renderer. Applies the entity's velocity to its current screen position, validates that the new position lies within the playfield bounds, updates the entity record, and redraws the sprite. If the new position is out of bounds the entity is removed via Remove_Entity_From_List.
Move_And_Redraw_Entity D5DD LD ($C4DA),HL Save the entity record pointer to Entity_Record_Pointer.
D5E0 CALL Erase_Narrow_Entity_Sprite Erase the entity's current sprite via Erase_Narrow_Entity_Sprite.
D5E3 LD HL,($C4DA) Reload the entity record from Entity_Record_Pointer and point HL at the Y position field; copy the pointer to DE.
D5E6 INC HL
D5E7 INC HL
D5E8 INC HL
D5E9 LD D,H
D5EA LD E,L
D5EB INC DE Advance DE to the Y velocity field and add the velocity to the current Y position.
D5EC INC DE
D5ED INC DE
D5EE INC DE
D5EF LD A,(DE)
D5F0 ADD A,(HL)
D5F1 CP $10
D5F3 JR C,Remove_Entity_From_List Reject the move if the new Y position is above the playfield top edge (10).
D5F5 CP $B8
D5F7 JR NC,Remove_Entity_From_List Reject the move if the new Y position is below the playfield bottom edge (B8).
D5F9 LD (HL),A Store the new Y position; advance to the X fields and add the X velocity to the current X position.
D5FA LD B,A
D5FB INC DE
D5FC INC HL
D5FD LD A,(DE)
D5FE ADD A,(HL)
D5FF CP $08 Reject the move if the new X position is past the left edge (08).
D601 JR C,Remove_Entity_From_List Remove the entity if the new X position is too close to the left wall.
D603 CP $F8 Reject the move if the new X position is past the right edge (F8).
D605 JR NC,Remove_Entity_From_List Remove the entity if the new X position is too close to the right wall.
D607 LD (HL),A Store the new X position; step back and update the two additional entity record fields from their corresponding velocity bytes.
D608 DEC HL
D609 DEC HL
D60A LD A,(DE)
D60B ADD A,(HL)
D60C LD (HL),A
D60D DEC HL
D60E DEC DE
D60F LD A,(DE)
D610 ADD A,(HL) Update the final position field and step back to the entity record origin.
D611 LD (HL),A
D612 DEC HL
D613 EXX Set the entity colour to INK: WHITE, PAPER: BLACK (BRIGHT) in B' and redraw the sprite via Draw_Narrow_Entity_Sprite.
D614 LD B,$47
D616 EXX
D617 CALL Draw_Narrow_Entity_Sprite
D61A LD HL,($C4DA) Reload the entity record pointer from Entity_Record_Pointer.
D61D JP Advance_Entity_Pointer Jump to the entity update completion handler at Advance_Entity_Pointer.
Prev: D570 Up: Map Next: D620