Prev: 53151 Up: Map Next: 53217
53157: 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 53157 LD HL,(23503) Fetch the place in the list after the other object from SecondListPosition.
53160 DEC HL Point HL at the entry of the other object.
53161 LD C,(HL) Fetch the index of the other object.
53162 LD DE,53274 Point DE at ObjectChain.
CompareWithOtherObject_Find 53165 LD A,(DE) Fetch an entry.
53166 CP 255 Jump to CompareWithOtherObject_Add if it is the end of the list.
53168 JR Z,CompareWithOtherObject_Add
53170 CP C Test whether it is the other object.
53171 JR Z,CompareWithOtherObject_Loop Jump to CompareWithOtherObject_Loop if it is.
53173 INC DE Move on to the next entry.
53174 JR CompareWithOtherObject_Find Jump to CompareWithOtherObject_Find.
CompareWithOtherObject_Add 53176 LD A,C Fetch the index of the other object.
53177 LD (DE),A Add it to the list.
53178 INC DE Move on to the next entry.
53179 LD A,255 Mark the end of the list.
53181 LD (DE),A
53182 PUSH IY Make the other object the first object (using the stack).
53184 POP IX
53186 LD HL,(23503) Fetch the place in the list after the other object from SecondListPosition.
53189 LD (23501),HL Make it the place in the list after the first object at FirstListPosition.
53192 LD DE,52875 Point DE at ObjectsToDrawList.
53195 JP DrawObjectsInOrder_FindSecond Jump to DrawObjectsInOrder_FindSecond.
CompareWithOtherObject_Loop 53198 LD HL,52875 Point HL at the list of objects to draw, ObjectsToDrawList.
CompareWithOtherObject_Search 53201 LD A,(HL) Fetch an entry.
53202 INC HL Move on to the next entry.
53203 CP 255 Jump to DrawObjectsInOrder_First if it is the end of the list.
53205 JP Z,DrawObjectsInOrder_First
53208 CP C Test whether it is the other object.
53209 JR NZ,CompareWithOtherObject_Search Jump to CompareWithOtherObject_Search if it is not.
53211 PUSH IY Make the other object the first object (using the stack).
53213 POP IX
53215 JR DrawNextObject_Flag Jump to DrawNextObject_Flag to draw it.
View the equivalent code in;
Prev: 53151 Up: Map Next: 53217