![]() |
Routines |
| Prev: 50729 | Up: Map | Next: 50885 |
|
Draws a block in the parts left uncovered by entities drawn earlier. Those entities are in the table at 45491, four bytes each, and the count is patched into this routine. Each item that covers the row leaves a span, which DrawBlockSpan draws.
|
||||
|
The two limits of the row are remembered, and the count of overlapping items is patched into the loop.
|
||||
| DrawOverlappedBlock | 50758 | LD (50775),HL | Remember the first limit. | |
| 50761 | LD (50816),DE | Remember the second limit. | ||
| 50765 | EXX | Use the limits' register set. | ||
| 50766 | LD IX,45491 | Start at the first overlapping item. | ||
| 50770 | LD B,0 | The number of items is patched. | ||
| 50772 | AND A | Clear the carry for the comparison. | ||
| DrawOverlappedBlock_Loop | 50773 | PUSH BC | Remember how many items remain. | |
| 50774 | LD HL,0 | Read the patched first limit. | ||
| 50777 | LD A,L | Take its low byte. | ||
| 50778 | AND %11111000 | Use the patched mask. | ||
| 50780 | OR %00000000 | Apply the patched bits. | ||
| 50782 | LD L,A | Remember the masked limit. | ||
| 50783 | LD (51117),A | |||
| 50786 | LD D,128 | Take the item's first byte, with the patched high byte. | ||
| 50788 | LD E,(IX+0) | |||
| 50791 | SBC HL,DE | Subtract it from the limit. | ||
| 50793 | JR C,DrawOverlappedBlock_Above | The item starts above the row. | ||
| 50795 | LD A,H | The item is a whole byte or more past the row. | ||
| 50796 | AND A | |||
| 50797 | JR NZ,DrawOverlappedBlock_Next | |||
| 50799 | LD A,L | The gap is at least the item's next byte. | ||
| 50800 | SUB (IX+2) | |||
| 50803 | JR NC,DrawOverlappedBlock_Next | |||
| 50805 | JR DrawOverlappedBlock_Second | Join the second limit. | ||
| DrawOverlappedBlock_Above | 50807 | INC H | The other side is a whole byte or more away. | |
| 50808 | JR NZ,DrawOverlappedBlock_Next | |||
| 50810 | LD A,L | The item's extra size does not reach the row. | ||
| 50811 | ADD A,0 | |||
| 50813 | JR NC,DrawOverlappedBlock_Next | |||
| DrawOverlappedBlock_Second | 50815 | LD HL,0 | Read the patched second limit. | |
| 50818 | SLA H | The high byte has to be clear. | ||
| 50820 | JR NZ,DrawOverlappedBlock_Next | |||
| 50822 | LD A,L | The low byte has to reach the patched edge. | ||
| 50823 | SUB 0 | |||
| 50825 | JR C,DrawOverlappedBlock_Height | |||
| 50827 | INC A | Shift that distance up. | ||
| 50828 | RLA | |||
| 50829 | JR C,DrawOverlappedBlock_Next | A distance that overflowed does not cover the row. | ||
| DrawOverlappedBlock_Height | 50831 | LD B,(IY+6) | Read the shape's position byte. | |
| 50834 | LD A,L | Subtract the item's byte from the distance. | ||
| 50835 | SUB (IX+1) | |||
| 50838 | JR C,DrawOverlappedBlock_Far | The item covers the far side of the row. | ||
| 50840 | LD H,A | The remainder is the height so far. | ||
| 50841 | SUB 0 | A remainder past the patched edge does not cover the row. | ||
| 50843 | JR NC,DrawOverlappedBlock_Next | |||
| 50845 | LD L,(IX+1) | The height is the item's byte, negated. | ||
| 50848 | NEG | |||
| 50850 | LD B,A | |||
| 50851 | CP (IX+3) | Use the smaller of that height and the item's other byte. | ||
| 50854 | JR C,DrawOverlappedBlock_Draw | |||
| 50856 | LD B,(IX+3) | Use the item's byte when it is the smaller. | ||
| 50859 | JR DrawOverlappedBlock_Draw | |||
| DrawOverlappedBlock_Far | 50861 | ADD A,(IX+3) | Add the item's byte to the distance. | |
| 50864 | JR NC,DrawOverlappedBlock_Next | The sum has to reach past zero. | ||
| 50866 | JR Z,DrawOverlappedBlock_Next | |||
| 50868 | CP 0 | Use the patched edge when the sum is below it. | ||
| 50870 | JR NC,DrawOverlappedBlock_Draw | |||
| 50872 | LD B,A | The height is that sum. | ||
| DrawOverlappedBlock_Draw | 50873 | CALL DrawBlockSpan | Draw the span that this item leaves. | |
| DrawOverlappedBlock_Next | 50876 | LD BC,4 | Move on to the next item. | |
| 50879 | ADD IX,BC | |||
| 50881 | POP BC | Bring the count back. | ||
| 50882 | DJNZ DrawOverlappedBlock_Loop | Repeat for the remaining items. | ||
| 50884 | RET | Return. | ||
| Prev: 50729 | Up: Map | Next: 50885 |