mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-23 19:59:16 +01:00
Fix video mode patching
Bug reported @ https://gbatemp.net/posts/9015326
This commit is contained in:
parent
0a14c3a05c
commit
ea7987f0ae
@ -105,6 +105,8 @@ int main()
|
|||||||
u32 offset = 0;
|
u32 offset = 0;
|
||||||
Disc_FindPartition(&offset);
|
Disc_FindPartition(&offset);
|
||||||
WDVD_OpenPartition(offset, &GameIOS);
|
WDVD_OpenPartition(offset, &GameIOS);
|
||||||
|
if(normalCFG.vidMode == 5)
|
||||||
|
normalCFG.patchVidMode = 1; //progressive mode requires this
|
||||||
vmode = Disc_SelectVMode(normalCFG.vidMode, &vmode_reg);
|
vmode = Disc_SelectVMode(normalCFG.vidMode, &vmode_reg);
|
||||||
AppEntrypoint = Apploader_Run(normalCFG.vidMode, vmode, normalCFG.vipatch, normalCFG.countryString, normalCFG.patchVidMode, normalCFG.aspectRatio,
|
AppEntrypoint = Apploader_Run(normalCFG.vidMode, vmode, normalCFG.vipatch, normalCFG.countryString, normalCFG.patchVidMode, normalCFG.aspectRatio,
|
||||||
normalCFG.returnTo, normalCFG.patchregion, normalCFG.private_server, normalCFG.patchFix480p);
|
normalCFG.returnTo, normalCFG.patchregion, normalCFG.private_server, normalCFG.patchFix480p);
|
||||||
|
@ -6,8 +6,6 @@
|
|||||||
|
|
||||||
#define ARRAY_SIZE(a) (sizeof a / sizeof a[0])
|
#define ARRAY_SIZE(a) (sizeof a / sizeof a[0])
|
||||||
|
|
||||||
extern GXRModeObj TVNtsc480Int;
|
|
||||||
|
|
||||||
GXRModeObj TVPal528Prog =
|
GXRModeObj TVPal528Prog =
|
||||||
{
|
{
|
||||||
6, // viDisplayMode
|
6, // viDisplayMode
|
||||||
@ -78,7 +76,7 @@ GXRModeObj TVPal528ProgSoft =
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GXRModeObj TVPal528ProgUnknown =
|
GXRModeObj TVPal524ProgAa =
|
||||||
{
|
{
|
||||||
6, // viDisplayMode
|
6, // viDisplayMode
|
||||||
640, // fbWidth
|
640, // fbWidth
|
||||||
@ -113,86 +111,41 @@ GXRModeObj TVPal528ProgUnknown =
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GXRModeObj TVPal574IntDfScale =
|
static GXRModeObj* vmodes[] = {
|
||||||
{
|
&TVNtsc240Ds,
|
||||||
VI_TVMODE_PAL_INT, // viDisplayMode
|
&TVNtsc240DsAa,
|
||||||
640, // fbWidth
|
&TVNtsc240Int,
|
||||||
480, // efbHeight
|
&TVNtsc240IntAa,
|
||||||
574, // xfbHeight
|
|
||||||
(VI_MAX_WIDTH_PAL - 640)/2, // viXOrigin
|
|
||||||
(VI_MAX_HEIGHT_PAL - 574)/2, // viYOrigin
|
|
||||||
640, // viWidth
|
|
||||||
574, // viHeight
|
|
||||||
VI_XFBMODE_DF, // xFBmode
|
|
||||||
GX_FALSE, // field_rendering
|
|
||||||
GX_FALSE, // aa
|
|
||||||
|
|
||||||
// sample points arranged in increasing Y order
|
|
||||||
{
|
|
||||||
{6,6},{6,6},{6,6}, // pix 0, 3 sample points, 1/12 units, 4 bits each
|
|
||||||
{6,6},{6,6},{6,6}, // pix 1
|
|
||||||
{6,6},{6,6},{6,6}, // pix 2
|
|
||||||
{6,6},{6,6},{6,6} // pix 3
|
|
||||||
},
|
|
||||||
// vertical filter[7], 1/64 units, 6 bits each
|
|
||||||
{
|
|
||||||
8, // line n-1
|
|
||||||
8, // line n-1
|
|
||||||
10, // line n
|
|
||||||
12, // line n
|
|
||||||
10, // line n
|
|
||||||
8, // line n+1
|
|
||||||
8 // line n+1
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static const GXRModeObj *g_vidmodes[] = {
|
|
||||||
&TVNtsc480Int,
|
&TVNtsc480Int,
|
||||||
|
&TVNtsc480IntAa,
|
||||||
&TVNtsc480IntDf,
|
&TVNtsc480IntDf,
|
||||||
&TVNtsc480Prog,
|
&TVNtsc480Prog,
|
||||||
|
&TVNtsc480ProgSoft,
|
||||||
&TVPal528Int,
|
&TVNtsc480ProgAa,
|
||||||
|
&TVMpal480IntDf,
|
||||||
|
&TVPal264Ds,
|
||||||
|
&TVPal264DsAa,
|
||||||
|
&TVPal264Int,
|
||||||
|
&TVPal264IntAa,
|
||||||
|
&TVPal524ProgAa,
|
||||||
|
&TVPal524IntAa,
|
||||||
|
&TVPal528Int,
|
||||||
&TVPal528IntDf,
|
&TVPal528IntDf,
|
||||||
&TVPal528Prog,
|
&TVPal528Prog,
|
||||||
&TVPal528ProgSoft,
|
&TVPal528ProgSoft,
|
||||||
&TVPal528ProgUnknown,
|
&TVPal576IntDfScale,
|
||||||
|
&TVEurgb60Hz240Ds,
|
||||||
&TVMpal480IntDf,
|
&TVEurgb60Hz240DsAa,
|
||||||
&TVMpal480Prog,
|
&TVEurgb60Hz240Int,
|
||||||
|
&TVEurgb60Hz240IntAa,
|
||||||
&TVEurgb60Hz480Int,
|
&TVEurgb60Hz480Int,
|
||||||
&TVEurgb60Hz480IntDf,
|
&TVEurgb60Hz480IntDf,
|
||||||
&TVEurgb60Hz480Prog
|
&TVEurgb60Hz480IntAa,
|
||||||
|
&TVEurgb60Hz480Prog,
|
||||||
|
&TVEurgb60Hz480ProgSoft,
|
||||||
|
&TVEurgb60Hz480ProgAa
|
||||||
};
|
};
|
||||||
|
|
||||||
// Level :
|
|
||||||
// 0 : If same number of lines and same mode type (interlaced, progressive)
|
|
||||||
// 1 : If same mode type
|
|
||||||
// 2 : Always
|
|
||||||
static void applyVideoPatch(void *dst, u32 len, GXRModeObj *rmode, int level)
|
|
||||||
{
|
|
||||||
u32 i;
|
|
||||||
u32 *bufEnd = (u32 *)((u8 *)dst + (len - sizeof *rmode));
|
|
||||||
u32 *p = (u32 *)dst;
|
|
||||||
while (p <= bufEnd)
|
|
||||||
{
|
|
||||||
for (i = 0; i < ARRAY_SIZE(g_vidmodes); ++i)
|
|
||||||
if (memcmp(p, g_vidmodes[i], sizeof *rmode) == 0)
|
|
||||||
{
|
|
||||||
// Video mode description found, replace it
|
|
||||||
GXRModeObj *m = (GXRModeObj *)p;
|
|
||||||
if (level == 2
|
|
||||||
|| (((m->viTVMode & 3) == VI_PROGRESSIVE) == ((rmode->viTVMode & 3) == VI_PROGRESSIVE)
|
|
||||||
&& (level == 1 || m->viHeight == rmode->viHeight)))
|
|
||||||
memcpy(p, rmode, sizeof *rmode);
|
|
||||||
p = (u32 *)(m + 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (i == ARRAY_SIZE(g_vidmodes))
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool compare_videomodes(GXRModeObj* mode1, GXRModeObj* mode2)
|
static bool compare_videomodes(GXRModeObj* mode1, GXRModeObj* mode2)
|
||||||
{
|
{
|
||||||
return memcmp(mode1, mode2, sizeof *mode1) == 0; // padding seems to always be 0
|
return memcmp(mode1, mode2, sizeof *mode1) == 0; // padding seems to always be 0
|
||||||
@ -210,14 +163,15 @@ static GXRModeObj* PAL2NTSC[]={
|
|||||||
&TVPal264Int, &TVNtsc240Int,
|
&TVPal264Int, &TVNtsc240Int,
|
||||||
&TVPal264IntAa, &TVNtsc240IntAa,
|
&TVPal264IntAa, &TVNtsc240IntAa,
|
||||||
&TVPal524IntAa, &TVNtsc480IntAa,
|
&TVPal524IntAa, &TVNtsc480IntAa,
|
||||||
&TVPal528Int, &TVNtsc480IntAa,
|
&TVPal528Int, &TVNtsc480Int,
|
||||||
&TVPal528IntDf, &TVNtsc480IntDf,
|
&TVPal528IntDf, &TVNtsc480IntDf,
|
||||||
&TVPal574IntDfScale, &TVNtsc480IntDf,
|
&TVPal528Prog, &TVNtsc480Prog,
|
||||||
|
&TVPal576IntDfScale, &TVNtsc480IntDf,
|
||||||
&TVEurgb60Hz240Ds, &TVNtsc240Ds,
|
&TVEurgb60Hz240Ds, &TVNtsc240Ds,
|
||||||
&TVEurgb60Hz240DsAa, &TVNtsc240DsAa,
|
&TVEurgb60Hz240DsAa, &TVNtsc240DsAa,
|
||||||
&TVEurgb60Hz240Int, &TVNtsc240Int,
|
&TVEurgb60Hz240Int, &TVNtsc240Int,
|
||||||
&TVEurgb60Hz240IntAa, &TVNtsc240IntAa,
|
&TVEurgb60Hz240IntAa, &TVNtsc240IntAa,
|
||||||
&TVEurgb60Hz480Int, &TVNtsc480IntAa,
|
&TVEurgb60Hz480Int, &TVNtsc480Int,
|
||||||
&TVEurgb60Hz480IntDf, &TVNtsc480IntDf,
|
&TVEurgb60Hz480IntDf, &TVNtsc480IntDf,
|
||||||
&TVEurgb60Hz480IntAa, &TVNtsc480IntAa,
|
&TVEurgb60Hz480IntAa, &TVNtsc480IntAa,
|
||||||
&TVEurgb60Hz480Prog, &TVNtsc480Prog,
|
&TVEurgb60Hz480Prog, &TVNtsc480Prog,
|
||||||
@ -231,9 +185,10 @@ static GXRModeObj* NTSC2PAL[]={
|
|||||||
&TVNtsc240DsAa, &TVPal264DsAa,
|
&TVNtsc240DsAa, &TVPal264DsAa,
|
||||||
&TVNtsc240Int, &TVPal264Int,
|
&TVNtsc240Int, &TVPal264Int,
|
||||||
&TVNtsc240IntAa, &TVPal264IntAa,
|
&TVNtsc240IntAa, &TVPal264IntAa,
|
||||||
|
&TVNtsc480Int, &TVPal528Int,
|
||||||
&TVNtsc480IntDf, &TVPal528IntDf,
|
&TVNtsc480IntDf, &TVPal528IntDf,
|
||||||
&TVNtsc480IntAa, &TVPal524IntAa,
|
&TVNtsc480IntAa, &TVPal524IntAa,
|
||||||
&TVNtsc480Prog, &TVPal528IntDf,
|
&TVNtsc480Prog, &TVPal528Prog,
|
||||||
0,0
|
0,0
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -242,12 +197,49 @@ static GXRModeObj* NTSC2PAL60[]={
|
|||||||
&TVNtsc240DsAa, &TVEurgb60Hz240DsAa,
|
&TVNtsc240DsAa, &TVEurgb60Hz240DsAa,
|
||||||
&TVNtsc240Int, &TVEurgb60Hz240Int,
|
&TVNtsc240Int, &TVEurgb60Hz240Int,
|
||||||
&TVNtsc240IntAa, &TVEurgb60Hz240IntAa,
|
&TVNtsc240IntAa, &TVEurgb60Hz240IntAa,
|
||||||
|
&TVNtsc480Int, &TVEurgb60Hz480Int,
|
||||||
&TVNtsc480IntDf, &TVEurgb60Hz480IntDf,
|
&TVNtsc480IntDf, &TVEurgb60Hz480IntDf,
|
||||||
&TVNtsc480IntAa, &TVEurgb60Hz480IntAa,
|
&TVNtsc480IntAa, &TVEurgb60Hz480IntAa,
|
||||||
&TVNtsc480Prog, &TVEurgb60Hz480Prog,
|
&TVNtsc480Prog, &TVEurgb60Hz480Prog,
|
||||||
0,0
|
0,0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void applyVideoPatch(void *Address, u32 Size, GXRModeObj* rmode, bool patchAll)
|
||||||
|
{
|
||||||
|
u8 *Addr = (u8 *)Address;
|
||||||
|
bool found = 0;
|
||||||
|
u32 i;
|
||||||
|
|
||||||
|
while(Size >= sizeof(GXRModeObj))
|
||||||
|
{
|
||||||
|
// Video mode pattern found
|
||||||
|
if( (((GXRModeObj*)Addr)->fbWidth == 0x0280 && ((GXRModeObj*)Addr)->viWidth == 0x02c4) || // TVEurgb60Hz480Prog
|
||||||
|
(((GXRModeObj*)Addr)->fbWidth == 0x0280 && ((GXRModeObj*)Addr)->viWidth == 0x0280) ) // All other video modes
|
||||||
|
{
|
||||||
|
found = 0;
|
||||||
|
for(i = 0; i < sizeof(vmodes)/sizeof(vmodes[0]); i++)
|
||||||
|
{
|
||||||
|
if(compare_videomodes(vmodes[i], (GXRModeObj*)Addr))
|
||||||
|
{
|
||||||
|
found = 1;
|
||||||
|
patch_videomode((GXRModeObj*)Addr, rmode);
|
||||||
|
Addr += (sizeof(GXRModeObj)-4);
|
||||||
|
Size -= (sizeof(GXRModeObj)-4);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(patchAll && !found)
|
||||||
|
{
|
||||||
|
patch_videomode((GXRModeObj*)Addr, rmode);
|
||||||
|
Addr += (sizeof(GXRModeObj)-4);
|
||||||
|
Size -= (sizeof(GXRModeObj)-4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Addr += 4;
|
||||||
|
Size -= 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool Search_and_patch_Video_Modes(void *Address, u32 Size, GXRModeObj* Table[])
|
static bool Search_and_patch_Video_Modes(void *Address, u32 Size, GXRModeObj* Table[])
|
||||||
{
|
{
|
||||||
u8 *Addr = (u8 *)Address;
|
u8 *Addr = (u8 *)Address;
|
||||||
@ -277,14 +269,16 @@ void patchVideoModes(void *dst, u32 len, int vidMode, GXRModeObj *vmode, int pat
|
|||||||
{
|
{
|
||||||
GXRModeObj **table = 0;
|
GXRModeObj **table = 0;
|
||||||
|
|
||||||
if(patchVidModes && vmode != 0)
|
// Video patch set to "all" or the video mode is progressive
|
||||||
applyVideoPatch(dst, len, vmode, patchVidModes - 1);
|
if((patchVidModes == 3 || vidMode == 5) && vmode != 0)
|
||||||
|
applyVideoPatch(dst, len, vmode, true);
|
||||||
|
// Video patch set to "more"
|
||||||
|
else if(patchVidModes == 2 && vmode != 0)
|
||||||
|
applyVideoPatch(dst, len, vmode, false);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch(vidMode)
|
switch(vidMode)
|
||||||
{
|
{
|
||||||
case 0: // default / disc / game
|
|
||||||
break;
|
|
||||||
case 1: // SYSTEM
|
case 1: // SYSTEM
|
||||||
switch(CONF_GetVideo())
|
switch(CONF_GetVideo())
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user