Skip to content

Commit

Permalink
- Fix selecting switcher.prs as alternate executable.
Browse files Browse the repository at this point in the history
  • Loading branch information
Extrems committed Feb 5, 2024
1 parent e0da14b commit 139d63e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
7 changes: 3 additions & 4 deletions cube/swiss/source/gcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,15 +580,14 @@ int patch_gcm(ExecutableFile *filesToPatch, int numToPatch) {
goto fail;
}

u8 *oldBuffer = NULL, *newBuffer = NULL;
u8 *oldBuffer = buffer, *newBuffer = NULL;
if(fileToPatch->type == PATCH_DOL_PRS || fileToPatch->type == PATCH_OTHER_PRS) {
ret = pso_prs_decompress_buf(buffer, &newBuffer, fileToPatch->size);
int ret = pso_prs_decompress_buf(buffer, &newBuffer, fileToPatch->size);
if(ret < 0) {
message = "Failed to decompress file!";
goto fail;
}
sizeToRead = ret;
oldBuffer = buffer;
buffer = newBuffer;
}

Expand All @@ -603,7 +602,7 @@ int patch_gcm(ExecutableFile *filesToPatch, int numToPatch) {
}

if(fileToPatch->type == PATCH_DOL_PRS || fileToPatch->type == PATCH_OTHER_PRS) {
ret = pso_prs_compress2(buffer, oldBuffer, sizeToRead, fileToPatch->size);
int ret = pso_prs_compress2(buffer, oldBuffer, sizeToRead, fileToPatch->size);
if(ret < 0) {
message = "Failed to recompress file!";
free(oldBuffer);
Expand Down
17 changes: 16 additions & 1 deletion cube/swiss/source/swiss.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "gui/IPLFontWrite.h"
#include "devices/deviceHandler.h"
#include "devices/filemeta.h"
#include "psoarchive/PRS.h"
#include "xxhash/xxhash.h"
#include "dolparameters.h"
#include "reservedarea.h"
Expand Down Expand Up @@ -1110,6 +1111,20 @@ void load_app(ExecutableFile *fileToPatch)
}
gameID_set(&GCMDisk, fileToPatch->hash);
}

u8 *oldBuffer = buffer, *newBuffer = NULL;
if(type == PATCH_DOL_PRS || type == PATCH_OTHER_PRS) {
int ret = pso_prs_decompress_buf(buffer, &newBuffer, fileToPatch->size);
if(ret < 0) {
message = "Failed to decompress DOL!";
goto fail;
}
sizeToRead = ret;
buffer = newBuffer;
newBuffer = NULL;
free(oldBuffer);
oldBuffer = NULL;
}
}
else {
if(devices[DEVICE_PATCHES] && devices[DEVICE_PATCHES] != devices[DEVICE_CUR]) {
Expand Down Expand Up @@ -1199,7 +1214,7 @@ void load_app(ExecutableFile *fileToPatch)
else if(type == PATCH_BIN) {
BINtoARAM(buffer, sizeToRead, 0x80003100, 0x80003100);
}
else if(type == PATCH_DOL) {
else if(type == PATCH_DOL || type == PATCH_DOL_PRS) {
DOLtoARAM(buffer, NULL, 0);
}
else if(type == PATCH_ELF) {
Expand Down

0 comments on commit 139d63e

Please sign in to comment.