commit c09a047

neauoire  ·  2023-08-16 20:29:15 +0000 UTC
parent 867701b
Reduce redraws
2 files changed,  +6, -6
+1, -1
1@@ -3,7 +3,7 @@ CLI_src=src/uxn.c src/devices/system.c src/devices/console.c src/devices/file.c
2 EMU_src=${CLI_src} src/devices/screen.c src/devices/controller.c src/devices/mouse.c
3 
4 RELEASE_flags=-DNDEBUG -O2 -g0 -s
5-RELEASE_flags=-std=c89 -D_POSIX_C_SOURCE=199309L -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined
6+DEBUG_flags=-std=c89 -D_POSIX_C_SOURCE=199309L -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined
7 
8 .PHONY: all debug dest rom run test install uninstall format clean
9 
+5, -5
 1@@ -224,6 +224,11 @@ emu_run(Uxn *u, char *rom)
 2 		if(poll(&fds[1], 1, 0)) {
 3 			read(fds[1].fd, expirations, 8);   /* Indicate we handled the timer */
 4 			uxn_eval(u, PEEK2(u->dev + 0x20)); /* Call the vector once, even if the timer fired multiple times */
 5+			if(uxn_screen.x2) {
 6+				int x1 = uxn_screen.x1, y1 = uxn_screen.y1, x2 = uxn_screen.x2, y2 = uxn_screen.y2;
 7+				screen_redraw(u);
 8+				XPutImage(display, window, DefaultGC(display, 0), ximage, x1, y1, x1 + PAD, y1 + PAD, x2 - x1, y2 - y1);
 9+			}
10 		}
11 		if((fds[2].revents & POLLIN) != 0) {
12 			n = read(fds[2].fd, coninp, CONINBUFSIZE - 1);
13@@ -231,11 +236,6 @@ emu_run(Uxn *u, char *rom)
14 			for(i = 0; i < n; i++)
15 				console_input(u, coninp[i], CONSOLE_STD);
16 		}
17-		if(uxn_screen.x2) {
18-			int x1 = uxn_screen.x1, y1 = uxn_screen.y1, x2 = uxn_screen.x2, y2 = uxn_screen.y2;
19-			screen_redraw(u);
20-			XPutImage(display, window, DefaultGC(display, 0), ximage, x1, y1, x1 + PAD, y1 + PAD, x2 - x1, y2 - y1);
21-		}
22 	}
23 	return 1;
24 }