From c09a04785196a5b05c4b8be928f9bc287a9f1e0a Mon Sep 17 00:00:00 2001 From: neauoire Date: Wed, 16 Aug 2023 13:29:15 -0700 Subject: [PATCH] Reduce redraws --- makefile | 2 +- src/uxn11.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/makefile b/makefile index a2f449d..86cc7bf 100644 --- a/makefile +++ b/makefile @@ -3,7 +3,7 @@ CLI_src=src/uxn.c src/devices/system.c src/devices/console.c src/devices/file.c EMU_src=${CLI_src} src/devices/screen.c src/devices/controller.c src/devices/mouse.c RELEASE_flags=-DNDEBUG -O2 -g0 -s -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 +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 .PHONY: all debug dest rom run test install uninstall format clean diff --git a/src/uxn11.c b/src/uxn11.c index a923264..7a1ea5a 100644 --- a/src/uxn11.c +++ b/src/uxn11.c @@ -224,6 +224,11 @@ emu_run(Uxn *u, char *rom) if(poll(&fds[1], 1, 0)) { read(fds[1].fd, expirations, 8); /* Indicate we handled the timer */ uxn_eval(u, PEEK2(u->dev + 0x20)); /* Call the vector once, even if the timer fired multiple times */ + if(uxn_screen.x2) { + int x1 = uxn_screen.x1, y1 = uxn_screen.y1, x2 = uxn_screen.x2, y2 = uxn_screen.y2; + screen_redraw(u); + XPutImage(display, window, DefaultGC(display, 0), ximage, x1, y1, x1 + PAD, y1 + PAD, x2 - x1, y2 - y1); + } } if((fds[2].revents & POLLIN) != 0) { n = read(fds[2].fd, coninp, CONINBUFSIZE - 1); @@ -231,11 +236,6 @@ emu_run(Uxn *u, char *rom) for(i = 0; i < n; i++) console_input(u, coninp[i], CONSOLE_STD); } - if(uxn_screen.x2) { - int x1 = uxn_screen.x1, y1 = uxn_screen.y1, x2 = uxn_screen.x2, y2 = uxn_screen.y2; - screen_redraw(u); - XPutImage(display, window, DefaultGC(display, 0), ximage, x1, y1, x1 + PAD, y1 + PAD, x2 - x1, y2 - y1); - } } return 1; }