Prev: D1CE Up: Map Next: D2F0
D2BF: Remove an object that Dan collided with from the room.
Used by the routine at D1CE.
Input
A Count of objects in the room
BC Pointer to the moving graphics buffer
IY Pointer to moving objects data in the room
D2BF AND A Are there any objects left?
D2C0 RET Z Return if there aren't.
D2C1 LD L,A Put the object count in HL.
D2C2 LD A,($D1CD) Get the collision attribute (D1CD).
D2C5 CP (IY+$05) Does it equal this one?
D2C8 JR NZ,$D2D5 Move forward if it doesn't.
The attribute matches the one collided with, now check the position.
D2CA LD E,(IY+$00) Put the co-ordinates in DE.
D2CD LD D,(IY+$01)
D2D0 CALL $DB38 Has Dan collided with it?
D2D3 JR C,$D2DE Yes, so remove it.
D2D5 LD DE,$0008 Otherwise, move to the next object.
D2D8 ADD IY,DE
D2DA DEC L Decrement the object count.
D2DB JR NZ,$D2C2 Loop until we've looked at all objects.
D2DD RET
Found the object Dan collided with, so remove it.
D2DE LD D,(IY+$01) Put the position of the object in DE.
D2E1 LD A,(IY+$00)
D2E4 ADD A,C
D2E5 DEC A
D2E6 LD E,A
D2E7 SET 6,(IY+$04) Set the "object removed" flag.
D2EB CALL $E897 Remove the object from screen.
D2EE POP HL Clear the stack, so return won't pass to the calling routine (D1CE) but to the routine above that ie: do an early return. (For homework, look up "tail call optimisation").
D2EF RET
Prev: D1CE Up: Map Next: D2F0