Prev: 45977 Up: Map Next: 46027
46009: Test Range
Used by the routine at TestRecordOverlap.
Tests whether a position falls within a range. The zero flag is set when it does.
Input
HL The position
DE The column address
B The width
C The size
Output
F The zero flag is set when the position is inside the range
HL is the position and DE the column address. B is the width and C the size. The zero flag is set when the position is inside.
TestRange 46009 SBC HL,DE Subtract the column address from the position.
46011 JR C,TestRange_Low The position is below the column address.
46013 LD C,B Test the width on this side.
46014 LD B,0
46016 SBC HL,BC Subtract the width.
46018 RET NC Outside the range when the position is past the width.
46019 XOR A Inside the range.
46020 RET Return.
TestRange_Low 46021 LD B,0 The size is a single byte.
46023 ADD HL,BC Add the size to the shortfall.
46024 RET NC Outside the range when the size falls short.
46025 XOR A Inside the range.
46026 RET Return.
Prev: 45977 Up: Map Next: 46027