projects
/
gbrg
/
.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
9575262
)
rectangle: fixed collision breaking during scroll due to rectangle positions overflow...
author
Lukas Krickl
<lukas@krickl.dev>
Wed, 24 Sep 2025 04:27:29 +0000
(06:27 +0200)
committer
Lukas Krickl
<lukas@krickl.dev>
Wed, 24 Sep 2025 04:27:29 +0000
(06:27 +0200)
src/macros.inc
patch
|
blob
|
history
src/rectangle.s
patch
|
blob
|
history
diff --git
a/src/macros.inc
b/src/macros.inc
index c0f36f31cf2bc9ba403c6930e6a38169013617d8..3aa5bba1385b437d55c7d4c35981b4bedb9b1ca1 100644
(file)
--- a/
src/macros.inc
+++ b/
src/macros.inc
@@
-218,4
+218,28
@@
$1:
; $6: w
#macro recdef
.db $1, $2, $3, $4, $5, $6
+#endmacro
+
+ ; caps an underflow when carry is set
+ ; caps value to 0x00
+ ; inputs:
+ ; af: value and carry flag
+#macro capunderflow
+.beginscope
+ jr nc, @no_underflow REL
+ xor a, a
+@no_underflow:
+.endscope
+#endmacro
+
+ ; caps an overflow when carry is set
+ ; caps value to 0xFF
+ ; inputs:
+ ; af: value and carry flag
+#macro capoverflow
+.beginscope
+jr nc, @no_overflow REL
+ ld a, 0xFF
+@no_overflow:
+.endscope
#endmacro
diff --git
a/src/rectangle.s
b/src/rectangle.s
index 3a3e0125fc38564636b6b850c2ff0e3e49f53dd2..c14086fb4f81cc70be0677ca77da929d6ba65125 100644
(file)
--- a/
src/rectangle.s
+++ b/
src/rectangle.s
@@
-97,6
+97,7
@@
rect_tl:
ld l, a
ld a, d
sub a, l ; y-height
+ capunderflow
ld d, a ; d = top left y
ret
@@
-122,6
+123,7
@@
rect_tr:
ld a, [hl]
add a, e ; e = x + width
+ capoverflow
ld e, a
dec hl ; go back to height
@@
-129,6
+131,7
@@
rect_tr:
ld l, a
ld a, d
sub a, l ; y-height
+ capunderflow
ld d, a ; d = top right y
ret
@@
-144,6
+147,7
@@
rect_br:
ld a, [hl]
add a, e ; e = x + width
+ capoverflow
ld e, a
ret