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
uint32_t index = 8 + 24 + 8 + 4;
DEBUG_FUNCTION_LINE("%d", selectedBtn);
DrawUtils::setFontColor(COLOR_TEXT);
DrawUtils::setFontSize(24);

View File

@ -104,6 +104,24 @@ DECL_FUNCTION(int32_t, ACPGetTitleMetaXmlByDevice, uint32_t titleid_upper, uint3
}
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;
auto *acpMetaXml = (ACPMetaXml *) memalign(0x40, 0x4000);
@ -114,6 +132,9 @@ ON_FUNCTIONS_PATCHED() {
auto res = real_ACPGetLaunchMetaXml(acpMetaXml);
if (res >= 0) {
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) {
DEBUG_FUNCTION_LINE("Set default to JAPAN");
gDefaultProductArea = MCP_REGION_JAPAN;
@ -130,9 +151,10 @@ ON_FUNCTIONS_PATCHED() {
gDefaultLanguage = gDefaultLangForEUR;
gDefaultCountry = gDefaultCountryForEUR;
} 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;
}
}
} else {
forceConfigMenu = true;
}
@ -147,14 +169,12 @@ ON_FUNCTIONS_PATCHED() {
gCurrentCountry = gDefaultCountry;
gCurrentProductArea = gDefaultProductArea;
MCPRegion real_product_area;
if(gPreferSystemSettings && getRealProductArea(&real_product_area)){
if (gPreferSystemSettings && real_product_area_valid) {
if ((regionFromXML & real_product_area) == real_product_area) {
gCurrentProductArea = real_product_area;
auto ucHandle = UCOpen();
if (ucHandle >= 0) {
DEBUG_FUNCTION_LINE("Got UCHandle %08X0", ucHandle);
UCSysConfig sysConfig;
memset((void *) &sysConfig, 0, sizeof(sysConfig));
uint32_t data = 0xFFFFFFFF;