Prev: CF9F Up: Map Next: CFE1
CFA5: Compare With Other Object
Handles the other object having to be drawn first. It becomes the first object, and the comparisons start again from the beginning of the list. The objects that have taken the place of the first object are kept in the list at ObjectChain. If the other object is already there the objects hold each other up, and the other object is drawn to break the loop.
Input
IY Address of the other object
Draw the other object first, or break a loop if it is already in the chain.
CompareWithOtherObject CFA5 LD HL,($5BCF) Fetch the place in the list after the other object from SecondListPosition.
CFA8 DEC HL Point HL at the entry of the other object.
CFA9 LD C,(HL) Fetch the index of the other object.
CFAA LD DE,$D01A Point DE at ObjectChain.
CompareWithOtherObject_Find CFAD LD A,(DE) Fetch an entry.
CFAE CP $FF Jump to CompareWithOtherObject_Add if it is the end of the list.
CFB0 JR Z,CompareWithOtherObject_Add
CFB2 CP C Test whether it is the other object.
CFB3 JR Z,CompareWithOtherObject_Loop Jump to CompareWithOtherObject_Loop if it is.
CFB5 INC DE Move on to the next entry.
CFB6 JR CompareWithOtherObject_Find Jump to CompareWithOtherObject_Find.
CompareWithOtherObject_Add CFB8 LD A,C Fetch the index of the other object.
CFB9 LD (DE),A Add it to the list.
CFBA INC DE Move on to the next entry.
CFBB LD A,$FF Mark the end of the list.
CFBD LD (DE),A
CFBE PUSH IY Make the other object the first object (using the stack).
CFC0 POP IX
CFC2 LD HL,($5BCF) Fetch the place in the list after the other object from SecondListPosition.
CFC5 LD ($5BCD),HL Make it the place in the list after the first object at FirstListPosition.
CFC8 LD DE,$CE8B Point DE at ObjectsToDrawList.
CFCB JP DrawObjectsInOrder_FindSecond Jump to DrawObjectsInOrder_FindSecond.
CompareWithOtherObject_Loop CFCE LD HL,$CE8B Point HL at the list of objects to draw, ObjectsToDrawList.
CompareWithOtherObject_Search CFD1 LD A,(HL) Fetch an entry.
CFD2 INC HL Move on to the next entry.
CFD3 CP $FF Jump to DrawObjectsInOrder_First if it is the end of the list.
CFD5 JP Z,DrawObjectsInOrder_First
CFD8 CP C Test whether it is the other object.
CFD9 JR NZ,CompareWithOtherObject_Search Jump to CompareWithOtherObject_Search if it is not.
CFDB PUSH IY Make the other object the first object (using the stack).
CFDD POP IX
CFDF JR DrawNextObject_Flag Jump to DrawNextObject_Flag to draw it.
View the equivalent code in;
Prev: CF9F Up: Map Next: CFE1