Merge pull request #48 from Parlane/SetupWiiMemory_tidy
Tidy up SetupWiiMemory
This commit is contained in:
commit
64e01ec763
|
@ -22,6 +22,10 @@ public:
|
||||||
INITIAL_SEED = 0x73B5DBFA
|
INITIAL_SEED = 0x73B5DBFA
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline void AddSetting(const char *key, const std::string& value)
|
||||||
|
{
|
||||||
|
AddSetting(key, value.c_str());
|
||||||
|
}
|
||||||
void AddSetting(const char *key, const char *value);
|
void AddSetting(const char *key, const char *value);
|
||||||
|
|
||||||
const u8 *GetData() const;
|
const u8 *GetData() const;
|
||||||
|
|
|
@ -10,6 +10,17 @@
|
||||||
|
|
||||||
#include "../CoreParameter.h"
|
#include "../CoreParameter.h"
|
||||||
|
|
||||||
|
#include "Volume.h"
|
||||||
|
using DiscIO::IVolume;
|
||||||
|
|
||||||
|
typedef struct CountrySetting
|
||||||
|
{
|
||||||
|
const std::string area;
|
||||||
|
const std::string video;
|
||||||
|
const std::string game;
|
||||||
|
const std::string code;
|
||||||
|
} CountrySetting;
|
||||||
|
|
||||||
class CBoot
|
class CBoot
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -45,7 +56,7 @@ private:
|
||||||
static bool Load_BS2(const std::string& _rBootROMFilename);
|
static bool Load_BS2(const std::string& _rBootROMFilename);
|
||||||
static void Load_FST(bool _bIsWii);
|
static void Load_FST(bool _bIsWii);
|
||||||
|
|
||||||
static bool SetupWiiMemory(unsigned int _CountryCode);
|
static bool SetupWiiMemory(IVolume::ECountry country);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -158,56 +158,28 @@ bool CBoot::EmulatedBS2_GC()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBoot::SetupWiiMemory(unsigned int _CountryCode)
|
bool CBoot::SetupWiiMemory(IVolume::ECountry country)
|
||||||
{
|
{
|
||||||
INFO_LOG(BOOT, "Setup Wii Memory...");
|
static const CountrySetting SETTING_EUROPE = {"EUR", "PAL", "EU", "LE"};
|
||||||
|
static const std::map<IVolume::ECountry, const CountrySetting&> country_settings = {
|
||||||
// Write the 256 byte setting.txt to memory.
|
{IVolume::COUNTRY_EUROPE, SETTING_EUROPE},
|
||||||
std::string settings_Filename(Common::GetTitleDataPath(TITLEID_SYSMENU) + WII_SETTING);
|
{IVolume::COUNTRY_USA, {"USA", "NTSC", "US", "LU"}},
|
||||||
std::string area, model, code, video, game;
|
{IVolume::COUNTRY_JAPAN, {"JPN", "NTSC", "JP", "LJ"}},
|
||||||
|
{IVolume::COUNTRY_KOREA, {"KOR", "NTSC", "KR", "LKH"}},
|
||||||
|
//TODO: Determine if Taiwan have their own specific settings.
|
||||||
switch((DiscIO::IVolume::ECountry)_CountryCode)
|
// Also determine if there are other specific settings
|
||||||
{
|
// for other countries.
|
||||||
case DiscIO::IVolume::COUNTRY_KOREA:
|
{IVolume::COUNTRY_TAIWAN, {"JPN", "NTSC", "JP", "LJ"}}
|
||||||
area = "KOR";
|
};
|
||||||
video = "NTSC";
|
auto entryPos = country_settings.find(country);
|
||||||
game = "KR";
|
const CountrySetting& country_setting =
|
||||||
code = "LKH";
|
(entryPos != country_settings.end()) ?
|
||||||
break;
|
entryPos->second :
|
||||||
case DiscIO::IVolume::COUNTRY_TAIWAN:
|
SETTING_EUROPE; //Default to EUROPE
|
||||||
// TODO: Determine if Taiwan have their own specific settings.
|
|
||||||
case DiscIO::IVolume::COUNTRY_JAPAN:
|
|
||||||
area = "JPN";
|
|
||||||
video = "NTSC";
|
|
||||||
game = "JP";
|
|
||||||
code = "LJ";
|
|
||||||
break;
|
|
||||||
case DiscIO::IVolume::COUNTRY_USA:
|
|
||||||
area = "USA";
|
|
||||||
video = "NTSC";
|
|
||||||
game = "US";
|
|
||||||
code = "LU";
|
|
||||||
break;
|
|
||||||
case DiscIO::IVolume::COUNTRY_EUROPE:
|
|
||||||
area = "EUR";
|
|
||||||
video = "PAL";
|
|
||||||
game = "EU";
|
|
||||||
code = "LE";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// PanicAlertT("SetupWiiMem: Unknown country. Wii boot process will be switched to European settings.");
|
|
||||||
area = "EUR";
|
|
||||||
video = "PAL";
|
|
||||||
game = "EU";
|
|
||||||
code = "LE";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
model = "RVL-001(" + area + ")";
|
|
||||||
|
|
||||||
SettingsHandler gen;
|
SettingsHandler gen;
|
||||||
std::string serno = "";
|
std::string serno;
|
||||||
|
std::string settings_Filename(Common::GetTitleDataPath(TITLEID_SYSMENU) + WII_SETTING);
|
||||||
if (File::Exists(settings_Filename))
|
if (File::Exists(settings_Filename))
|
||||||
{
|
{
|
||||||
File::IOFile settingsFileHandle(settings_Filename, "rb");
|
File::IOFile settingsFileHandle(settings_Filename, "rb");
|
||||||
|
@ -230,29 +202,31 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode)
|
||||||
INFO_LOG(BOOT, "Using serial number: %s", serno.c_str());
|
INFO_LOG(BOOT, "Using serial number: %s", serno.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
gen.AddSetting("AREA", area.c_str());
|
std::string model = "RVL-001(" + country_setting.area + ")";
|
||||||
gen.AddSetting("MODEL", model.c_str());
|
gen.AddSetting("AREA", country_setting.area);
|
||||||
|
gen.AddSetting("MODEL", model);
|
||||||
gen.AddSetting("DVD", "0");
|
gen.AddSetting("DVD", "0");
|
||||||
gen.AddSetting("MPCH", "0x7FFE");
|
gen.AddSetting("MPCH", "0x7FFE");
|
||||||
gen.AddSetting("CODE", code.c_str());
|
gen.AddSetting("CODE", country_setting.code);
|
||||||
gen.AddSetting("SERNO", serno.c_str());
|
gen.AddSetting("SERNO", serno);
|
||||||
gen.AddSetting("VIDEO", video.c_str());
|
gen.AddSetting("VIDEO", country_setting.video);
|
||||||
gen.AddSetting("GAME", game.c_str());
|
gen.AddSetting("GAME", country_setting.game);
|
||||||
|
|
||||||
|
|
||||||
File::CreateFullPath(settings_Filename);
|
File::CreateFullPath(settings_Filename);
|
||||||
|
|
||||||
{
|
{
|
||||||
File::IOFile settingsFileHandle(settings_Filename, "wb");
|
File::IOFile settingsFileHandle(settings_Filename, "wb");
|
||||||
|
|
||||||
if (!settingsFileHandle.WriteBytes(gen.GetData(), SettingsHandler::SETTINGS_SIZE))
|
if (!settingsFileHandle.WriteBytes(gen.GetData(), SettingsHandler::SETTINGS_SIZE))
|
||||||
{
|
{
|
||||||
PanicAlertT("SetupWiiMem: Cant create setting file");
|
PanicAlertT("SetupWiiMemory: Cant create setting.txt file");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// Write the 256 byte setting.txt to memory.
|
||||||
Memory::WriteBigEData(gen.GetData(), 0x3800, SettingsHandler::SETTINGS_SIZE);
|
Memory::WriteBigEData(gen.GetData(), 0x3800, SettingsHandler::SETTINGS_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INFO_LOG(BOOT, "Setup Wii Memory...");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Set hardcoded global variables to Wii memory. These are partly collected from
|
Set hardcoded global variables to Wii memory. These are partly collected from
|
||||||
Wiibrew. These values are needed for the games to function correctly. A few
|
Wiibrew. These values are needed for the games to function correctly. A few
|
||||||
|
|
Loading…
Reference in New Issue