Browse code

Fixed issue with out-of-screen painting

Devine Lu Linvega authored on 01/03/2023 05:54:52
Showing 1 changed files
... ...
@@ -28,13 +28,12 @@ static Uint32 palette_mono[] = {
28 28
 static void
29 29
 screen_write(UxnScreen *p, Layer *layer, Uint16 x, Uint16 y, Uint8 color)
30 30
 {
31
-	Uint32 i;
32
-	if(x > p->width || y > p->height)
33
-		return;
34
-	i = x + y * p->width;
35
-	if(color != layer->pixels[i]) {
36
-		layer->pixels[i] = color;
37
-		layer->changed = 1;
31
+	if(x < p->width && y < p->height) {
32
+		Uint32 i = x + y * p->width;
33
+		if(color != layer->pixels[i]) {
34
+			layer->pixels[i] = color;
35
+			layer->changed = 1;
36
+		}
38 37
 	}
39 38
 }
40 39
 
... ...
@@ -189,7 +188,7 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
189 188
 		n = d[0x6] >> 4;
190 189
 		dx = (d[0x6] & 0x01) << 3;
191 190
 		dy = (d[0x6] & 0x02) << 2;
192
-		if(addr > 0xfff0)
191
+		if(addr > 0x10000 - ((n + 1) << (3 + twobpp)))
193 192
 			return;
194 193
 		for(i = 0; i <= n; i++) {
195 194
 			if(!(d[0xf] & 0xf))