Skip to content

Commit

Permalink
- WIP port MajoraAudioStream from nintendont
Browse files Browse the repository at this point in the history
- Reworked patch copy system so that VIConfigure patches are copied once and referenced many times
- Removed old dvd patches
  • Loading branch information
emukidid committed Oct 2, 2016
1 parent 8d8c779 commit c1e5c91
Show file tree
Hide file tree
Showing 13 changed files with 415 additions and 235 deletions.
2 changes: 1 addition & 1 deletion cube/swiss/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ SOURCES := source \
source/cheats \
source/patches \
source/patches/card \
source/patches/dvd \
source/patches/misc \
source/patches/gx \
source/patches/mtx \
source/patches/vi \
Expand Down
46 changes: 35 additions & 11 deletions cube/swiss/include/patcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ extern u8 dvd_bin[];
extern u32 dvd_bin_size;

/* SDK patches */
extern u8 DVDCancelAsync[];
extern u32 DVDCancelAsync_length;
extern u8 DVDCancel[];
extern u32 DVDCancel_length;
extern u8 DVDGetDriveStatus[];
extern u32 DVDGetDriveStatus_length;
extern u8 DVDGetCommandBlockStatus[];
extern u32 DVDGetCommandBlockStatus_length;
extern u8 DVDCompareDiskId[];
extern u32 DVDCompareDiskId_length;
extern u8 GXGetYScaleFactorHook[];
extern u32 GXGetYScaleFactorHook_length;
extern u8 GXInitTexObjLODHook[];
Expand Down Expand Up @@ -80,6 +70,39 @@ extern u8 VIConfigurePanHook[];
extern u32 VIConfigurePanHook_length;
extern u8 VIConfigurePanHookDs[];
extern u32 VIConfigurePanHookDs_length;
extern u8 MajoraSaveRegs[];
extern u32 MajoraSaveRegs_length;
extern u8 MajoraAudioStream[];
extern u32 MajoraAudioStream_length;
extern u8 MajoraLoadRegs[];
extern u32 MajoraLoadRegs_length;

enum patchIds {
GX_GETYSCALEFACTORHOOK = 0,
GX_INITTEXOBJLODHOOK,
GX_SETPROJECTIONHOOK,
GX_SETSCISSORHOOK,
MTX_FRUSTUMHOOK,
MTX_LIGHTFRUSTUMHOOK,
MTX_LIGHTPERSPECTIVEHOOK,
MTX_ORTHOHOOK,
MTX_PERSPECTIVEHOOK,
SETFBBREGSHOOK,
VI_CONFIGURE240P,
VI_CONFIGURE288P,
VI_CONFIGURE480I,
VI_CONFIGURE480P,
VI_CONFIGURE576I,
VI_CONFIGURE576P,
VI_CONFIGURE960I,
VI_CONFIGURE1152I,
VI_CONFIGUREPANHOOK,
VI_CONFIGUREPANHOOKDS,
MAJORA_SAVEREGS,
MAJORA_AUDIOSTREAM,
MAJORA_LOADREGS,
PATCHES_MAX
};

#define SWISS_MAGIC 0x53574953 /* "SWIS" */

Expand Down Expand Up @@ -121,7 +144,8 @@ int Patch_TexFilt(u8 *data, u32 length, int dataType);
int Patch_FontEnc(void *addr, u32 length);
int Patch_Fwrite(void *addr, u32 length);
int Patch_DVDReset(void *addr,u32 length);
void Patch_GameSpecific(void *addr, u32 length, const char* gameID);
int Patch_GameSpecific(void *addr, u32 length, const char* gameID, int dataType);
int PatchDetectLowMemUsage( u8 *dst, u32 Length, int dataType );
u32 Calc_ProperAddress(u8 *data, u32 type, u32 offsetFoundAt);
int Patch_CheatsHook(u8 *data, u32 length, u32 type);
int install_code();
Expand Down
13 changes: 10 additions & 3 deletions cube/swiss/source/gcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,13 @@ int patch_gcm(file_handle *file, ExecutableFile *filesToPatch, int numToPatch, i
if(strstr(filesToPatch[i].name, "iwanagaD.dol") || strstr(filesToPatch[i].name, "switcherD.dol")) {
continue; // skip unused PSO files
}
int sizeToRead = filesToPatch[i].size;
int sizeToRead = filesToPatch[i].size, ret = 0;
u8 *buffer = (u8*)memalign(32, sizeToRead);

deviceHandler_seekFile(file,filesToPatch[i].offset, DEVICE_HANDLER_SEEK_SET);
if(deviceHandler_readFile(file,buffer,sizeToRead)!= sizeToRead) {
ret = deviceHandler_readFile(file,buffer,sizeToRead);
print_gecko("Read from %08X Size %08X - Result: %08X\r\n", filesToPatch[i].offset, sizeToRead, ret);
if(ret != sizeToRead) {
DrawFrameStart();
DrawMessageBox(D_FAIL, "Failed to read!");
DrawFrameFinish();
Expand All @@ -364,7 +366,7 @@ int patch_gcm(file_handle *file, ExecutableFile *filesToPatch, int numToPatch, i
}

if(curDevice != DVD_DISC) {
u32 ret = Patch_DVDLowLevelRead(buffer, sizeToRead, filesToPatch[i].type);
ret = Patch_DVDLowLevelRead(buffer, sizeToRead, filesToPatch[i].type);
if(READ_PATCHED_ALL != ret) {
DrawFrameStart();
DrawMessageBox(D_FAIL, "Failed to find necessary functions for patching!");
Expand All @@ -374,6 +376,11 @@ int patch_gcm(file_handle *file, ExecutableFile *filesToPatch, int numToPatch, i
else
patched += 1;
}

// Patch specific game hacks
if(curDevice != DVD_DISC) {
patched += Patch_GameSpecific(buffer, sizeToRead, &gameID[0], filesToPatch[i].type);
}

if(swissSettings.debugUSB && usb_isgeckoalive(1) && !swissSettings.wiirdDebug) {
patched += Patch_Fwrite(buffer, sizeToRead);
Expand Down
Loading

0 comments on commit c1e5c91

Please sign in to comment.