SConfig: Replace bNTSC with m_region
This lets us get rid of VideoInterface::SetRegionReg, a huge hack in CEXIMemoryCard, and some minor things.
This commit is contained in:
1 parent
66ea9f5cc1
commit
f85266df20
13 files changed
+90
-151
No files matched your search
@@ -188,32 +188,34 @@ bool CBoot::Load_BS2(const std::string& _rBootROMFilename)
|
||||
// Use zlibs crc32 implementation to compute the hash
|
||||
u32 ipl_hash = crc32(0L, Z_NULL, 0);
|
||||
ipl_hash = crc32(ipl_hash, (const Bytef*)data.data(), (u32)data.size());
|
||||
std::string ipl_region;
|
||||
DiscIO::Region ipl_region;
|
||||
switch (ipl_hash)
|
||||
{
|
||||
case USA_v1_0:
|
||||
case USA_v1_1:
|
||||
case USA_v1_2:
|
||||
case BRA_v1_0:
|
||||
ipl_region = USA_DIR;
|
||||
ipl_region = DiscIO::Region::NTSC_U;
|
||||
break;
|
||||
case JAP_v1_0:
|
||||
case JAP_v1_1:
|
||||
ipl_region = JAP_DIR;
|
||||
ipl_region = DiscIO::Region::NTSC_J;
|
||||
break;
|
||||
case PAL_v1_0:
|
||||
case PAL_v1_2:
|
||||
ipl_region = EUR_DIR;
|
||||
ipl_region = DiscIO::Region::PAL;
|
||||
break;
|
||||
default:
|
||||
PanicAlertT("IPL with unknown hash %x", ipl_hash);
|
||||
ipl_region = DiscIO::Region::UNKNOWN_REGION;
|
||||
break;
|
||||
}
|
||||
|
||||
std::string BootRegion = _rBootROMFilename.substr(_rBootROMFilename.find_last_of(DIR_SEP) - 3, 3);
|
||||
if (BootRegion != ipl_region)
|
||||
const DiscIO::Region boot_region = SConfig::GetInstance().m_region;
|
||||
if (ipl_region != DiscIO::Region::UNKNOWN_REGION && boot_region != ipl_region)
|
||||
PanicAlertT("%s IPL found in %s directory. The disc might not be recognized",
|
||||
ipl_region.c_str(), BootRegion.c_str());
|
||||
SConfig::GetDirectoryForRegion(ipl_region),
|
||||
SConfig::GetDirectoryForRegion(boot_region));
|
||||
|
||||
// Run the descrambler over the encrypted section containing BS1/BS2
|
||||
CEXIIPL::Descrambler((u8*)data.data() + 0x100, 0x1AFE00);
|
||||
@@ -255,7 +257,8 @@ bool CBoot::BootUp()
|
||||
g_symbolDB.Clear();
|
||||
|
||||
// PAL Wii uses NTSC framerate and linecount in 60Hz modes
|
||||
VideoInterface::Preset(_StartupPara.bNTSC || (_StartupPara.bWii && _StartupPara.bPAL60));
|
||||
VideoInterface::Preset(DiscIO::IsNTSC(_StartupPara.m_region) ||
|
||||
(_StartupPara.bWii && _StartupPara.bPAL60));
|
||||
|
||||
switch (_StartupPara.m_BootType)
|
||||
{
|
||||
@@ -275,8 +278,6 @@ bool CBoot::BootUp()
|
||||
}
|
||||
|
||||
std::string game_id = DVDInterface::GetVolume().GetGameID();
|
||||
if (game_id.size() >= 4)
|
||||
VideoInterface::SetRegionReg(game_id.at(3));
|
||||
|
||||
std::vector<u8> tmd_buffer = pVolume.GetTMD();
|
||||
if (!tmd_buffer.empty())
|
||||
@@ -419,7 +420,7 @@ bool CBoot::BootUp()
|
||||
|
||||
// Poor man's bootup
|
||||
if (_StartupPara.bWii)
|
||||
SetupWiiMemory(DiscIO::Region::UNKNOWN_REGION);
|
||||
SetupWiiMemory();
|
||||
else
|
||||
EmulatedBS2_GC(true);
|
||||
|
||||
|
||||
@@ -7,11 +7,6 @@
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
|
||||
namespace DiscIO
|
||||
{
|
||||
enum class Region;
|
||||
}
|
||||
|
||||
struct RegionSetting
|
||||
{
|
||||
const std::string area;
|
||||
@@ -57,5 +52,5 @@ private:
|
||||
static bool Load_BS2(const std::string& _rBootROMFilename);
|
||||
static void Load_FST(bool _bIsWii);
|
||||
|
||||
static bool SetupWiiMemory(DiscIO::Region region);
|
||||
static bool SetupWiiMemory();
|
||||
};
|
||||
@@ -74,8 +74,8 @@ bool CBoot::EmulatedBS2_GC(bool skipAppLoader)
|
||||
0x10000006,
|
||||
0x8000002C); // Console type - DevKit (retail ID == 0x00000003) see YAGCD 4.2.1.1.2
|
||||
|
||||
PowerPC::HostWrite_U32(SConfig::GetInstance().bNTSC ? 0 : 1,
|
||||
0x800000CC); // Fake the VI Init of the IPL (YAGCD 4.2.1.4)
|
||||
const bool ntsc = DiscIO::IsNTSC(SConfig::GetInstance().m_region);
|
||||
PowerPC::HostWrite_U32(ntsc ? 0 : 1, 0x800000CC); // Fake the VI Init of the IPL (YAGCD 4.2.1.4)
|
||||
|
||||
PowerPC::HostWrite_U32(0x01000000, 0x800000d0); // ARAM Size. 16MB main + 4/16/32MB external
|
||||
// (retail consoles have no external ARAM)
|
||||
@@ -113,13 +113,14 @@ bool CBoot::EmulatedBS2_GC(bool skipAppLoader)
|
||||
DVDRead(apploader_offset + 0x20, 0x01200000, apploader_size + apploader_trailer, false);
|
||||
|
||||
// Setup pointers like real BS2 does
|
||||
if (SConfig::GetInstance().bNTSC)
|
||||
if (ntsc)
|
||||
{
|
||||
PowerPC::ppcState.gpr[1] = 0x81566550; // StackPointer, used to be set to 0x816ffff0
|
||||
PowerPC::ppcState.gpr[2] = 0x81465cc0; // Global pointer to Small Data Area 2 Base (haven't
|
||||
// seen anything use it...meh)
|
||||
PowerPC::ppcState.gpr[13] =
|
||||
0x81465320; // Global pointer to Small Data Area Base (Luigi's Mansion's apploader uses it)
|
||||
// StackPointer, used to be set to 0x816ffff0
|
||||
PowerPC::ppcState.gpr[1] = 0x81566550;
|
||||
// Global pointer to Small Data Area 2 Base (haven't seen anything use it...meh)
|
||||
PowerPC::ppcState.gpr[2] = 0x81465cc0;
|
||||
// Global pointer to Small Data Area Base (Luigi's Mansion's apploader uses it)
|
||||
PowerPC::ppcState.gpr[13] = 0x81465320;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -181,22 +182,15 @@ bool CBoot::EmulatedBS2_GC(bool skipAppLoader)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CBoot::SetupWiiMemory(DiscIO::Region region)
|
||||
bool CBoot::SetupWiiMemory()
|
||||
{
|
||||
static const RegionSetting SETTING_NTSC_J = {"JPN", "NTSC", "JP", "LJ"};
|
||||
static const RegionSetting SETTING_NTSC_U = {"USA", "NTSC", "US", "LU"};
|
||||
static const RegionSetting SETTING_PAL = {"EUR", "PAL", "EU", "LE"};
|
||||
static const RegionSetting SETTING_NTSC_K = {"KOR", "NTSC", "KR", "LKH"};
|
||||
static const std::map<DiscIO::Region, const RegionSetting> region_settings = {
|
||||
{DiscIO::Region::NTSC_J, SETTING_NTSC_J},
|
||||
{DiscIO::Region::NTSC_U, SETTING_NTSC_U},
|
||||
{DiscIO::Region::PAL, SETTING_PAL},
|
||||
{DiscIO::Region::NTSC_K, SETTING_NTSC_K}};
|
||||
auto entryPos = region_settings.find(region);
|
||||
const RegionSetting& region_setting =
|
||||
(entryPos != region_settings.end()) ?
|
||||
entryPos->second :
|
||||
(SConfig::GetInstance().bNTSC ? SETTING_NTSC_U : SETTING_PAL);
|
||||
{DiscIO::Region::NTSC_J, {"JPN", "NTSC", "JP", "LJ"}},
|
||||
{DiscIO::Region::NTSC_U, {"USA", "NTSC", "US", "LU"}},
|
||||
{DiscIO::Region::PAL, {"EUR", "PAL", "EU", "LE"}},
|
||||
{DiscIO::Region::NTSC_K, {"KOR", "NTSC", "KR", "LKH"}}};
|
||||
auto entryPos = region_settings.find(SConfig::GetInstance().m_region);
|
||||
const RegionSetting& region_setting = entryPos->second;
|
||||
|
||||
SettingsHandler gen;
|
||||
std::string serno;
|
||||
@@ -311,7 +305,7 @@ bool CBoot::SetupWiiMemory(DiscIO::Region region)
|
||||
Memory::Write_U32(0x80000000, 0x00003184); // GameID Address
|
||||
|
||||
// Fake the VI Init of the IPL
|
||||
Memory::Write_U32(SConfig::GetInstance().bNTSC ? 0 : 1, 0x000000CC);
|
||||
Memory::Write_U32(DiscIO::IsNTSC(SConfig::GetInstance().m_region) ? 0 : 1, 0x000000CC);
|
||||
|
||||
// Clear exception handler. Why? Don't we begin with only zeros?
|
||||
for (int i = 0x3000; i <= 0x3038; i += 4)
|
||||
@@ -330,10 +324,7 @@ bool CBoot::EmulatedBS2_Wii()
|
||||
INFO_LOG(BOOT, "Faking Wii BS2...");
|
||||
|
||||
// Setup Wii memory
|
||||
DiscIO::Region region_code = DiscIO::Region::UNKNOWN_REGION;
|
||||
if (DVDInterface::VolumeIsValid())
|
||||
region_code = DVDInterface::GetVolume().GetRegion();
|
||||
if (SetupWiiMemory(region_code) == false)
|
||||
if (!SetupWiiMemory())
|
||||
return false;
|
||||
|
||||
// Execute the apploader
|
||||
|
||||
@@ -89,13 +89,8 @@ bool CBoot::Boot_WiiWAD(const std::string& _pFilename)
|
||||
if (titleID == TITLEID_SYSMENU)
|
||||
HLE_IPC_CreateVirtualFATFilesystem();
|
||||
// setup Wii memory
|
||||
if (!SetupWiiMemory(ContentLoader.GetRegion()))
|
||||
if (!SetupWiiMemory())
|
||||
return false;
|
||||
// this sets a bit that is used to detect NTSC-J
|
||||
if (ContentLoader.GetRegion() == DiscIO::Region::NTSC_J)
|
||||
{
|
||||
VideoInterface::SetRegionReg('J');
|
||||
}
|
||||
// DOL
|
||||
const DiscIO::SNANDContent* pContent =
|
||||
ContentLoader.GetContentByIndex(ContentLoader.GetBootIndex());
|
||||
|
||||
Reference in new issue
Block a user