allow slightly deviated sound rates (for Wiz)
[libpicofe.git] / common / emu.c
index 7de2aa9..118dc38 100644 (file)
@@ -643,7 +643,8 @@ int emu_read_config(int game, int no_defaults)
                        // read global config, and apply game_def.cfg on top\r
                        make_config_cfg(cfg);\r
                        config_readsect(cfg, NULL);\r
-                       ret = config_readsect("game_def.cfg", sect);\r
+                       emu_make_path(cfg, "game_def.cfg", sizeof(cfg));\r
+                       ret = config_readsect(cfg, sect);\r
                }\r
 \r
                if (ret == 0)\r
@@ -1275,9 +1276,6 @@ void emu_loop(void)
        if (PicoAHW & PAHW_MCD)\r
                PicoCDBufferInit();\r
 \r
-       if (currentConfig.EmuOpt & EOPT_PSYNC)\r
-               plat_video_wait_vsync();\r
-\r
        pemu_loop_prep();\r
 \r
        timestamp_fps = get_ticks();\r
@@ -1285,6 +1283,8 @@ void emu_loop(void)
 \r
        frames_done = frames_shown = pframes_done = 0;\r
 \r
+       plat_video_wait_vsync();\r
+\r
        /* loop with resync every 1 sec. */\r
        while (engineState == PGS_Running)\r
        {\r
@@ -1413,12 +1413,9 @@ void emu_loop(void)
                        if (diff < diff_lim)\r
                        {\r
                                // we are too fast\r
-                               if (currentConfig.EmuOpt & EOPT_PSYNC) {\r
-                                       if (diff_lim - diff > target_frametime/2)\r
-                                               plat_wait_till_us(timestamp_base + target_frametime/4);\r
+                               plat_wait_till_us(timestamp_base + diff_lim - target_frametime / 4);\r
+                               if (currentConfig.EmuOpt & EOPT_VSYNC)\r
                                        plat_video_wait_vsync();\r
-                               } else\r
-                                       plat_wait_till_us(timestamp_base + diff_lim);\r
                        }\r
                }\r
 \r
@@ -1429,9 +1426,6 @@ void emu_loop(void)
 \r
        emu_set_fastforward(0);\r
 \r
-       if (PicoAHW & PAHW_MCD)\r
-               PicoCDBufferFree();\r
-\r
        // save SRAM\r
        if ((currentConfig.EmuOpt & EOPT_EN_SRAM) && SRam.changed) {\r
                plat_status_msg_busy_first("Writing SRAM/BRAM...");\r
@@ -1439,9 +1433,11 @@ void emu_loop(void)
                SRam.changed = 0;\r
        }\r
 \r
-       // do menu background to be sure it's right\r
-       pemu_forced_frame(POPT_EN_SOFTSCALE);\r
-\r
        pemu_loop_end();\r
+\r
+       // pemu_loop_end() might want to do 1 frame for bg image,\r
+       // so free CD buffer here\r
+       if (PicoAHW & PAHW_MCD)\r
+               PicoCDBufferFree();\r
 }\r
 \r