diff options
author | Bad Diode <bd@badd10de.dev> | 2022-10-12 14:56:58 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2022-10-12 14:56:58 +0200 |
commit | 457efc07cd5989e947bc2f05feef9173fbde541a (patch) | |
tree | a2df6cc84fbaf588246a6e34643d19d21a1be8b7 | |
parent | e101b44b986811b3e37bccae230fcb73adc4dee2 (diff) | |
download | uxnfb-457efc07cd5989e947bc2f05feef9173fbde541a.tar.gz uxnfb-457efc07cd5989e947bc2f05feef9173fbde541a.zip |
[WIP] Parametrize the screen update and refresh frequencies
-rw-r--r-- | src/main.c | 17 | ||||
-rw-r--r-- | src/ppu.c | 14 |
2 files changed, 17 insertions, 14 deletions
@@ -297,9 +297,9 @@ handle_keyboard(void) { | |||
297 | 297 | ||
298 | // NOTE: Nook overrides. | 298 | // NOTE: Nook overrides. |
299 | switch (key_code) { | 299 | switch (key_code) { |
300 | case 156: { rune = 0x40; } break; // top left | 300 | case 156: { rune = 0x10; } break; // top left |
301 | case 139: { rune = 0x40; } break; // bottom left | 301 | case 139: { rune = 0x20; } break; // bottom left |
302 | case 151: { rune = 0x80; } break; // top right | 302 | case 151: { rune = 0x40; } break; // top right |
303 | case 158: { rune = 0x80; } break; // bottom right | 303 | case 158: { rune = 0x80; } break; // bottom right |
304 | default: break; | 304 | default: break; |
305 | } | 305 | } |
@@ -558,19 +558,10 @@ main(int argc, char *argv[]) { | |||
558 | 558 | ||
559 | // Blit ppu.pixels to the framebuffer. | 559 | // Blit ppu.pixels to the framebuffer. |
560 | blit_framebuffer(); | 560 | blit_framebuffer(); |
561 | // TODO: make update frames and refresh frames as parameters instead | 561 | if (++frames_update > frames_per_update) { |
562 | // of hardcoded | ||
563 | if (++frames_update > 5) { | ||
564 | write(fb_file, "0", 0); | 562 | write(fb_file, "0", 0); |
565 | frames_update = 0; | 563 | frames_update = 0; |
566 | } | 564 | } |
567 | // NOTE: Maybe this should happen on blit_framebuffer depending on | ||
568 | // the number of actual updates (uxn applications that don't modify | ||
569 | // the framebuffer shouldn't have to blink). | ||
570 | if (++frames_refresh > 360) { | ||
571 | write(refresh_file, "1", 1); | ||
572 | frames_refresh = 0; | ||
573 | } | ||
574 | frame_time = time_now(); | 565 | frame_time = time_now(); |
575 | } | 566 | } |
576 | } | 567 | } |
@@ -22,12 +22,17 @@ | |||
22 | WITH REGARD TO THIS SOFTWARE. | 22 | WITH REGARD TO THIS SOFTWARE. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | // Parameters. | ||
26 | static int zoom = 2; | ||
27 | static int frames_per_update = 5; | ||
28 | static int blits_per_refresh = 60 * 5; | ||
29 | |||
25 | static size_t screen_width = 0; | 30 | static size_t screen_width = 0; |
26 | static size_t screen_height = 0; | 31 | static size_t screen_height = 0; |
27 | static size_t bpp = 0; | 32 | static size_t bpp = 0; |
28 | static int fb_file = 0; | 33 | static int fb_file = 0; |
29 | static int refresh_file = 0; | 34 | static int refresh_file = 0; |
30 | static int zoom = 2; | 35 | static frames_refresh = 0; |
31 | 36 | ||
32 | static u8 *framebuffer = 0; | 37 | static u8 *framebuffer = 0; |
33 | 38 | ||
@@ -242,5 +247,12 @@ blit_framebuffer(void) { | |||
242 | } | 247 | } |
243 | dirty_lines[j] = 0; | 248 | dirty_lines[j] = 0; |
244 | } | 249 | } |
250 | // NOTE: Maybe this should happen on blit_framebuffer depending on | ||
251 | // the number of actual updates (uxn applications that don't modify | ||
252 | // the framebuffer shouldn't have to blink). | ||
253 | if (++frames_refresh > blits_per_refresh) { | ||
254 | write(refresh_file, "1", 1); | ||
255 | frames_refresh = 0; | ||
256 | } | ||
245 | reqdraw = 0; | 257 | reqdraw = 0; |
246 | } | 258 | } |