1.40a fixes, pt2
authornotaz <notasas@gmail.com>
Sat, 29 Mar 2008 12:59:30 +0000 (12:59 +0000)
committernotaz <notasas@gmail.com>
Sat, 29 Mar 2008 12:59:30 +0000 (12:59 +0000)
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@403 be3aeb3a-fb24-0410-a615-afba39da0efa

common/emu.c

index a9b98ae..c2e4075 100644 (file)
@@ -481,6 +481,18 @@ static void romfname_ext(char *dst, const char *prefix, const char *ext)
 }\r
 \r
 \r
+static void make_config_cfg(char *cfg)\r
+{\r
+       strncpy(cfg, PicoConfigFile, 511);\r
+       if (config_slot != 0)\r
+       {\r
+               char *p = strrchr(cfg, '.');\r
+               if (p == NULL) p = cfg + strlen(cfg);\r
+               sprintf(p, ".%i.cfg", config_slot);\r
+       }\r
+       cfg[511] = 0;\r
+}\r
+\r
 int emu_ReadConfig(int game, int no_defaults)\r
 {\r
        char cfg[512];\r
@@ -491,14 +503,7 @@ int emu_ReadConfig(int game, int no_defaults)
        {\r
                if (!no_defaults)\r
                        emu_setDefaultConfig();\r
-               strncpy(cfg, PicoConfigFile, 511);\r
-               if (config_slot != 0)\r
-               {\r
-                       char *p = strrchr(cfg, '.');\r
-                       if (p == NULL) p = cfg + strlen(cfg);\r
-                       sprintf(p, ".%i.cfg", config_slot);\r
-               }\r
-               cfg[511] = 0;\r
+               make_config_cfg(cfg);\r
                ret = config_readsect(cfg, NULL);\r
        }\r
        else\r
@@ -511,18 +516,25 @@ int emu_ReadConfig(int game, int no_defaults)
                else strcpy(cfg,  "game.cfg");\r
 \r
                ret = -1;\r
-               if (config_havesect(cfg, sect)) {\r
+               if (config_havesect(cfg, sect))\r
+               {\r
+                       // read user's config\r
                        int vol = currentConfig.volume;\r
                        emu_setDefaultConfig();\r
                        ret = config_readsect(cfg, sect);\r
                        currentConfig.volume = vol; // make vol global (bah)\r
                }\r
                else\r
-                       config_readsect("game_def.cfg", sect);\r
+               {\r
+                       // 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
+               }\r
 \r
                if (ret != 0)\r
                {\r
-                       // fall back to old\r
+                       // fall back to old game specific cfg\r
                        char extbuf[16];\r
                        if (config_slot != 0)\r
                                sprintf(extbuf, ".%i.pbcfg", config_slot);\r