From 32d3f3f69024835d375401222b9abfbd32db37a5 Mon Sep 17 00:00:00 2001 From: Ac_K Date: Thu, 19 Mar 2020 23:37:55 +0100 Subject: Implement GetRegionCode and add the RegionCode to settings (#999) This implement `GetRegionCode` accordingly to RE. I've added a setting in the GUI and a field in the Configuration file with a way to update the Configuration file if needed. --- Ryujinx.HLE/HOS/Services/Settings/ISettingsServer.cs | 18 ++++++++++++++++++ Ryujinx.HLE/HOS/SystemState/SystemRegion.cs | 16 ++++++++++++++++ Ryujinx.HLE/HOS/SystemState/SystemStateMgr.cs | 7 +++++++ 3 files changed, 41 insertions(+) create mode 100644 Ryujinx.HLE/HOS/SystemState/SystemRegion.cs (limited to 'Ryujinx.HLE/HOS') diff --git a/Ryujinx.HLE/HOS/Services/Settings/ISettingsServer.cs b/Ryujinx.HLE/HOS/Services/Settings/ISettingsServer.cs index 2d2512df..a8b10297 100644 --- a/Ryujinx.HLE/HOS/Services/Settings/ISettingsServer.cs +++ b/Ryujinx.HLE/HOS/Services/Settings/ISettingsServer.cs @@ -54,6 +54,24 @@ namespace Ryujinx.HLE.HOS.Services.Settings return ResultCode.Success; } + [Command(4)] + // GetRegionCode() -> u32 nn::settings::RegionCode + public ResultCode GetRegionCode(ServiceCtx context) + { + // NOTE: Service mount 0x8000000000000050 savedata and read the region code here. + + SystemRegion regionCode = (SystemRegion)context.Device.System.State.DesiredRegionCode; + + if (regionCode < SystemRegion.Min || regionCode > SystemRegion.Max) + { + regionCode = SystemRegion.USA; + } + + context.ResponseData.Write((uint)regionCode); + + return ResultCode.Success; + } + [Command(5)] // GetAvailableLanguageCodes2() -> (u32, buffer) public ResultCode GetAvailableLanguageCodes2(ServiceCtx context) diff --git a/Ryujinx.HLE/HOS/SystemState/SystemRegion.cs b/Ryujinx.HLE/HOS/SystemState/SystemRegion.cs new file mode 100644 index 00000000..9a07a4a8 --- /dev/null +++ b/Ryujinx.HLE/HOS/SystemState/SystemRegion.cs @@ -0,0 +1,16 @@ +namespace Ryujinx.HLE.HOS.SystemState +{ + public enum SystemRegion + { + Japan, + USA, + Europe, + Australia, + China, + Korea, + Taiwan, + + Min = Japan, + Max = Taiwan + } +} \ No newline at end of file diff --git a/Ryujinx.HLE/HOS/SystemState/SystemStateMgr.cs b/Ryujinx.HLE/HOS/SystemState/SystemStateMgr.cs index c2e6680d..b65d1030 100644 --- a/Ryujinx.HLE/HOS/SystemState/SystemStateMgr.cs +++ b/Ryujinx.HLE/HOS/SystemState/SystemStateMgr.cs @@ -37,6 +37,8 @@ namespace Ryujinx.HLE.HOS.SystemState internal long DesiredLanguageCode { get; private set; } + internal uint DesiredRegionCode { get; private set; } + public TitleLanguage DesiredTitleLanguage { get; private set; } internal string ActiveAudioOutput { get; private set; } @@ -79,6 +81,11 @@ namespace Ryujinx.HLE.HOS.SystemState } } + public void SetRegion(SystemRegion region) + { + DesiredRegionCode = (uint)region; + } + public void SetAudioOutputAsTv() { ActiveAudioOutput = AudioOutputs[0]; -- cgit v1.2.3