From 457efc07cd5989e947bc2f05feef9173fbde541a Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Wed, 12 Oct 2022 14:56:58 +0200 Subject: [WIP] Parametrize the screen update and refresh frequencies --- src/main.c | 17 ++++------------- src/ppu.c | 14 +++++++++++++- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/main.c b/src/main.c index 2c0e397..7ae8ef8 100644 --- a/src/main.c +++ b/src/main.c @@ -297,9 +297,9 @@ handle_keyboard(void) { // NOTE: Nook overrides. switch (key_code) { - case 156: { rune = 0x40; } break; // top left - case 139: { rune = 0x40; } break; // bottom left - case 151: { rune = 0x80; } break; // top right + case 156: { rune = 0x10; } break; // top left + case 139: { rune = 0x20; } break; // bottom left + case 151: { rune = 0x40; } break; // top right case 158: { rune = 0x80; } break; // bottom right default: break; } @@ -558,19 +558,10 @@ main(int argc, char *argv[]) { // Blit ppu.pixels to the framebuffer. blit_framebuffer(); - // TODO: make update frames and refresh frames as parameters instead - // of hardcoded - if (++frames_update > 5) { + if (++frames_update > frames_per_update) { write(fb_file, "0", 0); frames_update = 0; } - // NOTE: Maybe this should happen on blit_framebuffer depending on - // the number of actual updates (uxn applications that don't modify - // the framebuffer shouldn't have to blink). - if (++frames_refresh > 360) { - write(refresh_file, "1", 1); - frames_refresh = 0; - } frame_time = time_now(); } } diff --git a/src/ppu.c b/src/ppu.c index 38b27e6..bedf02d 100644 --- a/src/ppu.c +++ b/src/ppu.c @@ -22,12 +22,17 @@ WITH REGARD TO THIS SOFTWARE. */ +// Parameters. +static int zoom = 2; +static int frames_per_update = 5; +static int blits_per_refresh = 60 * 5; + static size_t screen_width = 0; static size_t screen_height = 0; static size_t bpp = 0; static int fb_file = 0; static int refresh_file = 0; -static int zoom = 2; +static frames_refresh = 0; static u8 *framebuffer = 0; @@ -242,5 +247,12 @@ blit_framebuffer(void) { } dirty_lines[j] = 0; } + // NOTE: Maybe this should happen on blit_framebuffer depending on + // the number of actual updates (uxn applications that don't modify + // the framebuffer shouldn't have to blink). + if (++frames_refresh > blits_per_refresh) { + write(refresh_file, "1", 1); + frames_refresh = 0; + } reqdraw = 0; } -- cgit v1.2.1