Improve detection for region free app.

This commit is contained in:
Maschell 2021-10-16 14:10:39 +02:00
parent e90ce0ef0d
commit 2945ca6be1
2 changed files with 47 additions and 29 deletions

View File

@ -274,8 +274,6 @@ void ConfigUtils::displayMenu() {
// draw buttons // draw buttons
uint32_t index = 8 + 24 + 8 + 4; uint32_t index = 8 + 24 + 8 + 4;
DEBUG_FUNCTION_LINE("%d", selectedBtn);
DrawUtils::setFontColor(COLOR_TEXT); DrawUtils::setFontColor(COLOR_TEXT);
DrawUtils::setFontSize(24); DrawUtils::setFontSize(24);

View File

@ -104,6 +104,24 @@ DECL_FUNCTION(int32_t, ACPGetTitleMetaXmlByDevice, uint32_t titleid_upper, uint3
} }
ON_FUNCTIONS_PATCHED() { ON_FUNCTIONS_PATCHED() {
MCPRegion real_product_area;
auto real_product_area_valid = getRealProductArea(&real_product_area);
if(real_product_area_valid){
if(real_product_area == MCP_REGION_EUROPE){
gDefaultProductArea = MCP_REGION_EUROPE;
gDefaultLanguage = gDefaultLangForEUR;
gDefaultCountry = gDefaultCountryForEUR;
} else if(real_product_area == MCP_REGION_JAPAN){
gDefaultProductArea = MCP_REGION_JAPAN;
gDefaultLanguage = gDefaultLangForJPN;
gDefaultCountry = gDefaultCountryForJPN;
}if(real_product_area == MCP_REGION_USA){
gDefaultProductArea = MCP_REGION_USA;
gDefaultLanguage = gDefaultLangForUSA;
gDefaultCountry = gDefaultCountryForUSA;
}
}
bool forceConfigMenu = false; bool forceConfigMenu = false;
auto *acpMetaXml = (ACPMetaXml *) memalign(0x40, 0x4000); auto *acpMetaXml = (ACPMetaXml *) memalign(0x40, 0x4000);
@ -114,6 +132,9 @@ ON_FUNCTIONS_PATCHED() {
auto res = real_ACPGetLaunchMetaXml(acpMetaXml); auto res = real_ACPGetLaunchMetaXml(acpMetaXml);
if (res >= 0) { if (res >= 0) {
regionFromXML = acpMetaXml->region; regionFromXML = acpMetaXml->region;
if (real_product_area_valid && (regionFromXML & real_product_area) == real_product_area) {
gCurrentProductArea = real_product_area;
} else {
if (OSGetTitleID() == 0x0005001010040000L || acpMetaXml->region == 1) { if (OSGetTitleID() == 0x0005001010040000L || acpMetaXml->region == 1) {
DEBUG_FUNCTION_LINE("Set default to JAPAN"); DEBUG_FUNCTION_LINE("Set default to JAPAN");
gDefaultProductArea = MCP_REGION_JAPAN; gDefaultProductArea = MCP_REGION_JAPAN;
@ -130,9 +151,10 @@ ON_FUNCTIONS_PATCHED() {
gDefaultLanguage = gDefaultLangForEUR; gDefaultLanguage = gDefaultLangForEUR;
gDefaultCountry = gDefaultCountryForEUR; gDefaultCountry = gDefaultCountryForEUR;
} else { } else {
DEBUG_FUNCTION_LINE("Unknown area %d, forcing language will be disabled", acpMetaXml->region); DEBUG_FUNCTION_LINE("Unknown area %08X, forcing language will be disabled", acpMetaXml->region);
forceConfigMenu = true; forceConfigMenu = true;
} }
}
} else { } else {
forceConfigMenu = true; forceConfigMenu = true;
} }
@ -147,14 +169,12 @@ ON_FUNCTIONS_PATCHED() {
gCurrentCountry = gDefaultCountry; gCurrentCountry = gDefaultCountry;
gCurrentProductArea = gDefaultProductArea; gCurrentProductArea = gDefaultProductArea;
MCPRegion real_product_area; if (gPreferSystemSettings && real_product_area_valid) {
if(gPreferSystemSettings && getRealProductArea(&real_product_area)){
if ((regionFromXML & real_product_area) == real_product_area) { if ((regionFromXML & real_product_area) == real_product_area) {
gCurrentProductArea = real_product_area; gCurrentProductArea = real_product_area;
auto ucHandle = UCOpen(); auto ucHandle = UCOpen();
if (ucHandle >= 0) { if (ucHandle >= 0) {
DEBUG_FUNCTION_LINE("Got UCHandle %08X0", ucHandle);
UCSysConfig sysConfig; UCSysConfig sysConfig;
memset((void *) &sysConfig, 0, sizeof(sysConfig)); memset((void *) &sysConfig, 0, sizeof(sysConfig));
uint32_t data = 0xFFFFFFFF; uint32_t data = 0xFFFFFFFF;