[WIP] Parametrize the screen update and refresh frequencies

This commit is contained in:
Bad Diode 2022-10-12 14:56:58 +02:00
parent e101b44b98
commit 457efc07cd
2 changed files with 17 additions and 14 deletions

View File

@ -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();
}
}

View File

@ -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;
}