Prev: B399 Up: Map Next: B3CB
B3B9: 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 B3B9 SBC HL,DE Subtract the column address from the position.
B3BB JR C,TestRange_Low The position is below the column address.
B3BD LD C,B Test the width on this side.
B3BE LD B,$00
B3C0 SBC HL,BC Subtract the width.
B3C2 RET NC Outside the range when the position is past the width.
B3C3 XOR A Inside the range.
B3C4 RET Return.
TestRange_Low B3C5 LD B,$00 The size is a single byte.
B3C7 ADD HL,BC Add the size to the shortfall.
B3C8 RET NC Outside the range when the size falls short.
B3C9 XOR A Inside the range.
B3CA RET Return.
Prev: B399 Up: Map Next: B3CB