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.
... | ... |
@@ -25,8 +25,12 @@ static Uint8 blending[4][16] = { |
25 | 25 |
{2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2}}; |
26 | 26 |
|
27 | 27 |
static void |
28 |
-screen_change(int x1, int y1, int x2, int y2) |
|
28 |
+screen_change(Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2) |
|
29 | 29 |
{ |
30 |
+ if(x1 > uxn_screen.width && x2 > x1) return; |
|
31 |
+ if(y1 > uxn_screen.height && y2 > y1) return; |
|
32 |
+ if(x1 > x2) x1 = 0; |
|
33 |
+ if(y1 > y2) y1 = 0; |
|
30 | 34 |
if(x1 < uxn_screen.x1) uxn_screen.x1 = x1; |
31 | 35 |
if(y1 < uxn_screen.y1) uxn_screen.y1 = y1; |
32 | 36 |
if(x2 > uxn_screen.x2) uxn_screen.x2 = x2; |