input def bind fix, rnd note
[libpicofe.git] / common / emu.c
index becc0c2..167f2f0 100644 (file)
@@ -407,8 +407,8 @@ int emu_reload_rom(char *rom_fname)
                // valid CD image, check for BIOS..\r
 \r
                // we need to have config loaded at this point\r
-               ret = emu_read_config(1, 1);\r
-               if (!ret) emu_read_config(0, 1);\r
+               ret = emu_read_config(1, 0);\r
+               if (!ret) emu_read_config(0, 0);\r
                cfg_loaded = 1;\r
 \r
                if (PicoRegionOverride) {\r
@@ -465,8 +465,8 @@ int emu_reload_rom(char *rom_fname)
        if (!(PicoAHW & PAHW_MCD))\r
                memcpy(id_header, rom_data + 0x100, sizeof(id_header));\r
        if (!cfg_loaded) {\r
-               ret = emu_read_config(1, 1);\r
-               if (!ret) emu_read_config(0, 1);\r
+               ret = emu_read_config(1, 0);\r
+               if (!ret) emu_read_config(0, 0);\r
        }\r
 \r
        lprintf("PicoCartInsert(%p, %d);\n", rom_data, rom_size);\r
@@ -613,10 +613,11 @@ int emu_read_config(int game, int no_defaults)
        char cfg[512];\r
        int ret;\r
 \r
+       if (!no_defaults)\r
+               emu_set_defconfig();\r
+\r
        if (!game)\r
        {\r
-               if (!no_defaults)\r
-                       emu_set_defconfig();\r
                make_config_cfg(cfg);\r
                ret = config_readsect(cfg, NULL);\r
        }\r
@@ -643,7 +644,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 +1277,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 +1284,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 +1414,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