uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit f5c816d2152cad99ba059ec1124802f37db4d4c7
parent 49d74b89d01fd25266f7de97498136f228759072
Author: Weeble <clockworksaint@gmail.com>
Date:   Thu, 29 Jun 2023 11:44:55 +0100

(screen.c) Fix sprite draw at screen edge

Problem - Sprites can be drawn at X/Y coordinates >= 0xfff9 to appear
partially over the left/upper screen boundary. But the dirty-rectangle
calculation doesn't account for this, so these updates will only appear
on the screen if something *else* dirties this area of the screen. This
can be observed in /projects/examples/devices/screen.tal where these
edges of the screen show stale content.

Solution - Detect wrapping and expand the dirty rectangle appropriately.
Change screen_change to take Uint16 to make sure values are truncated to
the intended range. Ignore changes that are fully off the screen.

Diffstat:
Msrc/devices/screen.c | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/devices/screen.c b/src/devices/screen.c @@ -25,8 +25,12 @@ static Uint8 blending[4][16] = { {2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2}}; static void -screen_change(int x1, int y1, int x2, int y2) +screen_change(Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2) { + if(x1 > uxn_screen.width && x2 > x1) return; + if(y1 > uxn_screen.height && y2 > y1) return; + if(x1 > x2) x1 = 0; + if(y1 > y2) y1 = 0; if(x1 < uxn_screen.x1) uxn_screen.x1 = x1; if(y1 < uxn_screen.y1) uxn_screen.y1 = y1; if(x2 > uxn_screen.x2) uxn_screen.x2 = x2;