From f85266df20bf81777a422dcd71d725f8cf712cd9 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Fri, 23 Dec 2016 21:53:36 +0100 Subject: [PATCH] SConfig: Replace bNTSC with m_region This lets us get rid of VideoInterface::SetRegionReg, a huge hack in CEXIMemoryCard, and some minor things. --- Source/Core/Core/Boot/Boot.cpp | 23 +++--- Source/Core/Core/Boot/Boot.h | 7 +- Source/Core/Core/Boot/Boot_BS2Emu.cpp | 45 +++++------ Source/Core/Core/Boot/Boot_WiiWAD.cpp | 7 +- Source/Core/Core/BootManager.cpp | 18 +++-- Source/Core/Core/ConfigManager.cpp | 29 ++++--- Source/Core/Core/ConfigManager.h | 5 +- Source/Core/Core/HW/EXI_DeviceIPL.cpp | 5 +- Source/Core/Core/HW/EXI_DeviceMemoryCard.cpp | 79 +++----------------- Source/Core/Core/HW/VideoInterface.cpp | 16 ++-- Source/Core/Core/HW/VideoInterface.h | 1 - Source/Core/DiscIO/Enums.cpp | 5 ++ Source/Core/DiscIO/Enums.h | 1 + 13 files changed, 90 insertions(+), 151 deletions(-) diff --git a/Source/Core/Core/Boot/Boot.cpp b/Source/Core/Core/Boot/Boot.cpp index 7979038790..a85b62fc34 100644 --- a/Source/Core/Core/Boot/Boot.cpp +++ b/Source/Core/Core/Boot/Boot.cpp @@ -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 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); diff --git a/Source/Core/Core/Boot/Boot.h b/Source/Core/Core/Boot/Boot.h index aa952d1199..0388e07f11 100644 --- a/Source/Core/Core/Boot/Boot.h +++ b/Source/Core/Core/Boot/Boot.h @@ -7,11 +7,6 @@ #include #include -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(); }; diff --git a/Source/Core/Core/Boot/Boot_BS2Emu.cpp b/Source/Core/Core/Boot/Boot_BS2Emu.cpp index 5b44b297b4..8906792328 100644 --- a/Source/Core/Core/Boot/Boot_BS2Emu.cpp +++ b/Source/Core/Core/Boot/Boot_BS2Emu.cpp @@ -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 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 diff --git a/Source/Core/Core/Boot/Boot_WiiWAD.cpp b/Source/Core/Core/Boot/Boot_WiiWAD.cpp index f7cc276f48..f94780024b 100644 --- a/Source/Core/Core/Boot/Boot_WiiWAD.cpp +++ b/Source/Core/Core/Boot/Boot_WiiWAD.cpp @@ -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()); diff --git a/Source/Core/Core/BootManager.cpp b/Source/Core/Core/BootManager.cpp index 16b4e03d16..04b6e07f01 100644 --- a/Source/Core/Core/BootManager.cpp +++ b/Source/Core/Core/BootManager.cpp @@ -28,6 +28,7 @@ #include "Common/IniFile.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" + #include "Core/BootManager.h" #include "Core/ConfigManager.h" #include "Core/Core.h" @@ -38,6 +39,9 @@ #include "Core/Host.h" #include "Core/Movie.h" #include "Core/NetPlayProto.h" + +#include "DiscIO/Enums.h" + #include "VideoCommon/VideoBackendBase.h" namespace BootManager @@ -349,17 +353,19 @@ bool BootCore(const std::string& _rFilename) g_SRAM_netplay_initialized = false; } + const bool ntsc = DiscIO::IsNTSC(StartUp.m_region); + // Apply overrides - // Some NTSC GameCube games such as Baten Kaitos react strangely to language settings that would - // be invalid on an NTSC system - if (!StartUp.bOverrideGCLanguage && StartUp.bNTSC) + // Some NTSC GameCube games such as Baten Kaitos react strangely to + // language settings that would be invalid on an NTSC system + if (!StartUp.bOverrideGCLanguage && ntsc) { StartUp.SelectedLanguage = 0; } - // Some NTSC Wii games such as Doc Louis's Punch-Out!! and 1942 (Virtual Console) crash if the - // PAL60 option is enabled - if (StartUp.bWii && StartUp.bNTSC) + // Some NTSC Wii games such as Doc Louis's Punch-Out!! and + // 1942 (Virtual Console) crash if the PAL60 option is enabled + if (StartUp.bWii && ntsc) { StartUp.bPAL60 = false; } diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 9b1545d123..0f56685c38 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -794,7 +794,7 @@ void SConfig::LoadDefaults() m_revision = 0; } -static const char* GetDirectoryForRegion(DiscIO::Region region) +const char* SConfig::GetDirectoryForRegion(DiscIO::Region region) { switch (region) { @@ -867,19 +867,18 @@ bool SConfig::AutoSetup(EBootBS2 _BootBS2) // Check if we have a Wii disc bWii = pVolume->GetVolumeType() == DiscIO::Platform::WII_DISC; - DiscIO::Region region = pVolume->GetRegion(); - const char* retrieved_region_dir = GetDirectoryForRegion(region); + m_region = pVolume->GetRegion(); + const char* retrieved_region_dir = GetDirectoryForRegion(m_region); if (!retrieved_region_dir) { if (!PanicYesNoT("Your GCM/ISO file seems to be invalid (invalid country)." "\nContinue with PAL region?")) return false; - region = DiscIO::Region::PAL; + m_region = DiscIO::Region::PAL; retrieved_region_dir = EUR_DIR; } set_region_dir = retrieved_region_dir; - bNTSC = region != DiscIO::Region::PAL; } else if (!strcasecmp(Extension.c_str(), ".elf")) { @@ -889,8 +888,8 @@ bool SConfig::AutoSetup(EBootBS2 _BootBS2) // all GC homebrew to 50Hz. // In the future, it probably makes sense to add a Region setting for homebrew somewhere in // the emulator config. - bNTSC = bWii ? false : true; - set_region_dir = bNTSC ? USA_DIR : EUR_DIR; + m_region = bWii ? DiscIO::Region::PAL : DiscIO::Region::NTSC_U; + set_region_dir = bWii ? EUR_DIR : USA_DIR; m_BootType = BOOT_ELF; } else if (!strcasecmp(Extension.c_str(), ".dol")) @@ -898,15 +897,15 @@ bool SConfig::AutoSetup(EBootBS2 _BootBS2) CDolLoader dolfile(m_strFilename); bWii = dolfile.IsWii(); // TODO: See the ELF code above. - bNTSC = bWii ? false : true; - set_region_dir = bNTSC ? USA_DIR : EUR_DIR; + m_region = bWii ? DiscIO::Region::PAL : DiscIO::Region::NTSC_U; + set_region_dir = bWii ? EUR_DIR : USA_DIR; m_BootType = BOOT_DOL; } else if (!strcasecmp(Extension.c_str(), ".dff")) { bWii = true; + m_region = DiscIO::Region::NTSC_U; set_region_dir = USA_DIR; - bNTSC = true; m_BootType = BOOT_DFF; std::unique_ptr ddfFile(FifoDataFile::Load(m_strFilename, true)); @@ -931,9 +930,9 @@ bool SConfig::AutoSetup(EBootBS2 _BootBS2) return false; // do not boot } - const char* retrieved_region_dir = GetDirectoryForRegion(ContentLoader.GetRegion()); + m_region = ContentLoader.GetRegion(); + const char* retrieved_region_dir = GetDirectoryForRegion(m_region); set_region_dir = retrieved_region_dir ? retrieved_region_dir : EUR_DIR; - bNTSC = set_region_dir == USA_DIR || set_region_dir == JAP_DIR; bWii = true; m_BootType = BOOT_WII_NAND; @@ -974,21 +973,21 @@ bool SConfig::AutoSetup(EBootBS2 _BootBS2) break; case BOOT_BS2_USA: + m_region = DiscIO::Region::NTSC_U; set_region_dir = USA_DIR; m_strFilename.clear(); - bNTSC = true; break; case BOOT_BS2_JAP: + m_region = DiscIO::Region::NTSC_J; set_region_dir = JAP_DIR; m_strFilename.clear(); - bNTSC = true; break; case BOOT_BS2_EUR: + m_region = DiscIO::Region::PAL; set_region_dir = EUR_DIR; m_strFilename.clear(); - bNTSC = false; break; } diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index b3c8ce540a..265979eecb 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -16,6 +16,7 @@ namespace DiscIO { enum class Language; +enum class Region; } // DSP Backend Types @@ -92,7 +93,6 @@ struct SConfig : NonCopyable bool bDSPThread = false; bool bDSPHLE = true; bool bSyncGPUOnSkipIdleHack = true; - bool bNTSC = false; bool bForceNTSCJ = false; bool bHLE_BS2 = true; bool bEnableCheats = false; @@ -183,7 +183,9 @@ struct SConfig : NonCopyable BOOT_BS2, BOOT_DFF }; + EBootType m_BootType; + DiscIO::Region m_region; std::string m_strVideoBackend; std::string m_strGPUDeterminismMode; @@ -206,6 +208,7 @@ struct SConfig : NonCopyable std::string m_perfDir; void LoadDefaults(); + static const char* GetDirectoryForRegion(DiscIO::Region region); bool AutoSetup(EBootBS2 _BootBS2); const std::string& GetGameID() const { return m_strGameID; } void CheckMemcardPath(std::string& memcardPath, const std::string& gameRegion, bool isSlotA); diff --git a/Source/Core/Core/HW/EXI_DeviceIPL.cpp b/Source/Core/Core/HW/EXI_DeviceIPL.cpp index 9f9befb41a..ae89d42158 100644 --- a/Source/Core/Core/HW/EXI_DeviceIPL.cpp +++ b/Source/Core/Core/HW/EXI_DeviceIPL.cpp @@ -13,6 +13,7 @@ #include "Common/MemoryUtil.h" #include "Common/StringUtil.h" #include "Common/Timer.h" + #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/CoreTiming.h" @@ -22,6 +23,8 @@ #include "Core/Movie.h" #include "Core/NetPlayProto.h" +#include "DiscIO/Enums.h" + // We should provide an option to choose from the above, or figure out the checksum (the algo in // yagcd seems wrong) // so that people can change default language. @@ -89,7 +92,7 @@ void CEXIIPL::Descrambler(u8* data, u32 size) CEXIIPL::CEXIIPL() : m_uPosition(0), m_uAddress(0), m_uRWOffset(0), m_FontsLoaded(false) { // Determine region - m_bNTSC = SConfig::GetInstance().bNTSC; + m_bNTSC = DiscIO::IsNTSC(SConfig::GetInstance().m_region); // Create the IPL m_pIPL = static_cast(Common::AllocateMemoryPages(ROM_SIZE)); diff --git a/Source/Core/Core/HW/EXI_DeviceMemoryCard.cpp b/Source/Core/Core/HW/EXI_DeviceMemoryCard.cpp index 47d9efeb18..2a4286f440 100644 --- a/Source/Core/Core/HW/EXI_DeviceMemoryCard.cpp +++ b/Source/Core/Core/HW/EXI_DeviceMemoryCard.cpp @@ -152,76 +152,18 @@ CEXIMemoryCard::CEXIMemoryCard(const int index, bool gciFolder) : card_index(ind void CEXIMemoryCard::SetupGciFolder(u16 sizeMb) { - DiscIO::Region region = DiscIO::Region::UNKNOWN_REGION; + DiscIO::Region region = SConfig::GetInstance().m_region; + std::string game_id = SConfig::GetInstance().m_strGameID; - u32 CurrentGameId = 0; - if (game_id == TITLEID_SYSMENU_STRING) - { - const DiscIO::CNANDContentLoader& SysMenu_Loader = - DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU, - Common::FROM_SESSION_ROOT); - if (SysMenu_Loader.IsValid()) - { - region = DiscIO::RegionSwitchGC(SysMenu_Loader.GetCountryChar()); - } - } - else if (game_id.length() >= 4) - { - region = DiscIO::RegionSwitchGC(game_id.at(3)); + if (game_id.length() >= 4 && game_id != "00000000" && game_id != TITLEID_SYSMENU_STRING) CurrentGameId = BE32((u8*)game_id.c_str()); - } - bool shift_jis = false; - std::string strDirectoryName = File::GetUserPath(D_GCUSER_IDX); - switch (region) - { - case DiscIO::Region::NTSC_J: - shift_jis = true; - strDirectoryName += JAP_DIR DIR_SEP; - break; - case DiscIO::Region::NTSC_U: - strDirectoryName += USA_DIR DIR_SEP; - break; - case DiscIO::Region::PAL: - strDirectoryName += EUR_DIR DIR_SEP; - default: - { - // The current game's region is not passed down to the EXI device level. - // Usually, we can retrieve the region from SConfig::GetInstance().m_strUniqueId. - // The Wii System Menu requires a lookup based on the version number. - // This is not possible in some cases ( e.g. FIFO logs, homebrew elf/dol files). - // Instead, we then lookup the region from the memory card name - // Earlier in the boot process the region is added to the memory card name (This is done by the - // function checkMemcardPath) - // For now take advantage of this. - // Future options: - // Set memory card directory path in the checkMemcardPath function. - // or Add region to SConfig::GetInstance(). - // or Pass region down to the EXI device creation. - std::string memcardFilename = (card_index == 0) ? SConfig::GetInstance().m_strMemoryCardA : - SConfig::GetInstance().m_strMemoryCardB; - std::string region_string = memcardFilename.substr(memcardFilename.size() - 7, 3); - if (region_string == JAP_DIR) - { - region = DiscIO::Region::NTSC_J; - shift_jis = true; - strDirectoryName += JAP_DIR DIR_SEP; - } - else if (region_string == USA_DIR) - { - region = DiscIO::Region::NTSC_U; - strDirectoryName += USA_DIR DIR_SEP; - } - else - { - region = DiscIO::Region::PAL; - strDirectoryName += EUR_DIR DIR_SEP; - } - break; - } - } - strDirectoryName += StringFromFormat("Card %c", 'A' + card_index); + const bool shift_jis = region == DiscIO::Region::NTSC_J; + + std::string strDirectoryName = File::GetUserPath(D_GCUSER_IDX) + + SConfig::GetDirectoryForRegion(region) + DIR_SEP + + StringFromFormat("Card %c", 'A' + card_index); if (!File::Exists(strDirectoryName)) // first use of memcard folder, migrate automatically { @@ -237,9 +179,8 @@ void CEXIMemoryCard::SetupGciFolder(u16 sizeMb) else // we tried but the user wants to crash { // TODO more user friendly abort - PanicAlertT("%s is not a directory, failed to move to *.original.\n Verify your write " - "permissions or move " - "the file outside of Dolphin", + PanicAlertT("%s is not a directory, failed to move to *.original.\n Verify your " + "write permissions or move the file outside of Dolphin", strDirectoryName.c_str()); exit(0); } diff --git a/Source/Core/Core/HW/VideoInterface.cpp b/Source/Core/Core/HW/VideoInterface.cpp index 186ea42d69..9b87eaf8c1 100644 --- a/Source/Core/Core/HW/VideoInterface.cpp +++ b/Source/Core/Core/HW/VideoInterface.cpp @@ -8,6 +8,7 @@ #include "Common/CommonTypes.h" #include "Common/Logging/Log.h" #include "Common/MathUtil.h" + #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/CoreTiming.h" @@ -16,6 +17,9 @@ #include "Core/HW/SI.h" #include "Core/HW/SystemTimers.h" #include "Core/HW/VideoInterface.h" + +#include "DiscIO/Enums.h" + #include "VideoCommon/VideoBackendBase.h" #include "VideoCommon/VideoConfig.h" @@ -167,12 +171,14 @@ void Preset(bool _bNTSC) m_FilterCoefTables = {}; m_UnkAARegister = 0; + DiscIO::Region region = SConfig::GetInstance().m_region; + // 54MHz, capable of progressive scan - m_Clock = SConfig::GetInstance().bNTSC; + m_Clock = DiscIO::IsNTSC(region); // Say component cable is plugged m_DTVStatus.component_plugged = SConfig::GetInstance().bProgressive; - m_DTVStatus.ntsc_j = SConfig::GetInstance().bForceNTSCJ; + m_DTVStatus.ntsc_j = SConfig::GetInstance().bForceNTSCJ || region == DiscIO::Region::NTSC_J; m_FBWidth.Hex = 0; m_BorderHBlank.Hex = 0; @@ -408,12 +414,6 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base) } } -void SetRegionReg(char region) -{ - if (!SConfig::GetInstance().bForceNTSCJ) - m_DTVStatus.ntsc_j = region == 'J'; -} - void UpdateInterrupts() { if ((m_InterruptRegister[0].IR_INT && m_InterruptRegister[0].IR_MASK) || diff --git a/Source/Core/Core/HW/VideoInterface.h b/Source/Core/Core/HW/VideoInterface.h index 6e444ee034..bdee2c7927 100644 --- a/Source/Core/Core/HW/VideoInterface.h +++ b/Source/Core/Core/HW/VideoInterface.h @@ -327,7 +327,6 @@ union UVIHorizontalStepping { void Preset(bool _bNTSC); void Init(); -void SetRegionReg(char region); void DoState(PointerWrap& p); void RegisterMMIO(MMIO::Mapping* mmio, u32 base); diff --git a/Source/Core/DiscIO/Enums.cpp b/Source/Core/DiscIO/Enums.cpp index 6689470f32..c107d68c2d 100644 --- a/Source/Core/DiscIO/Enums.cpp +++ b/Source/Core/DiscIO/Enums.cpp @@ -11,6 +11,11 @@ namespace DiscIO { +bool IsNTSC(Region region) +{ + return region == Region::NTSC_J || region == Region::NTSC_U || region == Region::NTSC_K; +} + // Increment CACHE_REVISION (ISOFile.cpp & GameFile.cpp) if the code below is modified Region RegionSwitchGC(u8 country_code) diff --git a/Source/Core/DiscIO/Enums.h b/Source/Core/DiscIO/Enums.h index 01f7ddb529..8e7ee5259b 100644 --- a/Source/Core/DiscIO/Enums.h +++ b/Source/Core/DiscIO/Enums.h @@ -66,6 +66,7 @@ enum class Language LANGUAGE_UNKNOWN }; +bool IsNTSC(Region region); Region RegionSwitchGC(u8 country_code); Region RegionSwitchWii(u8 country_code); Country CountrySwitch(u8 country_code);