Prev: B638 Up: Map Next: B6CD
B66E: Resolve Object Order
The routines selected by the table at SortJumpTable, once DrawObjectsInOrder has compared two objects. IX holds the object that is being considered and IY holds the object that it has been compared with.
The order of the objects is not known, so look at the next object.
ResolveObjectOrder B66E JP DrawObjectsInOrder_NextOther Jump to DrawObjectsInOrder_NextOther to compare the object considered with the next object in the list.
The object considered is behind the other, so it needs no wait: look at the next object.
ResolveObjectOrder_Behind B671 JP DrawObjectsInOrder_NextOther Jump to DrawObjectsInOrder_NextOther to compare the object considered with the next object in the list.
The object considered is in front of the other so it must be drawn after it. Make the other one the object that is being considered, unless it has already been tried, and so is part of a loop.
ResolveObjectOrder_InFront B674 LD HL,($A71B) Fetch the list pointer, which is just after the entry of the other object.
B677 DEC HL Point HL at the entry.
B678 LD C,(HL) Fetch the number of the object in C.
B679 LD DE,$B6CD Point DE at the list of the objects that have been tried, ObjectsTriedList.
ResolveObjectOrder_FindTried B67C LD A,(DE) Fetch the next number in the list of the objects tried.
B67D CP $FF Jump to ResolveObjectOrder_AddTried if the end of that list has been reached.
B67F JR Z,ResolveObjectOrder_AddTried
B681 CP C Jump to ResolveObjectOrder_Loop if the object has already been tried, which means that there is a loop.
B682 JR Z,ResolveObjectOrder_Loop
B684 INC DE Move on in the list.
B685 JR ResolveObjectOrder_FindTried Jump to ResolveObjectOrder_FindTried to look at the next number.
Add the object to the list of the objects tried.
ResolveObjectOrder_AddTried B687 LD A,C Fetch the number of the object.
B688 LD (DE),A Add it to the list.
B689 INC DE Move on in the list.
B68A LD A,$FF Set A to FF.
B68C LD (DE),A Mark the end of the list.
Make the other object the one that is considered and start the search again from the top of the list.
B68D PUSH IY Copy IY to IX (using the stack).
B68F POP IX
B691 LD HL,($A71B) Fetch the list pointer.
B694 LD ($A719),HL Make it the pointer to the entry of the object that is considered.
B697 LD DE,$B55A Point DE at the start of the draw list, DrawList.
B69A JP DrawObjectsInOrder_NextOther Jump to DrawObjectsInOrder_NextOther to compare the object with the others.
The object has been tried before, so there is a loop. Draw it, to break the loop, once its place in the list has been found.
ResolveObjectOrder_Loop B69D LD HL,$B55A Point HL at the start of the draw list, DrawList.
ResolveObjectOrder_FindEntry B6A0 LD A,(HL) Fetch the next number from the list.
B6A1 INC HL
B6A2 CP $FF Jump to DrawObjectsInOrder_Restart if the end of the list has been reached.
B6A4 JP Z,DrawObjectsInOrder_Restart
B6A7 CP C Jump to ResolveObjectOrder_FindEntry if it is not the entry of the object.
B6A8 JR NZ,ResolveObjectOrder_FindEntry
B6AA PUSH IY Copy IY to IX (using the stack).
B6AC POP IX
B6AE JR ResolveObjectOrder_DrawEntry Jump to ResolveObjectOrder_DrawEntry to draw the object.
The two objects overlap completely, so look at the next object.
ResolveObjectOrder_Overlap B6B0 JP DrawObjectsInOrder_NextOther Jump to DrawObjectsInOrder_NextOther to compare the object considered with the next object in the list.
This entry point is used by the routine at DrawObjectsInOrder.
Nothing has to be drawn before the object considered, so draw it now.
ResolveObjectOrder_Draw B6B3 LD HL,($A719) Fetch the pointer to the entry of the object in the list.
ResolveObjectOrder_DrawEntry B6B6 DEC HL Point HL at the entry.
B6B7 SET 7,(HL) Set bit 7 of the entry, to show that the object has been drawn.
B6B9 LD A,$FF Set A to FF.
B6BB LD ($B6CD),A Empty the list of the objects that have been tried.
B6BE LD HL,$A714 Point HL at the count of the objects drawn, DrawingWorkCount.
B6C1 INC (HL) Count the object.
B6C2 CALL DrawObject Call DrawObject to draw the object.
B6C5 JP DrawObjectsInOrder_Restart Jump to DrawObjectsInOrder_Restart to look for the next object to draw.
This entry point is used by the routine at DrawObjectsInOrder.
All the objects have been drawn.
ResolveObjectOrder_Done B6C8 POP IY Restore IY and IX from the stack.
B6CA POP IX
B6CC RET Return.
Prev: B638 Up: Map Next: B6CD