Prev: 50894 Up: Map Next: 50946
50906: Hit Test: 8-Byte Bounds Pair
Reads four little-endian words at HL (8 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 52442, 52517, 53577, 53805, 57405, 60188).
HitTestBounds8AtHL 50906 LD B,(HL) B=*HL (first word, low byte).
50907 INC HL Advance HL.
50908 LD C,(HL) C=*HL (first word, high byte).
50909 INC HL Advance HL.
50910 LD D,(HL) D=*HL (second word, low byte).
50911 INC HL Advance HL.
50912 LD E,(HL) E=*HL (second word, high byte).
50913 EXX EXX (shadow HL continues the load; shadow BC/DE hold first pair).
50914 LD B,(HL) B=*HL (third word, low byte).
50915 INC HL Advance HL.
50916 LD C,(HL) C=*HL (third word, high byte).
50917 INC HL Advance HL.
50918 LD D,(HL) D=*HL (fourth word, low byte).
50919 INC HL Advance HL.
50920 LD E,(HL) E=*HL (fourth word, high byte).
50921 EXX EXX (main holds first pair; shadow second pair; HL past all 8 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).
50922 LD A,B A=B.
50923 ADD A,D A+=D (high bytes from main BC/DE).
50924 EXX EXX.
50925 SUB B Subtract shadow B from A.
50926 EXX EXX.
50927 RET C RET C if no hit (carry from SUB).
50928 EXX EXX.
50929 LD A,B A=B.
50930 ADD A,D A+=D (second high-byte sum).
50931 EXX EXX.
50932 SUB B Subtract shadow B from A.
50933 RET C RET C if no hit.
50934 LD A,C A=C.
50935 ADD A,E A+=E (low-byte sum).
50936 EXX EXX.
50937 SUB C Subtract shadow C from A.
50938 EXX EXX.
50939 RET C RET C if no hit.
50940 EXX EXX.
50941 LD A,C A=C.
50942 ADD A,E A+=E (final low-byte sum).
50943 EXX EXX.
50944 SUB C Subtract shadow C from A (last test).
50945 RET RET (carry clear if overlapping).
Prev: 50894 Up: Map Next: 50946