![]() |
Routines |
| Prev: 51013 | Up: Map | Next: 51251 |
|
Used by the routine at DrawChangedObjects.
Draws the objects in the list at ObjectsToDrawList so that the objects at the back are drawn before the objects in front of them. It takes the first object in the list that has not been drawn yet and compares it with each of the other objects that are waiting. If another object has to be drawn first, that object takes the place of the first object and is compared with the others in its turn. This carries on until an object is found that does not have to wait for any other object, and that one is drawn. This is repeated until the list is empty. The objects drawn are counted in ObjectsDrawn.
|
||||
|
Clear the count and find the first object that is still waiting.
|
||||
| DrawObjectsInOrder | 51077 | XOR A | Write 0 to ObjectsDrawn. | |
| 51078 | LD (23326),A | |||
| 51081 | PUSH IX | Stash IX and IY on the stack. | ||
| 51083 | PUSH IY | |||
|
This entry point is used by the routines at CompareWithOtherObject and DrawNextObject.
|
||||
| DrawObjectsInOrder_First | 51085 | LD DE,51013 | Point DE at ObjectsToDrawList. | |
|
Skip entries that have already been drawn.
|
||||
| DrawObjectsInOrder_FindFirst | 51088 | LD A,(DE) | Fetch an index from the list. | |
| 51089 | INC DE | Move on to the next entry. | ||
| 51090 | CP 255 | Jump to DrawNextObject_Finish if it is the end of the list. | ||
| 51092 | JP Z,DrawNextObject_Finish | |||
| 51095 | BIT 7,A | Jump to DrawObjectsInOrder_FindFirst if the object has been drawn. | ||
| 51097 | JR NZ,DrawObjectsInOrder_FindFirst | |||
| 51099 | CALL FindObjectAddress | Find the address of the object. | ||
| 51102 | LD (23341),DE | Remember the place in the list. | ||
| 51106 | PUSH HL | Point IX at the object (using the stack). | ||
| 51107 | POP IX | |||
|
This entry point is used by the routines at ContinueComparingObjects, CompareWithOtherObject and ReplaceOverlappingSpecialObject.
Compare it with each later object that is still waiting.
|
||||
| DrawObjectsInOrder_FindSecond | 51109 | LD A,(DE) | Fetch an index from the list. | |
| 51110 | INC DE | Move on to the next entry. | ||
| 51111 | CP 255 | Jump to DrawNextObject if it is the end of the list, as nothing has to be drawn before the first object. | ||
| 51113 | JP Z,DrawNextObject | |||
| 51116 | BIT 7,A | Jump to DrawObjectsInOrder_FindSecond if the object has been drawn. | ||
| 51118 | JR NZ,DrawObjectsInOrder_FindSecond | |||
| 51120 | CALL FindObjectAddress | Find the address of the object. | ||
| 51123 | LD (23343),DE | Remember the place in the list. | ||
| 51127 | PUSH HL | Point IY at the other object (using the stack). | ||
| 51128 | POP IY | |||
| 51130 | PUSH IX | Copy IX to BC (using the stack). | ||
| 51132 | POP BC | |||
| 51133 | AND A | Jump to DrawObjectsInOrder_FindSecond if they are the same object. | ||
| 51134 | SBC HL,BC | |||
| 51136 | JR Z,DrawObjectsInOrder_FindSecond | |||
|
Each of the three directions gives a number. The number along z is 0 if the first object is above the other, 1 if the objects overlap along z and 2 if the first object is below. The number along y is 0 if the first object is to the north of the other, 3 if the objects overlap along y and 6 if the first object is to the south. The number along x is 0 if the first object is to the east of the other, 9 if the objects overlap along x and 18 if the first object is to the west. The three numbers are added together in C.
|
||||
| 51138 | LD C,0 | Set the number to 0. | ||
| 51140 | LD A,(IY+3) | Work out where the top of the other object is. | ||
| 51143 | ADD A,(IY+6) | |||
| 51146 | LD L,A | |||
| 51147 | LD A,(IX+3) | Take it off the z position of the first object. | ||
| 51150 | SUB L | |||
| 51151 | JR NC,DrawObjectsInOrder_Y | Jump to DrawObjectsInOrder_Y if the first object is above the other. | ||
| 51153 | LD A,(IX+3) | Work out where the top of the first object is. | ||
| 51156 | ADD A,(IX+6) | |||
| 51159 | LD L,A | |||
| 51160 | LD A,(IY+3) | Take it off the z position of the other object. | ||
| 51163 | SUB L | |||
| 51164 | JR C,DrawObjectsInOrder_Overlap | Jump to DrawObjectsInOrder_Overlap if the objects overlap along z. | ||
| 51166 | INC C | Add one to the number along z. | ||
| DrawObjectsInOrder_Overlap | 51167 | INC C | Add one to the number along z. | |
|
Add the number along y.
|
||||
| DrawObjectsInOrder_Y | 51168 | LD A,(IY+2) | Work out where the north edge of the other object is. | |
| 51171 | ADD A,(IY+5) | |||
| 51174 | LD L,A | |||
| 51175 | LD A,(IX+2) | Work out where the south edge of the first object is, and take the north edge of the other object off it. | ||
| 51178 | SUB (IX+5) | |||
| 51181 | SUB L | |||
| 51182 | JR NC,DrawObjectsInOrder_X | Jump to DrawObjectsInOrder_X if the first object is to the north of the other. | ||
| 51184 | LD A,(IX+2) | Work out where the north edge of the first object is. | ||
| 51187 | ADD A,(IX+5) | |||
| 51190 | LD L,A | |||
| 51191 | LD A,(IY+2) | Work out where the south edge of the other object is, and take the north edge of the first object off it. | ||
| 51194 | SUB (IY+5) | |||
| 51197 | SUB L | |||
| 51198 | LD A,C | Fetch the number so far. | ||
| 51199 | JR C,DrawObjectsInOrder_OverlapY | Jump to DrawObjectsInOrder_OverlapY if the objects overlap along y. | ||
| 51201 | ADD A,3 | Add 3 to the number along y. | ||
| DrawObjectsInOrder_OverlapY | 51203 | ADD A,3 | Add 3 to the number along y. | |
| 51205 | LD C,A | Store the number. | ||
|
Add the number along x.
|
||||
| DrawObjectsInOrder_X | 51206 | LD A,(IY+1) | Work out where the east edge of the other object is. | |
| 51209 | ADD A,(IY+4) | |||
| 51212 | LD L,A | |||
| 51213 | LD A,(IX+1) | Work out where the west edge of the first object is, and take the east edge of the other object off it. | ||
| 51216 | SUB (IX+4) | |||
| 51219 | SUB L | |||
| 51220 | JR NC,DrawObjectsInOrder_Jump | Jump to DrawObjectsInOrder_Jump if the first object is to the east of the other. | ||
| 51222 | LD A,(IX+1) | Work out where the east edge of the first object is. | ||
| 51225 | ADD A,(IX+4) | |||
| 51228 | LD L,A | |||
| 51229 | LD A,(IY+1) | Work out where the west edge of the other object is, and take the east edge of the first object off it. | ||
| 51232 | SUB (IY+4) | |||
| 51235 | SUB L | |||
| 51236 | LD A,C | Fetch the number so far. | ||
| 51237 | JR C,DrawObjectsInOrder_OverlapX | Jump to DrawObjectsInOrder_OverlapX if the objects overlap along x. | ||
| 51239 | ADD A,9 | Add 9 to the number along x. | ||
| DrawObjectsInOrder_OverlapX | 51241 | ADD A,9 | Add 9 to the number along x. | |
| 51243 | LD C,A | Store the number. | ||
|
Jump to the routine for the number.
|
||||
| DrawObjectsInOrder_Jump | 51244 | LD L,C | Use the number as the index into the table. | |
| 51245 | LD BC,51251 | Point BC at DrawingOrderTable. | ||
| 51248 | JP RunGame_JumpToHandler | Jump to RunGame_JumpToHandler. | ||
|
View the equivalent code in;
|
||||
| Prev: 51013 | Up: Map | Next: 51251 |