commit 424e7a9

Devine Lu Linvega  ·  2025-02-14 17:59:58 +0000 UTC
parent 72a6b8a
Fixed flickering during resize
3 files changed,  +13, -7
+1, -1
 1@@ -15,9 +15,9 @@ WITH REGARD TO THIS SOFTWARE.
 2 #define CONSOLE_END 0x4
 3 
 4 void close_console(void);
 5+
 6 int console_input(int c, int type);
 7 void console_arguments(int i, int argc, char **argv);
 8-
 9 Uint8 console_dei(Uint8 addr);
10 void console_deo(Uint8 addr);
11 
+1, -1
1@@ -67,7 +67,7 @@ screen_palette(void)
2 void
3 screen_resize(Uint16 width, Uint16 height, int scale)
4 {
5-	Uint32 *pixels = NULL;
6+	Uint32 *pixels;
7 	clamp(width, 8, 0x800);
8 	clamp(height, 8, 0x800);
9 	clamp(scale, 1, 3);
+11, -5
 1@@ -71,11 +71,17 @@ emu_deo(Uint8 addr, Uint8 value)
 2 }
 3 
 4 int
 5-emu_resize(int w, int h)
 6+emu_resize(int width, int height)
 7 {
 8-	w *= uxn_screen.scale, h *= uxn_screen.scale;
 9-	XResizeWindow(display, window, w, h);
10-	ximage = XCreateImage(display, DefaultVisual(display, 0), DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, w, h, 32, 0);
11+	width *= uxn_screen.scale, height *= uxn_screen.scale;
12+	XResizeWindow(display, window, width, height);
13+	ximage = XCreateImage(display, DefaultVisual(display, 0), DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, width, height, 32, 0);
14+	if(screen_changed()) {
15+		int x = uxn_screen.x1 * uxn_screen.scale, y = uxn_screen.y1 * uxn_screen.scale;
16+		int w = uxn_screen.x2 * uxn_screen.scale - x, h = uxn_screen.y2 * uxn_screen.scale - y;
17+		screen_redraw();
18+		XPutImage(display, window, DefaultGC(display, 0), ximage, x, y, x, y, w, h);
19+	}
20 	return 1;
21 }
22 
23@@ -247,7 +253,7 @@ main(int argc, char **argv)
24 {
25 	int i = 1;
26 	if(argc == 2 && argv[1][0] == '-' && argv[1][1] == 'v')
27-		return !fprintf(stdout, "Uxn11 - Varvara Emulator, 23 Jan 2025.\n");
28+		return !fprintf(stdout, "Uxn11 - Varvara Emulator, 14 Feb 2025.\n");
29 	else if(argc == 1)
30 		return !fprintf(stdout, "usage: %s [-v] file.rom [args..]\n", argv[0]);
31 	else if(!display_init())