mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Support a gcm revision-specific game ini for cheats + partially fix gecko codes in default ini.
The local ini is not revision-specific because it would require renaming everything. Meh.
This commit is contained in:
@ -28,8 +28,8 @@ struct ARCode
|
||||
|
||||
void RunAllActive();
|
||||
bool RunCode(const ARCode &arcode);
|
||||
void LoadCodes(IniFile &globalIni, IniFile &localIni, bool forceLoad);
|
||||
void LoadCodes(std::vector<ARCode> &_arCodes, IniFile &globalIni, IniFile &localIni);
|
||||
void LoadCodes(IniFile &globalini, IniFile &localIni, bool forceLoad);
|
||||
void LoadCodes(std::vector<ARCode> &_arCodes, IniFile &globalini, IniFile &localIni);
|
||||
size_t GetCodeListSize();
|
||||
ARCode GetARCode(size_t index);
|
||||
void SetARCode_IsActive(bool active, size_t index);
|
||||
|
@ -149,8 +149,7 @@ bool CBoot::EmulatedBS2_GC()
|
||||
PC = PowerPC::ppcState.gpr[3];
|
||||
|
||||
// Load patches
|
||||
std::string gameID = VolumeHandler::GetVolume()->GetUniqueID();
|
||||
PatchEngine::LoadPatches(gameID.c_str());
|
||||
PatchEngine::LoadPatches();
|
||||
|
||||
PowerPC::ppcState.DebugCount = 0;
|
||||
|
||||
@ -422,7 +421,7 @@ bool CBoot::EmulatedBS2_Wii()
|
||||
|
||||
// Load patches and run startup patches
|
||||
std::string gameID = VolumeHandler::GetVolume()->GetUniqueID();
|
||||
PatchEngine::LoadPatches(gameID.c_str());
|
||||
PatchEngine::LoadPatches();
|
||||
|
||||
// return
|
||||
PC = PowerPC::ppcState.gpr[3];
|
||||
|
@ -118,7 +118,7 @@ bool CBoot::Boot_WiiWAD(const char* _pFilename)
|
||||
// Load patches and run startup patches
|
||||
const DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(_pFilename);
|
||||
if (pVolume != NULL)
|
||||
PatchEngine::LoadPatches(pVolume->GetUniqueID().c_str());
|
||||
PatchEngine::LoadPatches();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -75,14 +75,17 @@ bool BootCore(const std::string& _rFilename)
|
||||
|
||||
// Load game specific settings
|
||||
std::string unique_id = StartUp.GetUniqueID();
|
||||
std::string revision_specific = StartUp.m_strRevisionSpecificUniqueID;
|
||||
StartUp.m_strGameIniDefault = File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + unique_id + ".ini";
|
||||
if (revision_specific != "")
|
||||
StartUp.m_strGameIniDefaultRevisionSpecific = File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + revision_specific + ".ini";
|
||||
else
|
||||
StartUp.m_strGameIniDefaultRevisionSpecific = "";
|
||||
StartUp.m_strGameIniLocal = File::GetUserPath(D_GAMESETTINGS_IDX) + unique_id + ".ini";
|
||||
|
||||
if (unique_id.size() == 6)
|
||||
{
|
||||
IniFile game_ini;
|
||||
game_ini.Load(StartUp.m_strGameIniDefault);
|
||||
game_ini.Load(StartUp.m_strGameIniLocal, true);
|
||||
IniFile game_ini = StartUp.LoadGameIni();
|
||||
|
||||
config_cache.valid = true;
|
||||
config_cache.bCPUThread = StartUp.bCPUThread;
|
||||
|
@ -204,9 +204,7 @@ bool Init()
|
||||
g_aspect_wide = _CoreParameter.bWii;
|
||||
if (g_aspect_wide)
|
||||
{
|
||||
IniFile gameIni;
|
||||
gameIni.Load(_CoreParameter.m_strGameIniDefault.c_str());
|
||||
gameIni.Load(_CoreParameter.m_strGameIniLocal.c_str(), true);
|
||||
IniFile gameIni = _CoreParameter.LoadGameIni();
|
||||
gameIni.Get("Wii", "Widescreen", &g_aspect_wide,
|
||||
!!SConfig::GetInstance().m_SYSCONF->
|
||||
GetData<u8>("IPL.AR"));
|
||||
|
@ -147,6 +147,7 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
|
||||
}
|
||||
m_strName = pVolume->GetName();
|
||||
m_strUniqueID = pVolume->GetUniqueID();
|
||||
m_strRevisionSpecificUniqueID = pVolume->GetRevisionSpecificUniqueID();
|
||||
|
||||
// Check if we have a Wii disc
|
||||
bWii = DiscIO::IsVolumeWiiDisc(pVolume);
|
||||
@ -390,3 +391,29 @@ void SCoreStartupParameter::CheckMemcardPath(std::string& memcardPath, std::stri
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IniFile SCoreStartupParameter::LoadGameIni() const
|
||||
{
|
||||
IniFile game_ini;
|
||||
game_ini.Load(m_strGameIniDefault);
|
||||
if (m_strGameIniDefaultRevisionSpecific != "")
|
||||
game_ini.Load(m_strGameIniDefaultRevisionSpecific, true);
|
||||
game_ini.Load(m_strGameIniLocal, true);
|
||||
return game_ini;
|
||||
}
|
||||
|
||||
IniFile SCoreStartupParameter::LoadDefaultGameIni() const
|
||||
{
|
||||
IniFile game_ini;
|
||||
game_ini.Load(m_strGameIniDefault);
|
||||
if (m_strGameIniDefaultRevisionSpecific != "")
|
||||
game_ini.Load(m_strGameIniDefaultRevisionSpecific, true);
|
||||
return game_ini;
|
||||
}
|
||||
|
||||
IniFile SCoreStartupParameter::LoadLocalGameIni() const
|
||||
{
|
||||
IniFile game_ini;
|
||||
game_ini.Load(m_strGameIniLocal);
|
||||
return game_ini;
|
||||
}
|
||||
|
@ -197,8 +197,10 @@ struct SCoreStartupParameter
|
||||
std::string m_strDVDRoot;
|
||||
std::string m_strApploader;
|
||||
std::string m_strUniqueID;
|
||||
std::string m_strRevisionSpecificUniqueID;
|
||||
std::string m_strName;
|
||||
std::string m_strGameIniDefault;
|
||||
std::string m_strGameIniDefaultRevisionSpecific;
|
||||
std::string m_strGameIniLocal;
|
||||
|
||||
// Constructor just calls LoadDefaults
|
||||
@ -208,6 +210,9 @@ struct SCoreStartupParameter
|
||||
bool AutoSetup(EBootBS2 _BootBS2);
|
||||
const std::string &GetUniqueID() const { return m_strUniqueID; }
|
||||
void CheckMemcardPath(std::string& memcardPath, std::string Region, bool isSlotA);
|
||||
IniFile LoadDefaultGameIni() const;
|
||||
IniFile LoadLocalGameIni() const;
|
||||
IniFile LoadGameIni() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -65,7 +65,8 @@ namespace Gecko
|
||||
std::string name, creator;
|
||||
std::vector<std::string> notes;
|
||||
|
||||
bool enabled;
|
||||
bool enabled;
|
||||
bool user_defined;
|
||||
|
||||
bool Compare(GeckoCode compare) const;
|
||||
bool Exist(u32 address, u32 data);
|
||||
|
@ -15,70 +15,74 @@
|
||||
namespace Gecko
|
||||
{
|
||||
|
||||
// TODO: Support loading codes from default game inis.
|
||||
void LoadCodes(const IniFile& inifile, std::vector<GeckoCode>& gcodes)
|
||||
void LoadCodes(const IniFile& globalIni, const IniFile& localIni, std::vector<GeckoCode>& gcodes)
|
||||
{
|
||||
std::vector<std::string> lines;
|
||||
inifile.GetLines(GECKO_CODE_INI_SECTION, lines, false);
|
||||
|
||||
GeckoCode gcode;
|
||||
|
||||
std::vector<std::string>::const_iterator
|
||||
lines_iter = lines.begin(),
|
||||
lines_end = lines.end();
|
||||
for (; lines_iter!=lines_end; ++lines_iter)
|
||||
const IniFile* inis[] = {&globalIni, &localIni};
|
||||
for (size_t i = 0; i < ArraySize(inis); ++i)
|
||||
{
|
||||
if (lines_iter->empty())
|
||||
continue;
|
||||
std::vector<std::string> lines;
|
||||
inis[i]->GetLines(GECKO_CODE_INI_SECTION, lines, false);
|
||||
|
||||
std::istringstream ss(*lines_iter);
|
||||
GeckoCode gcode;
|
||||
|
||||
switch ((*lines_iter)[0])
|
||||
for (auto lines_iter = lines.begin(); lines_iter!=lines.end(); ++lines_iter)
|
||||
{
|
||||
if (lines_iter->empty())
|
||||
continue;
|
||||
|
||||
// enabled or disabled code
|
||||
case '+' :
|
||||
ss.seekg(1);
|
||||
case '$' :
|
||||
if (gcode.name.size())
|
||||
gcodes.push_back(gcode);
|
||||
gcode = GeckoCode();
|
||||
gcode.enabled = (1 == ss.tellg()); // silly
|
||||
ss.seekg(1, std::ios_base::cur);
|
||||
// read the code name
|
||||
std::getline(ss, gcode.name, '['); // stop at [ character (beginning of contributor name)
|
||||
gcode.name = StripSpaces(gcode.name);
|
||||
// read the code creator name
|
||||
std::getline(ss, gcode.creator, ']');
|
||||
break;
|
||||
std::istringstream ss(*lines_iter);
|
||||
|
||||
// notes
|
||||
case '*':
|
||||
gcode.notes.push_back(std::string(++lines_iter->begin(), lines_iter->end()));
|
||||
break;
|
||||
switch ((*lines_iter)[0])
|
||||
{
|
||||
|
||||
// enabled or disabled code
|
||||
case '+' :
|
||||
ss.seekg(1);
|
||||
case '$' :
|
||||
if (gcode.name.size())
|
||||
gcodes.push_back(gcode);
|
||||
gcode = GeckoCode();
|
||||
gcode.enabled = (1 == ss.tellg()); // silly
|
||||
gcode.user_defined = i == 1;
|
||||
ss.seekg(1, std::ios_base::cur);
|
||||
// read the code name
|
||||
std::getline(ss, gcode.name, '['); // stop at [ character (beginning of contributor name)
|
||||
gcode.name = StripSpaces(gcode.name);
|
||||
// read the code creator name
|
||||
std::getline(ss, gcode.creator, ']');
|
||||
break;
|
||||
|
||||
// notes
|
||||
case '*':
|
||||
gcode.notes.push_back(std::string(++lines_iter->begin(), lines_iter->end()));
|
||||
break;
|
||||
|
||||
// either part of the code, or an option choice
|
||||
default :
|
||||
{
|
||||
GeckoCode::Code new_code;
|
||||
// TODO: support options
|
||||
new_code.original_line = *lines_iter;
|
||||
ss >> std::hex >> new_code.address >> new_code.data;
|
||||
gcode.codes.push_back(new_code);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// either part of the code, or an option choice
|
||||
default :
|
||||
{
|
||||
GeckoCode::Code new_code;
|
||||
// TODO: support options
|
||||
new_code.original_line = *lines_iter;
|
||||
ss >> std::hex >> new_code.address >> new_code.data;
|
||||
gcode.codes.push_back(new_code);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// add the last code
|
||||
if (gcode.name.size())
|
||||
gcodes.push_back(gcode);
|
||||
}
|
||||
|
||||
// add the last code
|
||||
if (gcode.name.size())
|
||||
gcodes.push_back(gcode);
|
||||
}
|
||||
|
||||
// used by the SaveGeckoCodes function
|
||||
void SaveGeckoCode(std::vector<std::string>& lines, const GeckoCode& gcode)
|
||||
{
|
||||
if (!gcode.user_defined)
|
||||
return;
|
||||
|
||||
std::string name;
|
||||
|
||||
if (gcode.enabled)
|
||||
|
@ -12,7 +12,7 @@
|
||||
namespace Gecko
|
||||
{
|
||||
|
||||
void LoadCodes(const IniFile& inifile, std::vector<GeckoCode>& gcodes);
|
||||
void LoadCodes(const IniFile& globalIni, const IniFile& localIni, std::vector<GeckoCode>& gcodes);
|
||||
void SaveCodes(IniFile& inifile, const std::vector<GeckoCode>& gcodes);
|
||||
|
||||
};
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "GeckoCode.h"
|
||||
#include "GeckoCodeConfig.h"
|
||||
#include "FileUtil.h"
|
||||
#include "ConfigManager.h"
|
||||
|
||||
using namespace Common;
|
||||
|
||||
@ -166,22 +167,18 @@ int GetSpeedhackCycles(const u32 addr)
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
void LoadPatches(const char *gameID)
|
||||
void LoadPatches()
|
||||
{
|
||||
IniFile globalIni, localIni;
|
||||
globalIni.Load(File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + gameID + ".ini");
|
||||
localIni.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + gameID + ".ini", true);
|
||||
|
||||
IniFile merged;
|
||||
merged.Load(File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + gameID + ".ini");
|
||||
merged.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + gameID + ".ini", true);
|
||||
IniFile merged = SConfig::GetInstance().m_LocalCoreStartupParameter.LoadGameIni();
|
||||
IniFile globalIni = SConfig::GetInstance().m_LocalCoreStartupParameter.LoadDefaultGameIni();
|
||||
IniFile localIni = SConfig::GetInstance().m_LocalCoreStartupParameter.LoadLocalGameIni();
|
||||
|
||||
LoadPatchSection("OnFrame", onFrame, globalIni, localIni);
|
||||
ActionReplay::LoadCodes(globalIni, localIni, false);
|
||||
|
||||
// lil silly
|
||||
std::vector<Gecko::GeckoCode> gcodes;
|
||||
Gecko::LoadCodes(localIni, gcodes);
|
||||
Gecko::LoadCodes(globalIni, localIni, gcodes);
|
||||
Gecko::SetActiveCodes(gcodes);
|
||||
|
||||
LoadSpeedhacks("Speedhacks", speedHacks, merged);
|
||||
|
@ -39,7 +39,7 @@ struct Patch
|
||||
int GetSpeedhackCycles(const u32 addr);
|
||||
void LoadPatchSection(const char *section, std::vector<Patch> &patches,
|
||||
IniFile &globalIni, IniFile &localIni);
|
||||
void LoadPatches(const char *gameID);
|
||||
void LoadPatches();
|
||||
void ApplyFramePatches();
|
||||
void ApplyARPatches();
|
||||
void Shutdown();
|
||||
|
Reference in New Issue
Block a user