Prev: 56789 Up: Map Next: 56869
56819: Test Range Overlap
Used by the routine at TestGroupObjects.
Tests whether a range overlaps another, taking into account whether the entity is on the ground. Purpose of the individual steps is not yet known.
Input
HL The start of the first range
DE The start of the second range
B The size of the range
Output
F The carry flag is set if the ranges overlap
TestRangeOverlap 56819 XOR A Set A to zero.
56820 SBC HL,DE Subtract DE from HL. (with the carry)
56822 JR C,TestRangeOverlap_Second Jump to TestRangeOverlap_Second if the carry flag is set.
56824 OR H Combine A with H.
56825 RET NZ Return if the zero flag is reset.
56826 LD A,L L moves into A.
56827 SUB B Subtract B.
56828 RET NC Return if the carry flag is reset.
56829 ADD HL,DE HL takes DE.
56830 BIT 7,(IX+24) Jump to TestRangeOverlap_Swap if the zero flag is set.
56834 JR Z,TestRangeOverlap_Swap
TestRangeOverlap_Loop 56836 LD B,0 B is 0.
56838 ADD HL,BC HL takes BC.
56839 SBC HL,DE Subtract DE from HL. (with the carry)
TestRangeOverlap_Loop2 56841 LD H,(IX+24) Read field 24 of the entity into H.
56844 INC L Advance L.
56845 SCF Set the carry flag.
56846 RET Return.
This entry point is used by the routine at TestOverlap.
TestRangeOverlap_Reset 56847 AND A See whether A is zero.
56848 RET Return.
TestRangeOverlap_Second 56849 LD A,B B moves into A.
56850 LD B,0 B is 0.
56852 ADD HL,BC HL takes BC.
56853 RET NC Return if the carry flag is reset.
56854 BIT 7,(IX+24) Jump to 56841 if the zero flag is reset.
56858 JR NZ,TestRangeOverlap_Loop2
56860 AND A See whether A is zero.
56861 SBC HL,BC Subtract BC from HL. (with the carry)
56863 LD B,A A moves into B.
56864 ADD HL,DE HL takes DE.
TestRangeOverlap_Swap 56865 EX DE,HL Exchange DE and HL.
56866 LD C,B B moves into C.
56867 JR TestRangeOverlap_Loop Jump to 56836.
Prev: 56789 Up: Map Next: 56869