-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added various features #655
base: master
Are you sure you want to change the base?
Changes from 1 commit
bd30f4b
2f0deb5
c0a40d6
b62a0ae
fc892e7
25c32e4
e13a346
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,18 +19,26 @@ int main(int argc, char *argv[]) | |
char szXbeFilename[OPTION_LEN + 1] = { 0 }; | ||
char szDumpFilename[OPTION_LEN + 1] = { 0 }; | ||
char szXbeTitle[OPTION_LEN + 1] = "Untitled"; | ||
char szXbeTitleID[OPTION_LEN + 1] = ""; | ||
char szMode[OPTION_LEN + 1] = "retail"; | ||
char szLogo[OPTION_LEN + 1] = ""; | ||
char szDebugPath[OPTION_LEN + 1] = ""; | ||
|
||
bool bRetail; | ||
uint32 dwTitleId = 0xFFFF0002; | ||
|
||
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" }, | ||
{ szMode, "MODE", "{debug|retail}" }, { szLogo, "LOGO", "filename" }, | ||
{ szDebugPath, "DEBUGPATH", "path" }, { NULL } | ||
{ 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 } | ||
}; | ||
|
||
if(ParseOptions(argv, argc, options, szErrorMessage)) | ||
|
@@ -54,6 +62,40 @@ int main(int argc, char *argv[]) | |
szXbeTitle[40] = '\0'; | ||
} | ||
|
||
// interpret title id | ||
if(szXbeTitleID[0]) | ||
{ | ||
bool hex = true; | ||
for(int i = 0; szXbeTitleID[i]; ++i) | ||
{ | ||
if(szXbeTitleID[i] == '-') | ||
{ | ||
hex = false; | ||
break; | ||
} | ||
} | ||
if(hex) | ||
{ | ||
sscanf(szXbeTitleID, "%x", &dwTitleId); | ||
} | ||
else | ||
{ | ||
char titlechar[2]; | ||
unsigned titleno; | ||
Comment on lines
+93
to
+94
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using a not explicitly unsigned char can lead to incorrect results when shifting, better use the types defined in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will adding |
||
if (sscanf(szXbeTitleID, "%c%c-%u", &titlechar[0], &titlechar[1], &titleno) != 3) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line doesn't follow clang-format rules. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll see about doing a rebase and running clang-format on all the commits |
||
{ | ||
strncpy(szErrorMessage, "invalid TITLEID", ERROR_LEN); | ||
goto cleanup; | ||
} | ||
if(titleno > 0xFFFF) | ||
{ | ||
printf("WARNING: Title ID number too high (max is 65535)\n"); | ||
titleno = 0xFFFF; | ||
} | ||
dwTitleId = (titlechar[0] << 24) | (titlechar[1] << 16) | titleno; | ||
} | ||
} | ||
|
||
// verify we received the required parameters | ||
if(szExeFilename[0] == '\0') | ||
{ | ||
|
@@ -90,7 +132,7 @@ int main(int argc, char *argv[]) | |
LogoPtr = &logo; | ||
} | ||
|
||
Xbe *XbeFile = new Xbe(ExeFile, szXbeTitle, bRetail, LogoPtr, szDebugPath); | ||
Xbe *XbeFile = new Xbe(ExeFile, szXbeTitle, dwTitleId, bRetail, LogoPtr, szDebugPath); | ||
|
||
if(XbeFile->GetError() != 0) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, bool x_bRetail, const std::vector<uint08> *logo, | ||
const char *x_szDebugPath) | ||
Xbe::Xbe(class Exe *x_Exe, const char *x_szTitle, uint32 x_dwTitleID, bool x_bRetail, | ||
const std::vector<uint08> *logo, const char *x_szDebugPath) | ||
{ | ||
ConstructorInit(); | ||
|
||
|
@@ -279,8 +279,7 @@ Xbe::Xbe(class Exe *x_Exe, const char *x_szTitle, bool x_bRetail, const std::vec | |
|
||
m_Certificate.dwTimeDate = CurrentTime; | ||
|
||
// TODO: generate in the form CX-9999 | ||
m_Certificate.dwTitleId = 0xFFFF0002; | ||
m_Certificate.dwTitleId = x_dwTitleID; | ||
|
||
// title name | ||
memset(m_Certificate.wszTitleName, 0, sizeof(m_Certificate.wszTitleName)); | ||
|
@@ -305,10 +304,7 @@ Xbe::Xbe(class Exe *x_Exe, const char *x_szTitle, bool x_bRetail, const std::vec | |
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; | ||
Comment on lines
-300
to
+308
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change probably belongs to a different commit and breaks building this one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably |
||
|
||
// TODO: allow configuration | ||
m_Certificate.dwGameRatings = 0xFFFFFFFF; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the formatting change? This breaks the clang-format rules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was actually done by clang format I think
I remember just adding it to the end