bugfixes, new config system and messed code for it
[picodrive.git] / platform / gizmondo / emu.c
index 440a8de..9a28553 100644 (file)
@@ -104,24 +104,13 @@ void emu_Init(void)
 void emu_Deinit(void)
 {
        // save SRAM
-       if((currentConfig.EmuOpt & 1) && SRam.changed) {
+       if ((currentConfig.EmuOpt & 1) && SRam.changed) {
                emu_SaveLoadGame(0, 1);
                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();
 }
@@ -523,11 +512,22 @@ static void find_combos(void)
        combo_keys = combo_acts = 0;
        for (act = 0; act < 32; act++)
        {
-               int keyc = 0;
+               int keyc = 0, keyc2 = 0;
                if (act == 16 || act == 17) continue; // player2 flag
-               for (u = 0; u < 32; u++)
+               if (act > 17)
+               {
+                       for (u = 0; u < 32; u++)
+                               if (currentConfig.KeyBinds[u] & (1 << act)) keyc++;
+               }
+               else
                {
-                       if (currentConfig.KeyBinds[u] & (1 << act)) keyc++;
+                       for (u = 0; u < 32; u++)
+                               if ((currentConfig.KeyBinds[u] & 0x30000) == 0 && // pl. 1
+                                       (currentConfig.KeyBinds[u] & (1 << act))) keyc++;
+                       for (u = 0; u < 32; u++)
+                               if ((currentConfig.KeyBinds[u] & 0x30000) == 1 && // pl. 2
+                                       (currentConfig.KeyBinds[u] & (1 << act))) keyc2++;
+                       if (keyc2 > keyc) keyc = keyc2;
                }
                if (keyc > 1)
                {
@@ -593,7 +593,7 @@ void emu_Loop(void)
        {
                int ret, snd_excess_add, stereo;
                if (PsndRate != PsndRate_old || (PicoOpt&0x0b) != (PicoOpt_old&0x0b) || Pico.m.pal != pal_old) {
-                       sound_rerate(Pico.m.frame_count ? 1 : 0);
+                       PsndRerate(Pico.m.frame_count ? 1 : 0);
                }
                stereo=(PicoOpt&8)>>3;
                snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps;