diff --git a/Src/OSD/SDL/Main.cpp b/Src/OSD/SDL/Main.cpp --- a/Src/OSD/SDL/Main.cpp +++ b/Src/OSD/SDL/Main.cpp @@ -307,7 +307,6 @@ Configuration file management and input settings. ******************************************************************************/ -#define CONFIG_FILE_PATH "Config/Supermodel.ini" #define CONFIG_FILE_COMMENT ";\n" \ "; Supermodel Configuration File\n" \ ";\n" @@ -315,9 +314,13 @@ // Create and configure inputs static bool ConfigureInputs(CInputs *Inputs, bool configure) { + char configFilePath[512]; + + sprintf(configFilePath, "%s/.supermodel/supermodel.ini", getenv("HOME")); + // Open and parse configuration file CINIFile INI; - INI.Open(CONFIG_FILE_PATH); // doesn't matter if it exists or not, will get overwritten + INI.Open(configFilePath); // doesn't matter if it exists or not, will get overwritten INI.SetDefaultSectionName("Global"); INI.Parse(); @@ -338,9 +341,9 @@ Inputs->WriteToINIFile(&INI, "Global"); if (OKAY != INI.Write(CONFIG_FILE_COMMENT)) - ErrorLog("Unable to save configuration to '%s'.", CONFIG_FILE_PATH); + ErrorLog("Unable to save configuration to '%s'.", configFilePath); else - printf("Configuration successfully saved to '%s'.\n", CONFIG_FILE_PATH); + printf("Configuration successfully saved to '%s'.\n", configFilePath); } else puts("Configuration aborted..."); @@ -412,9 +415,13 @@ // Read settings (from a specific section) from the config file static void ReadConfigFile(const char *section) { + char configFilePath[512]; + + sprintf(configFilePath, "%s/.supermodel/supermodel.ini", getenv("HOME")); + CINIFile INI; - INI.Open(CONFIG_FILE_PATH); + INI.Open(configFilePath); INI.SetDefaultSectionName("Global"); // required to read settings not associated with a specific section INI.Parse(); ApplySettings(&INI, section); @@ -498,10 +505,10 @@ static void SaveState(CModel3 *Model3) { CBlockFile SaveState; - char filePath[24]; + char filePath[512]; int fileVersion = STATE_FILE_VERSION; - sprintf(filePath, "Saves/%s.st%d", Model3->GetGameInfo()->id, saveSlot); + sprintf(filePath, "%s/.supermodel/saves/%s.st%d", getenv("HOME"), Model3->GetGameInfo()->id, saveSlot); if (OKAY != SaveState.Create(filePath, "Supermodel Save State", "Supermodel Version " SUPERMODEL_VERSION)) { ErrorLog("Unable to save state to '%s'.", filePath); @@ -522,11 +529,11 @@ static void LoadState(CModel3 *Model3) { CBlockFile SaveState; - char filePath[24]; + char filePath[512]; int fileVersion; // Generate file path - sprintf(filePath, "Saves/%s.st%d", Model3->GetGameInfo()->id, saveSlot); + sprintf(filePath, "%s/.supermodel/saves/%s.st%d", getenv("HOME"), Model3->GetGameInfo()->id, saveSlot); // Open and check to make sure format is correct if (OKAY != SaveState.Load(filePath)) @@ -558,10 +565,10 @@ static void SaveNVRAM(CModel3 *Model3) { CBlockFile NVRAM; - char filePath[24]; + char filePath[512]; int fileVersion = NVRAM_FILE_VERSION; - sprintf(filePath, "NVRAM/%s.nv", Model3->GetGameInfo()->id); + sprintf(filePath, "%s/.supermodel/NVRAM/%s.nv", getenv("HOME"), Model3->GetGameInfo()->id); if (OKAY != NVRAM.Create(filePath, "Supermodel NVRAM State", "Supermodel Version " SUPERMODEL_VERSION)) { ErrorLog("Unable to save NVRAM to '%s'. Make sure directory exists!", filePath); @@ -581,11 +588,11 @@ static void LoadNVRAM(CModel3 *Model3) { CBlockFile NVRAM; - char filePath[24]; + char filePath[512]; int fileVersion; // Generate file path - sprintf(filePath, "NVRAM/%s.nv", Model3->GetGameInfo()->id); + sprintf(filePath, "%s/.supermodel/NVRAM/%s.nv", getenv("HOME"), Model3->GetGameInfo()->id); // Open and check to make sure format is correct if (OKAY != NVRAM.Load(filePath))