new cfg file system
[libpicofe.git] / psp / emu.c
index 9c69d88..4af44b9 100644 (file)
--- a/psp/emu.c
+++ b/psp/emu.c
@@ -111,19 +111,8 @@ void emu_Deinit(void)
                SRam.changed = 0;
        }
 
-       if (!(currentConfig.EmuOpt & 0x20)) {
-               FILE *f = fopen(PicoConfigFile, "r+b");
-               if (!f) emu_WriteConfig(0);
-               else {
-                       // if we already have config, reload it, except last ROM
-                       fseek(f, sizeof(currentConfig.lastRomFile), SEEK_SET);
-                       fread(&currentConfig.EmuOpt, 1, sizeof(currentConfig) - sizeof(currentConfig.lastRomFile), f);
-                       fseek(f, 0, SEEK_SET);
-                       fwrite(&currentConfig, 1, sizeof(currentConfig), f);
-                       fflush(f);
-                       fclose(f);
-               }
-       }
+       if (!(currentConfig.EmuOpt & 0x20))
+               config_writelrom(PicoConfigFile);
 
        PicoExit();
        sound_deinit();
@@ -1075,3 +1064,19 @@ void emu_ResetGame(void)
        reset_timing = 1;
 }
 
+void emu_HandleResume(void)
+{
+       if (!(PicoMCD & 1)) return;
+
+       // reopen files..
+       if (Pico_mcd->TOC.Tracks[0].F != NULL)
+       {
+               lprintf("emu_HandleResume: reopen %s\n", romFileName);
+               pm_close(Pico_mcd->TOC.Tracks[0].F);
+               Pico_mcd->TOC.Tracks[0].F = pm_open(romFileName);
+               lprintf("reopen %s\n", Pico_mcd->TOC.Tracks[0].F != NULL ? "ok" : "failed");
+       }
+
+       mp3_reopen_file();
+}
+