Prev: C6CE Up: Map Next: C702
C6DA: Hit Test: 8-Byte Bounds Pair
Reads four little-endian words at HL (08 bytes). The first two load into main BC and DE; EXX swaps to the shadow set so the next two words load into shadow BC and DE while HL walks the same block. After swapping back, four ADD/SUB pairs (with further EXX) each end in RET C if the subtraction borrows (no hit). If none borrow, falls through to RET with carry clear (hit). HL ends just past the eighth byte. Used throughout the gameplay object loop for collisions (among others CCDA, CD25, D149, D22D, E03D, EB1C).
HitTestBounds8AtHL C6DA LD B,(HL) B=*HL (first word, low byte).
C6DB INC HL Advance HL.
C6DC LD C,(HL) C=*HL (first word, high byte).
C6DD INC HL Advance HL.
C6DE LD D,(HL) D=*HL (second word, low byte).
C6DF INC HL Advance HL.
C6E0 LD E,(HL) E=*HL (second word, high byte).
C6E1 EXX EXX (shadow HL continues the load; shadow BC/DE hold first pair).
C6E2 LD B,(HL) B=*HL (third word, low byte).
C6E3 INC HL Advance HL.
C6E4 LD C,(HL) C=*HL (third word, high byte).
C6E5 INC HL Advance HL.
C6E6 LD D,(HL) D=*HL (fourth word, low byte).
C6E7 INC HL Advance HL.
C6E8 LD E,(HL) E=*HL (fourth word, high byte).
C6E9 EXX EXX (main holds first pair; shadow second pair; HL past all 08 bytes).
Each test adds two bytes from one pair, switches to the shadow pair, subtracts a byte from the other rectangle, and RET C on borrow (no overlap on that check).
C6EA LD A,B A=B.
C6EB ADD A,D A+=D (high bytes from main BC/DE).
C6EC EXX EXX.
C6ED SUB B Subtract shadow B from A.
C6EE EXX EXX.
C6EF RET C RET C if no hit (carry from SUB).
C6F0 EXX EXX.
C6F1 LD A,B A=B.
C6F2 ADD A,D A+=D (second high-byte sum).
C6F3 EXX EXX.
C6F4 SUB B Subtract shadow B from A.
C6F5 RET C RET C if no hit.
C6F6 LD A,C A=C.
C6F7 ADD A,E A+=E (low-byte sum).
C6F8 EXX EXX.
C6F9 SUB C Subtract shadow C from A.
C6FA EXX EXX.
C6FB RET C RET C if no hit.
C6FC EXX EXX.
C6FD LD A,C A=C.
C6FE ADD A,E A+=E (final low-byte sum).
C6FF EXX EXX.
C700 SUB C Subtract shadow C from A (last test).
C701 RET RET (carry clear if overlapping).
Prev: C6CE Up: Map Next: C702