; load bottom left point
ld a, [hl+]
- ; TODO: remove use of d2
- ld [d2], a ; save y in d2
ld d, a ; d = y
ld a, [hl+]
ld e, a ; e = x
ld d, a ; d = top left y
pop hl
+ ; x was already tested in bottom left
+
ld a, b ; compare y points
cp a, d
jr c, @no_collision REL
- ld a, c ; compare x position
- cp a, e
- jr c, @no_collision REL
-
; top right
capoverflow
ld e, a
+ ; top right has unique x and y positions
+
ld a, b ; compare y
cp a, d
jr c, @no_collision REL
; bottom right
- ; remove height from y
- ; to get bottom right point
- ld a, [d2] ; d2 = original y point
- ld d, a
+ ; original y position was already tested in bottom left
+ ; x positions was already tested in top right
- ld a, b ; compare y
- cp a, d
- jr nc, @no_collision REL
- ld a, c ; compare x
- cp a, e
- jr nc, @no_collision REL
+ ; all other missing x/y checks have
+ ; already been performed in previous points
+ ; e.g. original y is tested in bottom left
@collision:
ld a, 1