summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2022-10-12 14:56:58 +0200
committerBad Diode <bd@badd10de.dev>2022-10-12 14:56:58 +0200
commit457efc07cd5989e947bc2f05feef9173fbde541a (patch)
treea2df6cc84fbaf588246a6e34643d19d21a1be8b7
parente101b44b986811b3e37bccae230fcb73adc4dee2 (diff)
downloaduxnnst-457efc07cd5989e947bc2f05feef9173fbde541a.tar.gz
uxnnst-457efc07cd5989e947bc2f05feef9173fbde541a.zip
[WIP] Parametrize the screen update and refresh frequencies
-rw-r--r--src/main.c17
-rw-r--r--src/ppu.c14
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) {
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 }
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 @@
22 WITH REGARD TO THIS SOFTWARE. 22 WITH REGARD TO THIS SOFTWARE.
23 */ 23 */
24 24
25// Parameters.
26static int zoom = 2;
27static int frames_per_update = 5;
28static int blits_per_refresh = 60 * 5;
29
25static size_t screen_width = 0; 30static size_t screen_width = 0;
26static size_t screen_height = 0; 31static size_t screen_height = 0;
27static size_t bpp = 0; 32static size_t bpp = 0;
28static int fb_file = 0; 33static int fb_file = 0;
29static int refresh_file = 0; 34static int refresh_file = 0;
30static int zoom = 2; 35static frames_refresh = 0;
31 36
32static u8 *framebuffer = 0; 37static 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}