X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=common%2Femu.c;h=1e836941176c40db7842fbee2a94b41722f71971;hb=9cfdd2d2e94daaeb85ab7f1675312dec80659ec3;hp=23e90ebed1fc39b2608a601d408b8fbd85b5e115;hpb=d2f29611d1379a249c8f3f955ed16a336f9290cd;p=libpicofe.git diff --git a/common/emu.c b/common/emu.c index 23e90eb..1e83694 100644 --- a/common/emu.c +++ b/common/emu.c @@ -1116,7 +1116,7 @@ static void emu_tray_close(void) void emu_32x_startup(void) { - plat_video_toggle_renderer(0, 1, 0); + plat_video_toggle_renderer(0, 0); system_announce(); } @@ -1247,9 +1247,9 @@ static void run_events_ui(unsigned int which) PicoStateProgressCB = NULL; } } - if ((which & PEV_SWITCH_RND) && !(PicoAHW & PAHW_32X)) + if (which & PEV_SWITCH_RND) { - plat_video_toggle_renderer(1, 0, 0); + plat_video_toggle_renderer(1, 0); } if (which & (PEV_SSLOT_PREV|PEV_SSLOT_NEXT)) { @@ -1347,6 +1347,8 @@ void emu_init(void) mkdir_path(path, pos, "srm"); mkdir_path(path, pos, "brm"); + pprof_init(); + make_config_cfg(path); config_readlrom(path); @@ -1373,6 +1375,8 @@ void emu_finish(void) #endif } + pprof_finish(); + PicoExit(); } @@ -1432,6 +1436,8 @@ void emu_loop(void) unsigned int timestamp; int diff, diff_lim; + pprof_start(main); + timestamp = get_ticks(); if (reset_timing) { reset_timing = 0; @@ -1470,6 +1476,7 @@ void emu_loop(void) } bench_fps += frames_shown; sprintf(fpsbuff, "%02i/%02i/%02i", frames_shown, bench_fps_s, (bf[0]+bf[1]+bf[2]+bf[3])>>2); + printf("%s\n", fpsbuff); #else if (currentConfig.EmuOpt & EOPT_SHOW_FPS) { sprintf(fpsbuff, "%02i/%02i", frames_shown, frames_done); @@ -1487,17 +1494,15 @@ void emu_loop(void) { if ((currentConfig.EmuOpt & EOPT_NO_FRMLIMIT) && currentConfig.Frameskip >= 0) pframes_done = 0; - else { + else pframes_done -= target_fps; - /* don't allow it to drift during heavy slowdowns */ - if (pframes_done < -5) { - reset_timing = 1; - continue; - } - if (pframes_done < -2) - pframes_done = -2; + if (pframes_done < -2) { + /* don't drag more than 2 frames behind */ + pframes_done = -2; + timestamp_base = timestamp - 2 * target_frametime; } - timestamp_base += ms_to_ticks(1000); + else + timestamp_base += ms_to_ticks(1000); } diff = timestamp - timestamp_base; @@ -1522,19 +1527,20 @@ void emu_loop(void) else if (diff > diff_lim) { /* no time left for this frame - skip */ - if (diff - diff_lim >= ms_to_ticks(200)) { - /* if too much behind, reset instead */ - reset_timing = 1; + /* limit auto frameskip to 8 */ + if (frames_done / 8 <= frames_shown) { + emu_update_input(); + skip_frame(diff < diff_lim + target_frametime * 16); + pframes_done++; frames_done++; continue; } - emu_update_input(); - skip_frame(diff < diff_lim + target_frametime * 2); - pframes_done++; frames_done++; - continue; } emu_update_input(); PicoFrame(); + pemu_finalize_frame(fpsbuff, notice_msg); + + // plat_video_flip(); /* frame limiter */ if (!reset_timing && !(currentConfig.EmuOpt & (EOPT_NO_FRMLIMIT|EOPT_EXT_FRMLIMIT))) @@ -1552,9 +1558,13 @@ void emu_loop(void) } } - pemu_update_display(fpsbuff, notice_msg); + // XXX: for some plats it might be better to flip before vsync + // (due to shadow registers in display hw) + plat_video_flip(); pframes_done++; frames_done++; frames_shown++; + + pprof_end(main); } emu_set_fastforward(0);