-
-
Save Pokechu22/736d46abb9ce7e5f94ed4fc9de98b946 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Updated (far after the fact) for 2019-09-20 #dolphin-emu conversation about me getting regions > 3 wrong | |
BS2State BS2StateMachine(void) { | |
switch (BS2State) { | |
// ... | |
case BS2 38 Wait game partition, check region: // 8137e4bc in 4.3U | |
bVar7 = BS2CacheDatHelper(); | |
if (bVar7 == false) break; | |
tmd_ptr = &tmd_8108c4a0; | |
DebugLog(s_TMD_ver_..._0x%02X_8164654a,(uint)tmd_8108c4a0.version); | |
DebugLog(s_CA_CRL_ver_..._0x%02X_81646565,(uint)tmd_ptr->ca_crl_version); | |
DebugLog(s_Signer_CRL_ver_..._0x%02X_81646580,(uint)tmd_ptr->signer_crl_version); | |
DebugLog(s_Req_sys_ver_..._0x%08X%08X_8164659b,*(undefined4 *)&tmd_ptr->system_version, | |
*(undefined4 *)&(tmd_ptr->system_version).day); | |
DebugLog(s_Title_ID_..._0x%08X%08X_816465ba,tmd_ptr->titleid1,tmd_ptr->titleid2); | |
titleid_81698a88.type = *(uint *)&tmd_ptr->system_version; | |
titleid_81698a88.code = *(uint *)&(tmd_ptr->system_version).day; | |
uVar11 = tmd_ptr->titleid2; | |
if ((*(uint *)&(tmd_ptr->system_version).day ^ 0x10 | *(uint *)&tmd_ptr->system_version ^ 1) == | |
0) { | |
DAT_81698a84 = uVar11; | |
DebugLog(s_This_must_be_a_backup_disk_816466ca); | |
BS2State = BS2 57 FatalError; | |
break; | |
} | |
DAT_81698a84 = uVar11; | |
memset(gameIDChars,0,4); | |
firstIDChar_ = uVar11 >> 0x18; | |
gameIDChars[3] = (char)uVar11; | |
gameIDChars[0] = (char)(uVar11 >> 0x18); | |
if (firstIDChar_ < 'R') { | |
if (firstIDChar_ != 'D') goto LAB_8137e5c4; | |
LAB_8137e5cc: | |
if (gameIDChars[3] == 'A') { | |
isRegionValid = true; | |
goto figuredOutRegionIDValidity; | |
} | |
GVar6 = LookupGameRegionID(); | |
gameRegionID = (GameRegionID)GVar6; | |
if (gameRegionID == INVALID_3) goto regionIDMismatch; | |
if ('\x02' < (char)gameRegionID) { | |
if (gameRegionID == CN) { // 8137e6e4 | |
if (gameIDChars[3] != 'C') goto regionIDMismatch; | |
/* China(!?) gets gameids ending in 'C' */ | |
isRegionValid = true; | |
} | |
else { | |
if (('\x04' < (char)gameRegionID) || (gameIDChars[3] != 'K')) goto regionIDMismatch; | |
/* Region 4, korea, needs 'K' */ | |
isRegionValid = true; | |
} | |
goto figuredOutRegionIDValidity; | |
} | |
if (gameRegionID == US) { | |
if ((byte)gameIDChars[3] < 0x58) { | |
if (gameIDChars[3] == 'E') { | |
regionOKForUS: | |
/* US gets 'E' and also 0x58/0x59/0x5a, | |
i.e. 'X'/'Y'/'Z' */ | |
isRegionValid = true; | |
goto figuredOutRegionIDValidity; | |
} | |
} | |
else { | |
if ((byte)gameIDChars[3] < 0x5b) goto regionOKForUS; | |
} | |
regionIDMismatch: | |
isRegionValid = false; | |
} | |
else { | |
if ((char)gameRegionID < '\x01') { | |
if ((-1 < (char)gameRegionID) && | |
((gameIDChars[3] == 'W' || (((byte)gameIDChars[3] < 0x57 && (gameIDChars[3] == 'J'))))) | |
) { | |
/* Region 0, japan, gets 'W' and 'J' */ | |
isRegionValid = true; | |
goto figuredOutRegionIDValidity; | |
} | |
goto regionIDMismatch; | |
} | |
if (false) goto regionIDMismatch; | |
switch(gameIDChars[3]) { | |
case 'D': | |
case 'F': | |
case 'H': | |
case 'I': | |
case 'P': | |
case 'R': | |
case 'S': | |
case 'U': | |
case 'V': | |
case 'X': | |
case 'Y': | |
case 'Z': | |
/* Region 2, europe, gets a bunch: | |
DFHIPRSUVXYZ */ | |
isRegionValid = true; | |
break; | |
case 'W': // 8137e698 | |
/* RLWW seems to have been shoehorned into europe, even though W is normally | |
invalid. | |
https://wiki.dolphin-emu.org/index.php?title=RLWW78 */ | |
firstIDChar_ = uVar11 >> 0x10 & 0xff; | |
uVar11 = uVar11 >> 8 & 0xff; | |
gameIDChars[1] = (char)firstIDChar_; | |
gameIDChars[2] = (char)uVar11; | |
if (((gameIDChars[0] != 'R') || (firstIDChar_ != 'L')) || (uVar11 != 'W')) | |
goto regionIDMismatch; | |
isRegionValid = true; | |
break; | |
default: | |
goto regionIDMismatch; | |
} | |
} | |
} | |
else { | |
if (firstIDChar_ < 'U') goto LAB_8137e5cc; | |
LAB_8137e5c4: | |
isRegionValid = true; | |
} | |
figuredOutRegionIDValidity: | |
if (!isRegionValid) { | |
regionOK = false; | |
BS2State = BS2 47 Close game partition; | |
break; | |
} | |
regionOK = true; | |
BS2State = BS2 39 Read apploader header from cache; // 8137e728 | |
// ... | |
} | |
return BS2State; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GameRegion_ARRAY_81687440[0].name[0] XREF[1,2]: LookupGameRegionID:8156ac78(R), | |
GameRegion_ARRAY_81687440[1].id LookupGameRegionID:8156ac58(*), | |
GameRegion_ARRAY_81687440 LookupGameRegionID:8156ac78(R) | |
81687440 00 4a 50 GameRegi | |
00 01 55 | |
53 00 02 | |
81687440 00 4a 50 00 GameRegion [0] XREF[1,1]: LookupGameRegionID:8156ac78(R), | |
LookupGameRegionID:8156ac58(*) | |
81687440 00 GameRegi JP id Japan XREF[1]: LookupGameRegionID:8156ac78(R) | |
81687441 4a 50 00 char[3] "JP" name XREF[1]: LookupGameRegionID:8156ac58(*) | |
81687444 01 55 53 00 GameRegion [1] XREF[1]: LookupGameRegionID:8156ac78(R) | |
81687444 01 GameRegi US id US XREF[1]: LookupGameRegionID:8156ac78(R) | |
81687445 55 53 00 char[3] "US" name | |
81687448 02 45 55 00 GameRegion [2] | |
81687448 02 GameRegi EU id Europe | |
81687449 45 55 00 char[3] "EU" name | |
8168744c 04 4b 52 00 GameRegion [3] | |
8168744c 04 GameRegi KO id Korea | |
8168744d 4b 52 00 char[3] "KR" name | |
81687450 05 43 4e 00 GameRegion [4] | |
81687450 05 GameRegi CN id China | |
81687451 43 4e 00 char[3] "CN" name | |
81687454 ff 00 00 00 GameRegion [5] | |
81687454 ff GameRegi END id END | |
81687455 00 00 00 char[3] "" name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment