Prev: DDD5 Up: Map Next: DE25
DDF3: 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 DDF3 XOR A Set A to zero.
DDF4 SBC HL,DE Subtract DE from HL. (with the carry)
DDF6 JR C,TestRangeOverlap_Second Jump to TestRangeOverlap_Second if the carry flag is set.
DDF8 OR H Combine A with H.
DDF9 RET NZ Return if the zero flag is reset.
DDFA LD A,L L moves into A.
DDFB SUB B Subtract B.
DDFC RET NC Return if the carry flag is reset.
DDFD ADD HL,DE HL takes DE.
DDFE BIT 7,(IX+$18) Jump to TestRangeOverlap_Swap if the zero flag is set.
DE02 JR Z,TestRangeOverlap_Swap
TestRangeOverlap_Loop DE04 LD B,$00 B is 00.
DE06 ADD HL,BC HL takes BC.
DE07 SBC HL,DE Subtract DE from HL. (with the carry)
TestRangeOverlap_Loop2 DE09 LD H,(IX+$18) Read field 18 of the entity into H.
DE0C INC L Advance L.
DE0D SCF Set the carry flag.
DE0E RET Return.
This entry point is used by the routine at TestOverlap.
TestRangeOverlap_Reset DE0F AND A See whether A is zero.
DE10 RET Return.
TestRangeOverlap_Second DE11 LD A,B B moves into A.
DE12 LD B,$00 B is 00.
DE14 ADD HL,BC HL takes BC.
DE15 RET NC Return if the carry flag is reset.
DE16 BIT 7,(IX+$18) Jump to DE09 if the zero flag is reset.
DE1A JR NZ,TestRangeOverlap_Loop2
DE1C AND A See whether A is zero.
DE1D SBC HL,BC Subtract BC from HL. (with the carry)
DE1F LD B,A A moves into B.
DE20 ADD HL,DE HL takes DE.
TestRangeOverlap_Swap DE21 EX DE,HL Exchange DE and HL.
DE22 LD C,B B moves into C.
DE23 JR TestRangeOverlap_Loop Jump to DE04.
Prev: DDD5 Up: Map Next: DE25