![]() |
Routines |
| Prev: B55A | Up: Map | Next: B638 |
|
Used by the routine at DrawChangedObjects.
Draws the objects in the list at DrawList 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 DrawingWorkCount.
|
||||
|
Clear the count and find the first object that is still waiting.
|
||||
| DrawObjectsInOrder | B58A | XOR A | Write 00 to DrawingWorkCount. | |
| B58B | LD ($A714),A | |||
| B58E | PUSH IX | Stash IX and IY on the stack. | ||
| B590 | PUSH IY | |||
|
This entry point is used by the routine at ResolveObjectOrder.
Find the first object in the list that has not been drawn.
|
||||
| DrawObjectsInOrder_Restart | B592 | LD DE,$B55A | Point DE at DrawList. | |
|
Skip entries that have already been drawn.
|
||||
| DrawObjectsInOrder_NextCandidate | B595 | LD A,(DE) | Fetch an index from the list. | |
| B596 | INC DE | Move on to the next entry. | ||
| B597 | CP $FF | Jump to ResolveObjectOrder_Done if the end of the list has been reached, as every object has been drawn. | ||
| B599 | JP Z,ResolveObjectOrder_Done | |||
| B59C | BIT 7,A | Jump to DrawObjectsInOrder_NextCandidate if the object has already been drawn. | ||
| B59E | JR NZ,DrawObjectsInOrder_NextCandidate | |||
| B5A0 | CALL FindObjectAddress | Call FindObjectAddress to get the address of the object. | ||
| B5A3 | LD ($A719),DE | Remember the place in the list. | ||
| B5A7 | PUSH HL | Copy the address of the object to IX (using the stack). | ||
| B5A8 | POP IX | |||
|
This entry point is used by the routine at ResolveObjectOrder.
Compare it with each later object that is still waiting.
|
||||
| DrawObjectsInOrder_NextOther | B5AA | LD A,(DE) | Fetch an index from the list. | |
| B5AB | INC DE | Move on to the next entry. | ||
| B5AC | CP $FF | Jump to ResolveObjectOrder_Draw if the end of the list has been reached, as nothing has to be drawn before the object considered. | ||
| B5AE | JP Z,ResolveObjectOrder_Draw | |||
| B5B1 | BIT 7,A | Jump to DrawObjectsInOrder_NextOther if the object has already been drawn. | ||
| B5B3 | JR NZ,DrawObjectsInOrder_NextOther | |||
| B5B5 | CALL FindObjectAddress | Call FindObjectAddress to get the address of the object. | ||
| B5B8 | LD ($A71B),DE | Remember the place in the list. | ||
| B5BC | PUSH HL | Copy the address of the object to IY (using the stack). | ||
| B5BD | POP IY | |||
| B5BF | PUSH IX | Copy IX to BC (using the stack). | ||
| B5C1 | POP BC | |||
| B5C2 | AND A | Jump to DrawObjectsInOrder_NextOther if the other object is the object considered, as an object is not compared with itself. | ||
| B5C3 | SBC HL,BC | |||
| B5C5 | JR Z,DrawObjectsInOrder_NextOther | |||
|
Each of the three directions gives a number. The number along z is 00 if the first object is above the other, 01 if the objects overlap along z and 02 if the first object is below. The number along y is 00 if the first object is to the north of the other, 03 if the objects overlap along y and 06 if the first object is to the south. The number along x is 00 if the first object is to the east of the other, 09 if the objects overlap along x and 12 if the first object is to the west. The three numbers are added together in C.
|
||||
| B5C7 | LD C,$00 | Set the number to 00. | ||
|
Compare the heights. The code is 0 if the object considered is above the other and so in front, 1 if they overlap and 2 if it is below the other.
|
||||
| B5C9 | LD A,(IY+$03) | Fetch the height of the top of the other object. | ||
| B5CC | ADD A,(IY+$06) | |||
| B5CF | LD L,A | |||
| B5D0 | LD A,(IX+$03) | Subtract it from the height of the bottom of the object considered. | ||
| B5D3 | SUB L | |||
| B5D4 | JR NC,DrawObjectsInOrder_CompareY | Jump to DrawObjectsInOrder_CompareY if the object considered is above the other. | ||
| B5D6 | LD A,(IX+$03) | Fetch the height of the top of the object considered. | ||
| B5D9 | ADD A,(IX+$06) | |||
| B5DC | LD L,A | |||
| B5DD | LD A,(IY+$03) | Subtract it from the height of the bottom of the other object. | ||
| B5E0 | SUB L | |||
| B5E1 | JR C,DrawObjectsInOrder_HeightCode | Jump to DrawObjectsInOrder_HeightCode if the two overlap. | ||
| B5E3 | INC C | Add one to the code, as the object considered is below the other. | ||
| DrawObjectsInOrder_HeightCode | B5E4 | INC C | Add one to the number along z. | |
|
Add the number along y.
|
||||
| DrawObjectsInOrder_CompareY | B5E5 | LD A,(IY+$02) | Fetch the highest y position of the other object. | |
| B5E8 | ADD A,(IY+$05) | |||
| B5EB | LD L,A | |||
| B5EC | LD A,(IX+$02) | Subtract it from the lowest y position of the object considered. | ||
| B5EF | SUB (IX+$05) | |||
| B5F2 | SUB L | |||
| B5F3 | JR NC,DrawObjectsInOrder_CompareX | Jump to DrawObjectsInOrder_CompareX if the object considered has the higher y position, and is behind. | ||
| B5F5 | LD A,(IX+$02) | Fetch the highest y position of the object considered. | ||
| B5F8 | ADD A,(IX+$05) | |||
| B5FB | LD L,A | |||
| B5FC | LD A,(IY+$02) | Subtract it from the lowest y position of the other object. | ||
| B5FF | SUB (IY+$05) | |||
| B602 | SUB L | |||
| B603 | LD A,C | Fetch the number so far. | ||
| B604 | JR C,DrawObjectsInOrder_YCode | Jump to DrawObjectsInOrder_YCode if the two overlap. | ||
| B606 | ADD A,$03 | Add three to the code, as the object considered has the lower y position. | ||
| DrawObjectsInOrder_YCode | B608 | ADD A,$03 | Add 03 to the number along y. | |
| B60A | LD C,A | Store the number. | ||
|
Add the number along x.
|
||||
| DrawObjectsInOrder_CompareX | B60B | LD A,(IY+$01) | Fetch the highest x position of the other object. | |
| B60E | ADD A,(IY+$04) | |||
| B611 | LD L,A | |||
| B612 | LD A,(IX+$01) | Subtract it from the lowest x position of the object considered. | ||
| B615 | SUB (IX+$04) | |||
| B618 | SUB L | |||
| B619 | JR NC,DrawObjectsInOrder_Dispatch | Jump to DrawObjectsInOrder_Dispatch if the object considered has the higher x position, and is in front. | ||
| B61B | LD A,(IX+$01) | Fetch the highest x position of the object considered. | ||
| B61E | ADD A,(IX+$04) | |||
| B621 | LD L,A | |||
| B622 | LD A,(IY+$01) | Subtract it from the lowest x position of the other object. | ||
| B625 | SUB (IY+$04) | |||
| B628 | SUB L | |||
| B629 | LD A,C | Fetch the number so far. | ||
| B62A | JR C,DrawObjectsInOrder_XCode | Jump to DrawObjectsInOrder_XCode if the two overlap. | ||
| B62C | ADD A,$09 | Add nine to the code, as the object considered has the lower x position. | ||
| DrawObjectsInOrder_XCode | B62E | ADD A,$09 | Add 09 to the number along x. | |
| B630 | LD C,A | Store the number. | ||
|
Jump to the routine for the number.
|
||||
| DrawObjectsInOrder_Dispatch | B631 | LD L,C | Use the number as the index into the table. | |
| B632 | LD BC,$B638 | Point BC at SortJumpTable. | ||
| B635 | JP RunGame_JumpViaTable | Jump to RunGame_JumpViaTable. | ||
|
View the equivalent code in;
|
||||
| Prev: B55A | Up: Map | Next: B638 |