Skip to content

Commit

Permalink
- Fix framebuffer initialization in LOADRDVD/STUBRDVD.ELF.
Browse files Browse the repository at this point in the history
- Fix patching STUBRDVD.elf in Medal of Honor: Rising Sun (Europe).
  • Loading branch information
Extrems committed Apr 28, 2021
1 parent d1609fe commit 644232c
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cube/swiss/source/gcm.c
Expand Up @@ -262,15 +262,15 @@ int parse_gcm(file_handle *file, ExecutableFile *filesToPatch) {
memcpy(&filesToPatch[numFiles].name,&filename[0],64);
numFiles++;
}
if(strstr(filename,"switcher.prs")) {
if(!strcasecmp(filename,"switcher.prs")) {
filesToPatch[numFiles].offset = file_offset;
filesToPatch[numFiles].size = size;
filesToPatch[numFiles].type = PATCH_DOL_PRS;
memcpy(&filesToPatch[numFiles].name,&filename[0],64);
numFiles++;
}
if(endsWith(filename,".elf")) {
if(!strstr(filename,"STUBRDVD.ELF")) {
if(strcasecmp(filename,"STUBRDVD.ELF")) {
if(dolSize == calc_elf_segments_size(file, file_offset, &size) + DOLHDRLENGTH) {
continue;
}
Expand All @@ -281,7 +281,7 @@ int parse_gcm(file_handle *file, ExecutableFile *filesToPatch) {
memcpy(&filesToPatch[numFiles].name,&filename[0],64);
numFiles++;
}
if(strstr(filename,"execD.img")) {
if(!strcasecmp(filename,"execD.img")) {
filesToPatch[numFiles].offset = file_offset;
filesToPatch[numFiles].size = size;
filesToPatch[numFiles].type = PATCH_BS2;
Expand Down Expand Up @@ -417,7 +417,7 @@ int parse_tgc(file_handle *file, ExecutableFile *filesToPatch, u32 tgc_base, cha
memcpy(&filesToPatch[numFiles].name,&filename[0],64);
numFiles++;
}
if(strstr(filename,"execD.img")) {
if(!strcasecmp(filename,"execD.img")) {
filesToPatch[numFiles].offset = file_offset;
filesToPatch[numFiles].size = size;
filesToPatch[numFiles].type = PATCH_BS2;
Expand Down Expand Up @@ -486,7 +486,7 @@ int patch_gcm(file_handle *file, ExecutableFile *filesToPatch, int numToPatch) {
}
print_gecko("Checking %s %iKb\r\n", filesToPatch[i].name, filesToPatch[i].size/1024);

if(strstr(filesToPatch[i].name, "iwanagaD.dol") || strstr(filesToPatch[i].name, "switcherD.dol")) {
if(!strcasecmp(filesToPatch[i].name, "iwanagaD.dol") || !strcasecmp(filesToPatch[i].name, "switcherD.dol")) {
continue; // skip unused PSO files
}
uiDrawObj_t* progBox = DrawPublish(DrawProgressBar(true, 0, txtbuffer));
Expand Down
102 changes: 102 additions & 0 deletions cube/swiss/source/patcher.c
Expand Up @@ -10262,6 +10262,23 @@ int Patch_GameSpecific(void *data, u32 length, const char *gameID, int dataType)
*(u32 *)(data + 0x8000563C - 0x800055E0 + 0x25E0) = 0x60000000;
*(u32 *)(data + 0x80005640 - 0x800055E0 + 0x25E0) = 0x38000000;

print_gecko("Patched:[%.6s]\n", gameID);
patched++;
break;
}
} else if (!strncmp(gameID, "GGIJ13", 6) && (dataType == PATCH_DOL || dataType == PATCH_ELF)) {
switch (length) {
case 205696:
// Fix framebuffer initialization.
*(u32 *)(data + 0x8001501C - 0x800134A0 + 0x4A0) = 0x807E0000;

print_gecko("Patched:[%.6s]\n", gameID);
patched++;
break;
case 266324:
// Fix framebuffer initialization.
*(u32 *)(data + 0x807023F0 - 0x807003A0 + 0x500) = 0x807E0000;

print_gecko("Patched:[%.6s]\n", gameID);
patched++;
break;
Expand All @@ -10276,6 +10293,57 @@ int Patch_GameSpecific(void *data, u32 length, const char *gameID, int dataType)
*(u32 *)(data + 0x80014598 - 0x800034A0 + 0x4A0) = 0x3D208000;
*(u32 *)(data + 0x8001459C - 0x800034A0 + 0x4A0) = 0x812900EC;

print_gecko("Patched:[%.6s]\n", gameID);
patched++;
break;
}
} else if ((!strncmp(gameID, "GOND69", 6) || !strncmp(gameID, "GONE69", 6) || !strncmp(gameID, "GONF69", 6) || !strncmp(gameID, "GONP69", 6)) && (dataType == PATCH_DOL || dataType == PATCH_ELF)) {
switch (length) {
case 277472:
// Fix framebuffer initialization.
*(u32 *)(data + 0x80014C54 - 0x800134A0 + 0x4A0) = 0x807E0000;

print_gecko("Patched:[%.6s]\n", gameID);
patched++;
break;
case 339500:
// Fix framebuffer initialization.
*(u32 *)(data + 0x80701C38 - 0x807003A0 + 0x500) = 0x807E0000;

print_gecko("Patched:[%.6s]\n", gameID);
patched++;
break;
}
} else if (!strncmp(gameID, "GONJ13", 6) && (dataType == PATCH_DOL || dataType == PATCH_ELF)) {
switch (length) {
case 276416:
// Fix framebuffer initialization.
*(u32 *)(data + 0x80014C54 - 0x800134A0 + 0x4A0) = 0x807E0000;

print_gecko("Patched:[%.6s]\n", gameID);
patched++;
break;
case 338376:
// Fix framebuffer initialization.
*(u32 *)(data + 0x80701C38 - 0x807003A0 + 0x500) = 0x807E0000;

print_gecko("Patched:[%.6s]\n", gameID);
patched++;
break;
}
} else if ((!strncmp(gameID, "GOYD69", 6) || !strncmp(gameID, "GOYE69", 6) || !strncmp(gameID, "GOYF69", 6) || !strncmp(gameID, "GOYP69", 6) || !strncmp(gameID, "GOYS69", 6)) && (dataType == PATCH_DOL || dataType == PATCH_ELF)) {
switch (length) {
case 207232:
// Fix framebuffer initialization.
*(u32 *)(data + 0x8001501C - 0x800134A0 + 0x4A0) = 0x807E0000;

print_gecko("Patched:[%.6s]\n", gameID);
patched++;
break;
case 268372:
// Fix framebuffer initialization.
*(u32 *)(data + 0x807023F0 - 0x807003A0 + 0x500) = 0x807E0000;

print_gecko("Patched:[%.6s]\n", gameID);
patched++;
break;
Expand Down Expand Up @@ -10525,6 +10593,40 @@ int Patch_GameSpecific(void *data, u32 length, const char *gameID, int dataType)

*(s16 *)(data + 0x80129362 - 0x800056C0 + 0x2600) = 0x181F;

print_gecko("Patched:[%.6s]\n", gameID);
patched++;
break;
}
} else if ((!strncmp(gameID, "GR8D69", 6) || !strncmp(gameID, "GR8E69", 6) || !strncmp(gameID, "GR8F69", 6) || !strncmp(gameID, "GR8P69", 6)) && (dataType == PATCH_DOL || dataType == PATCH_ELF)) {
switch (length) {
case 206016:
// Fix framebuffer initialization.
*(u32 *)(data + 0x80500EB4 - 0x805003A0 + 0x4A0) = 0x387D2720;

print_gecko("Patched:[%.6s]\n", gameID);
patched++;
break;
case 260164:
// Fix framebuffer initialization.
*(u32 *)(data + 0x80500EB4 - 0x805003A0 + 0x500) = 0x387D2720;

print_gecko("Patched:[%.6s]\n", gameID);
patched++;
break;
}
} else if (!strncmp(gameID, "GRZJ13", 6) && (dataType == PATCH_DOL || dataType == PATCH_ELF)) {
switch (length) {
case 206240:
// Fix framebuffer initialization.
*(u32 *)(data + 0x80500EB4 - 0x805003A0 + 0x4A0) = 0x387D2800;

print_gecko("Patched:[%.6s]\n", gameID);
patched++;
break;
case 260852:
// Fix framebuffer initialization.
*(u32 *)(data + 0x80500EB4 - 0x805003A0 + 0x500) = 0x387D2800;

print_gecko("Patched:[%.6s]\n", gameID);
patched++;
break;
Expand Down

0 comments on commit 644232c

Please sign in to comment.