diff --git a/tools/cxbe/Main.cpp b/tools/cxbe/Main.cpp index c75bdbfa3..96afbcbdd 100644 --- a/tools/cxbe/Main.cpp +++ b/tools/cxbe/Main.cpp @@ -20,24 +20,31 @@ int main(int argc, char *argv[]) char szDumpFilename[OPTION_LEN + 1] = { 0 }; char szXbeTitle[OPTION_LEN + 1] = "Untitled"; char szXbeTitleID[OPTION_LEN + 1] = ""; + char szXbeRegions[OPTION_LEN + 1] = ""; char szMode[OPTION_LEN + 1] = "retail"; char szLogo[OPTION_LEN + 1] = ""; char szDebugPath[OPTION_LEN + 1] = ""; bool bRetail; uint32 dwTitleId = 0x4358270F; // CX-9999 + uint32 dwRegions; const char *program = argv[0]; const char *program_desc = "CXBE EXE to XBE (win32 to Xbox) Relinker (Version: " VERSION ")"; - Option options[] = { { szExeFilename, NULL, "exefile" }, - { szXbeFilename, "OUT", "filename" }, - { szDumpFilename, "DUMPINFO", "filename" }, - { szXbeTitle, "TITLE", "title" }, - { szXbeTitleID, "TITLEID", "{%c%c-%u|%x}" }, - { szMode, "MODE", "{debug|retail}" }, - { szLogo, "LOGO", "filename" }, - { szDebugPath, "DEBUGPATH", "path" }, - { NULL } }; + Option options[] = { + { szExeFilename, NULL, "exefile" }, + { szXbeFilename, "OUT", "filename" }, + { szDumpFilename, "DUMPINFO", "filename" }, + { szXbeTitle, "TITLE", "title" }, + { szXbeTitleID, "TITLEID", "{%c%c-%u|%x}" }, + { szXbeRegions, "REGION", + "{-|[n][j][w][m]|a}\n" + " -=none, n=North America, j=Japan, w=world, m=manufacturing, a=njwm" }, + { szMode, "MODE", "{debug|retail}" }, + { szLogo, "LOGO", "filename" }, + { szDebugPath, "DEBUGPATH", "path" }, + { NULL } + }; if(ParseOptions(argv, argc, options, szErrorMessage)) { @@ -90,6 +97,47 @@ int main(int argc, char *argv[]) } } + // interpret region flags + if(szXbeRegions[0]) + { + char c; + for(int i = 0; (c = szXbeRegions[i]); ++i) + { + switch(c) + { + case '-':; + dwRegions = 0; + goto breakfor; + case 'a':; + dwRegions = XBEIMAGE_GAME_REGION_NA | XBEIMAGE_GAME_REGION_JAPAN | + XBEIMAGE_GAME_REGION_RESTOFWORLD | + XBEIMAGE_GAME_REGION_MANUFACTURING; + goto breakfor; + case 'n':; + dwRegions |= XBEIMAGE_GAME_REGION_NA; + break; + case 'j':; + dwRegions |= XBEIMAGE_GAME_REGION_JAPAN; + break; + case 'w':; + dwRegions |= XBEIMAGE_GAME_REGION_RESTOFWORLD; + break; + case 'm':; + dwRegions |= XBEIMAGE_GAME_REGION_MANUFACTURING; + break; + default:; + printf("WARNING: Invalid region char: %c\n", c); + break; + } + } + breakfor:; + } + else + { + dwRegions = XBEIMAGE_GAME_REGION_NA | XBEIMAGE_GAME_REGION_JAPAN | + XBEIMAGE_GAME_REGION_RESTOFWORLD | XBEIMAGE_GAME_REGION_MANUFACTURING; + } + // verify we received the required parameters if(szExeFilename[0] == '\0') { @@ -126,7 +174,7 @@ int main(int argc, char *argv[]) LogoPtr = &logo; } - Xbe *XbeFile = new Xbe(ExeFile, szXbeTitle, dwTitleId, bRetail, LogoPtr, szDebugPath); + Xbe *XbeFile = new Xbe(ExeFile, szXbeTitle, dwTitleId, dwRegions, bRetail, LogoPtr, szDebugPath); if(XbeFile->GetError() != 0) { diff --git a/tools/cxbe/Xbe.cpp b/tools/cxbe/Xbe.cpp index 8fba92912..27fc86122 100644 --- a/tools/cxbe/Xbe.cpp +++ b/tools/cxbe/Xbe.cpp @@ -32,8 +32,8 @@ static size_t BasenameOffset(const std::string &path) } // construct via Exe file object -Xbe::Xbe(class Exe *x_Exe, const char *x_szTitle, uint32 x_dwTitleID, bool x_bRetail, - const std::vector *logo, const char *x_szDebugPath) +Xbe::Xbe(class Exe *x_Exe, const char *x_szTitle, uint32 x_dwTitleID, uint32 x_dwRegions, + bool x_bRetail, const std::vector *logo, const char *x_szDebugPath) { ConstructorInit(); @@ -304,10 +304,7 @@ Xbe::Xbe(class Exe *x_Exe, const char *x_szTitle, uint32 x_dwTitleID, bool x_bRe XBEIMAGE_MEDIA_TYPE_MEDIA_BOARD | XBEIMAGE_MEDIA_TYPE_NONSECURE_HARD_DISK | XBEIMAGE_MEDIA_TYPE_NONSECURE_MODE; - // TODO: allow configuration - m_Certificate.dwGameRegion = XBEIMAGE_GAME_REGION_MANUFACTURING | - XBEIMAGE_GAME_REGION_NA | XBEIMAGE_GAME_REGION_JAPAN | - XBEIMAGE_GAME_REGION_RESTOFWORLD; + m_Certificate.dwGameRegion = x_dwRegions; // TODO: allow configuration m_Certificate.dwGameRatings = 0xFFFFFFFF; diff --git a/tools/cxbe/Xbe.h b/tools/cxbe/Xbe.h index be8382c2d..e9915fbb7 100644 --- a/tools/cxbe/Xbe.h +++ b/tools/cxbe/Xbe.h @@ -26,8 +26,8 @@ class Xbe : public Error { public: // construct via Exe file object - Xbe(class Exe *x_Exe, const char *x_szTitle, uint32 x_dwTitleID, bool x_bRetail, - const std::vector *logo = nullptr, const char *x_szDebugPath = nullptr); + Xbe(class Exe *x_Exe, const char *x_szTitle, uint32 x_dwTitleID, uint32 x_dwRegions, + bool x_bRetail, const std::vector *logo = nullptr, const char *x_szDebugPath = nullptr); // deconstructor ~Xbe();