From ef7ac95153c9bfc769410a416789e05faa29d4d6 Mon Sep 17 00:00:00 2001 From: "crediar@rypp.net" Date: Thu, 28 Jun 2012 19:38:04 +0000 Subject: [PATCH] Patches: *Added a new method of video mode forcing (i.e. Luigi's Mansion EUR works in NTSC video mode) git-svn-id: svn://localhost/Users/andi/Downloads/code/trunk@13 be6c1b03-d731-4111-a574-e37d80d43941 --- Patches.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ Patches.h | 24 +++++++++++++++++++ dip.c | 13 ++++++++++ 3 files changed, 108 insertions(+) diff --git a/Patches.c b/Patches.c index a7eb918..d7a7042 100644 --- a/Patches.c +++ b/Patches.c @@ -76,6 +76,43 @@ u32 __GXSetVAT_patch[31] = { 0x4082ffa0, 0x38000000, 0x980904f2, 0x4e800020 }; +u8 GXMObjects[][0x3C] = +{ + { // GXPal528IntDf + 0x00, 0x00, 0x00, 0x04, 0x02, 0x80, 0x02, 0x10, 0x02, 0x10, 0x00, 0x28, 0x00, 0x17, 0x02, 0x80, + 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x08, 0x08, 0x0A, 0x0C, 0x0A, 0x08, 0x08, 0x00, 0x00, 0x00, + }, + + { // GXEurgb60Hz480IntDf + 0x00, 0x00, 0x00, 0x14, 0x02, 0x80, 0x01, 0xE0, 0x01, 0xE0, 0x00, 0x28, 0x00, 0x00, 0x02, 0x80, + 0x01, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x08, 0x08, 0x0A, 0x0C, 0x0A, 0x08, 0x08, 0x00, 0x00, 0x00, + }, + + { // GXMpal480IntDf + 0x00, 0x00, 0x00, 0x08, 0x02, 0x80, 0x01, 0xE0, 0x01, 0xE0, 0x00, 0x28, 0x00, 0x00, 0x02, 0x80, + 0x01, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x08, 0x08, 0x0A, 0x0C, 0x0A, 0x08, 0x08, 0x00, 0x00, 0x00, + }, + + { // GXNtsc480IntDf + 0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x01, 0xE0, 0x01, 0xE0, 0x00, 0x28, 0x00, 0x00, 0x02, 0x80, + 0x01, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x08, 0x08, 0x0A, 0x0C, 0x0A, 0x08, 0x08, 0x00, 0x00, 0x00, + }, + + { // GXNtsc480Int + 0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x01, 0xE0, 0x01, 0xE0, 0x00, 0x28, 0x00, 0x00, 0x02, 0x80, + 0x01, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x00, 0x00, 0x15, 0x16, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, + }, +}; FuncPattern FPatterns[] = { @@ -751,6 +788,40 @@ void DoPatches( char *ptr, u32 size, u32 SectionOffset ) if( PatchCount == 47 ) break; } + } + + if( ConfigGetVideMode() & DML_VID_FORCE ) + { + k=0; + for( i=0; i < size; i+=4 ) + { + for( j=0; j <= GXNtsc480Int; ++j ) + { + if( memcmp( ptr+i, GXMObjects[j], 0x3C ) == 0 ) + { + dbgprintf("Patch:Found GX pattern %u at %08X\n", j, ptr+i ); + switch( ConfigGetVideMode() & 15 ) + { + case DML_VID_FORCE_PAL50: + { + memcpy( ptr+i, GXMObjects[GXPal528IntDf], 0x3C ); + } break; + case DML_VID_FORCE_PAL60: + { + memcpy( ptr+i, GXMObjects[GXEurgb60Hz480IntDf], 0x3C ); + } break; + case DML_VID_FORCE_NTSC: + { + memcpy( ptr+i, GXMObjects[GXNtsc480IntDf], 0x3C ); + } break; + } + k++; + } + } + + if( k > 4 ) + break; + } } for( i=0; i < size; i+=4 ) diff --git a/Patches.h b/Patches.h index 4a306bb..fe64b2a 100644 --- a/Patches.h +++ b/Patches.h @@ -9,6 +9,7 @@ #include "vsprintf.h" #include "HW.h" #include "dol.h" +#include "Config.h" typedef struct PatchInfo @@ -43,6 +44,29 @@ typedef struct PatchCache u32 PatchID; } PatchCache; + +typedef struct _gx_rmodeobj { + u32 viTVMode; + u16 fbWidth; + u16 efbHeight; + u16 xfbHeight; + u16 viXOrigin; + u16 viYOrigin; + u16 viWidth; + u16 viHeight; + u32 xfbMode; + u8 field_rendering; + u8 aa; + u8 sample_pattern[12][2]; + u8 vfilter[7]; +} GXRModeObj; + +#define GXPal528IntDf 0 +#define GXEurgb60Hz480IntDf 1 +#define GXMpal480IntDf 2 +#define GXNtsc480IntDf 3 +#define GXNtsc480Int 4 + void PatchGCIPL( void ); void DoPatches( char *ptr, u32 size, u32 SectionOffset ); diff --git a/dip.c b/dip.c index a8df3d2..b35fa88 100644 --- a/dip.c +++ b/dip.c @@ -176,6 +176,19 @@ u32 DIUpdateRegisters( void ) if( DOLMaxOff < dol->addressText[i] + dol->sizeText[i] ) DOLMaxOff = dol->addressText[i] + dol->sizeText[i]; } + + for( i=0; i < 11; ++i ) + { + if( dol->addressData[i] == 0 ) + continue; + + if( DOLMinOff > dol->addressData[i]) + DOLMinOff = dol->addressData[i]; + + if( DOLMaxOff < dol->addressData[i] + dol->sizeData[i] ) + DOLMaxOff = dol->addressData[i] + dol->sizeData[i]; + } + DOLMinOff -= 0x80000000; DOLMaxOff -= 0x80000000;