commit f89033a

Devie Lu Linvega  ·  2025-12-14 17:32:17 +0000 UTC
parent 7ce2996
Cleanup
1 files changed,  +19, -17
+19, -17
 1@@ -409,7 +409,7 @@ console_input(int c, unsigned int type)
 2 #define MAR2(x) (x + 0x10)
 3 
 4 typedef struct UxnScreen {
 5-	int width, height, zoom, resized, x1, y1, x2, y2, redraw;
 6+	int width, height, zoom, resized, redraw, x1, y1, x2, y2;
 7 	unsigned int palette[16], *pixels;
 8 	Uint8 *bg;
 9 } UxnScreen;
10@@ -445,8 +445,7 @@ screen_changed(void)
11 	clamp(uxn_screen.y1, 0, uxn_screen.height);
12 	clamp(uxn_screen.x2, 0, uxn_screen.width);
13 	clamp(uxn_screen.y2, 0, uxn_screen.height);
14-	return uxn_screen.x2 > uxn_screen.x1 &&
15-		uxn_screen.y2 > uxn_screen.y1;
16+	return uxn_screen.x2 > uxn_screen.x1 && uxn_screen.y2 > uxn_screen.y1;
17 }
18 
19 static void
20@@ -486,7 +485,9 @@ screen_apply(int width, int height)
21 	length = MAR2(width) * MAR2(height);
22 	uxn_screen.bg = realloc(uxn_screen.bg, length);
23 	memset(uxn_screen.bg, 0, length);
24-	uxn_screen.width = width, uxn_screen.height = height, uxn_screen.resized = 1;
25+	uxn_screen.width = width;
26+	uxn_screen.height = height;
27+	uxn_screen.resized = 1;
28 	uxn_screen.redraw = 1;
29 }
30 
31@@ -505,8 +506,7 @@ screen_redraw(void)
32 			}
33 		}
34 	}
35-	uxn_screen.x1 = uxn_screen.y1 = 9999;
36-	uxn_screen.x2 = uxn_screen.y2 = 0;
37+	uxn_screen.x1 = uxn_screen.y1 = uxn_screen.x2 = uxn_screen.y2 = 0;
38 }
39 
40 /* screen registers */
41@@ -1052,6 +1052,15 @@ emu_repaint(void)
42 	XPutImage(display, window, DefaultGC(display, 0), ximage, x, y, x, y, w, h);
43 }
44 
45+static void
46+emu_repaint_all(void)
47+{
48+	uxn_screen.x1 = uxn_screen.y1 = 0;
49+	uxn_screen.x2 = uxn_screen.width;
50+	uxn_screen.y2 = uxn_screen.height;
51+	emu_repaint();
52+}
53+
54 void
55 emu_resize(void)
56 {
57@@ -1063,10 +1072,7 @@ emu_resize(void)
58 	if(ximage)
59 		free(ximage);
60 	ximage = XCreateImage(display, DefaultVisual(display, 0), DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, width, height, 32, 0);
61-	uxn_screen.x1 = uxn_screen.y1 = 0;
62-	uxn_screen.x2 = uxn_screen.width;
63-	uxn_screen.y2 = uxn_screen.height;
64-	emu_repaint();
65+	emu_repaint_all();
66 }
67 
68 static void
69@@ -1231,13 +1237,9 @@ emu_run(void)
70 				uxn_eval(screen_vector);
71 			if(uxn_screen.resized)
72 				emu_resize(), uxn_screen.resized = 0;
73-			if(uxn_screen.redraw) {
74-				uxn_screen.x1 = 0;
75-				uxn_screen.y1 = 0;
76-				uxn_screen.x2 = uxn_screen.width;
77-				uxn_screen.y2 = uxn_screen.height;
78-				emu_repaint();
79-			} else if(uxn_screen.x2 && uxn_screen.y2 && screen_changed())
80+			if(uxn_screen.redraw)
81+				emu_repaint_all();
82+			else if(screen_changed())
83 				emu_repaint();
84 		}
85 		has_input = fds[2].revents & POLLIN;