mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-11-30 14:34:22 +01:00
proper code to change video modes, remove some legacy code
This commit is contained in:
parent
02cba69962
commit
ca7efcdb45
@ -96,23 +96,6 @@ void UpdateCheck()
|
||||
}
|
||||
}
|
||||
}
|
||||
else // temporary, for compatibility
|
||||
{
|
||||
int versionnum = atoi(version);
|
||||
if(versionnum > 19) // 019 (4.0.9)
|
||||
{
|
||||
item = mxmlFindElement(xml, xml, "file", NULL, NULL, MXML_DESCEND);
|
||||
if(item)
|
||||
{
|
||||
const char * tmp = mxmlElementGetAttr(item, "url");
|
||||
if(tmp)
|
||||
{
|
||||
snprintf(updateURL, 128, "%s", tmp);
|
||||
updateFound = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mxmlDelete(xml);
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
/*
|
||||
Copyright (c) 2008 Francisco Muñoz 'Hermes' <www.elotrolado.net>
|
||||
All rights reserved.
|
||||
|
||||
Proper (standard) vorbis usage by Tantric, 2009
|
||||
Threading modifications/corrections by Tantric, 2009
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are
|
||||
permitted provided that the following conditions are met:
|
||||
|
@ -41,10 +41,9 @@ unsigned char * filtermem = NULL; // only want ((512*2) X (239*2))
|
||||
/*** 2D Video ***/
|
||||
static unsigned int *xfb[2] = { NULL, NULL }; // Double buffered
|
||||
static int whichfb = 0; // Switch
|
||||
static GXRModeObj *vmode; // Menu video mode
|
||||
int screenheight;
|
||||
int screenwidth;
|
||||
static int currentVideoMode = -1; // -1 - not set, 0 - automatic, 1 - NTSC (480i), 2 - Progressive (480p), 3 - PAL (50Hz), 4 - PAL (60Hz)
|
||||
static GXRModeObj *vmode = NULL; // Current video mode
|
||||
int screenheight = 480;
|
||||
int screenwidth = 640;
|
||||
static int oldRenderMode = -1; // set to GCSettings.render when changing (temporarily) to another mode
|
||||
int CheckVideo = 0; // for forcing video reset
|
||||
|
||||
@ -417,50 +416,49 @@ void StopGX()
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* SetupVideoMode
|
||||
* FindVideoMode
|
||||
*
|
||||
* Finds the optimal video mode, or uses the user-specified one
|
||||
* Also configures original video modes
|
||||
***************************************************************************/
|
||||
static void SetupVideoMode()
|
||||
static GXRModeObj * FindVideoMode()
|
||||
{
|
||||
if(currentVideoMode == GCSettings.videomode)
|
||||
return; // no need to do anything
|
||||
|
||||
GXRModeObj * mode;
|
||||
|
||||
// choose the desired video mode
|
||||
switch(GCSettings.videomode)
|
||||
{
|
||||
case 1: // NTSC (480i)
|
||||
vmode = &TVNtsc480IntDf;
|
||||
mode = &TVNtsc480IntDf;
|
||||
break;
|
||||
case 2: // Progressive (480p)
|
||||
vmode = &TVNtsc480Prog;
|
||||
mode = &TVNtsc480Prog;
|
||||
break;
|
||||
case 3: // PAL (50Hz)
|
||||
vmode = &TVPal574IntDfScale;
|
||||
mode = &TVPal574IntDfScale;
|
||||
break;
|
||||
case 4: // PAL (60Hz)
|
||||
vmode = &TVEurgb60Hz480IntDf;
|
||||
mode = &TVEurgb60Hz480IntDf;
|
||||
break;
|
||||
default:
|
||||
vmode = VIDEO_GetPreferredMode(NULL);
|
||||
mode = VIDEO_GetPreferredMode(NULL);
|
||||
|
||||
#ifdef HW_DOL
|
||||
/* we have component cables, but the preferred mode is interlaced
|
||||
* why don't we switch into progressive?
|
||||
* on the Wii, the user can do this themselves on their Wii Settings */
|
||||
if(VIDEO_HaveComponentCable())
|
||||
vmode = &TVNtsc480Prog;
|
||||
mode = &TVNtsc480Prog;
|
||||
#endif
|
||||
|
||||
// use hardware vertical scaling to fill screen
|
||||
if(vmode->viTVMode >> 2 == VI_PAL)
|
||||
vmode = &TVPal574IntDfScale;
|
||||
if(mode->viTVMode >> 2 == VI_PAL)
|
||||
mode = &TVPal574IntDfScale;
|
||||
break;
|
||||
}
|
||||
|
||||
// configure original modes
|
||||
switch (vmode->viTVMode >> 2)
|
||||
switch (mode->viTVMode >> 2)
|
||||
{
|
||||
case VI_PAL:
|
||||
// 576 lines (PAL 50Hz)
|
||||
@ -511,7 +509,7 @@ static void SetupVideoMode()
|
||||
}
|
||||
|
||||
// check for progressive scan
|
||||
if (vmode->viTVMode == VI_TVMODE_NTSC_PROG)
|
||||
if (mode->viTVMode == VI_TVMODE_NTSC_PROG)
|
||||
progressive = true;
|
||||
else
|
||||
progressive = false;
|
||||
@ -520,11 +518,50 @@ static void SetupVideoMode()
|
||||
// widescreen fix
|
||||
if(CONF_GetAspectRatio() == CONF_ASPECT_16_9)
|
||||
{
|
||||
vmode->viWidth = VI_MAX_WIDTH_PAL;
|
||||
mode->viWidth = VI_MAX_WIDTH_PAL;
|
||||
}
|
||||
#endif
|
||||
return mode;
|
||||
}
|
||||
|
||||
currentVideoMode = GCSettings.videomode;
|
||||
/****************************************************************************
|
||||
* SetupVideoMode
|
||||
*
|
||||
* Sets up the given video mode
|
||||
***************************************************************************/
|
||||
static void SetupVideoMode(GXRModeObj * mode)
|
||||
{
|
||||
if(vmode == mode)
|
||||
return;
|
||||
|
||||
VIDEO_SetPostRetraceCallback (NULL);
|
||||
copynow = GX_FALSE;
|
||||
VIDEO_Configure (mode);
|
||||
VIDEO_Flush();
|
||||
|
||||
// Allocate the video buffers
|
||||
if(xfb[0]) free(MEM_K1_TO_K0(xfb[0]));
|
||||
if(xfb[1]) free(MEM_K1_TO_K0(xfb[1]));
|
||||
xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (mode));
|
||||
xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (mode));
|
||||
|
||||
// Clear framebuffers etc.
|
||||
VIDEO_ClearFrameBuffer (mode, xfb[0], COLOR_BLACK);
|
||||
VIDEO_ClearFrameBuffer (mode, xfb[1], COLOR_BLACK);
|
||||
VIDEO_SetNextFramebuffer (xfb[0]);
|
||||
|
||||
VIDEO_SetBlack (FALSE);
|
||||
VIDEO_Flush ();
|
||||
VIDEO_WaitVSync ();
|
||||
|
||||
if (mode->viTVMode & VI_NON_INTERLACE)
|
||||
VIDEO_WaitVSync();
|
||||
else
|
||||
while (VIDEO_GetNextField())
|
||||
VIDEO_WaitVSync();
|
||||
|
||||
VIDEO_SetPostRetraceCallback ((VIRetraceCallback)copy_to_xfb);
|
||||
vmode = mode;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -537,39 +574,11 @@ static void SetupVideoMode()
|
||||
void
|
||||
InitGCVideo ()
|
||||
{
|
||||
SetupVideoMode();
|
||||
VIDEO_Configure (vmode);
|
||||
|
||||
screenheight = 480;
|
||||
screenwidth = 640;
|
||||
|
||||
// Allocate the video buffers
|
||||
xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
|
||||
xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
|
||||
|
||||
// A console is always useful while debugging
|
||||
//console_init (xfb[0], 20, 64, vmode->fbWidth, vmode->xfbHeight, vmode->fbWidth * 2);
|
||||
|
||||
// Clear framebuffers etc.
|
||||
VIDEO_ClearFrameBuffer (vmode, xfb[0], COLOR_BLACK);
|
||||
VIDEO_ClearFrameBuffer (vmode, xfb[1], COLOR_BLACK);
|
||||
VIDEO_SetNextFramebuffer (xfb[0]);
|
||||
|
||||
// video callbacks
|
||||
VIDEO_SetPostRetraceCallback ((VIRetraceCallback)copy_to_xfb);
|
||||
|
||||
VIDEO_SetBlack (FALSE);
|
||||
VIDEO_Flush ();
|
||||
VIDEO_WaitVSync ();
|
||||
if (vmode->viTVMode & VI_NON_INTERLACE)
|
||||
VIDEO_WaitVSync ();
|
||||
|
||||
copynow = GX_FALSE;
|
||||
|
||||
GXRModeObj *rmode = FindVideoMode();
|
||||
SetupVideoMode(rmode);
|
||||
StartGX ();
|
||||
InitLUTs(); // init LUTs for hq2x
|
||||
InitVideoThread ();
|
||||
// Finally, the video is up and ready for use :)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -580,8 +589,7 @@ InitGCVideo ()
|
||||
void
|
||||
ResetVideo_Emu ()
|
||||
{
|
||||
SetupVideoMode();
|
||||
GXRModeObj *rmode = vmode; // same mode as menu
|
||||
GXRModeObj *rmode;
|
||||
Mtx44 p;
|
||||
int i = -1;
|
||||
|
||||
@ -615,16 +623,12 @@ ResetVideo_Emu ()
|
||||
rmode->viTVMode |= VI_INTERLACE;
|
||||
}
|
||||
}
|
||||
|
||||
VIDEO_Configure (rmode);
|
||||
VIDEO_Flush();
|
||||
VIDEO_WaitVSync();
|
||||
if (rmode->viTVMode & VI_NON_INTERLACE)
|
||||
VIDEO_WaitVSync();
|
||||
else
|
||||
while (VIDEO_GetNextField())
|
||||
VIDEO_WaitVSync();
|
||||
{
|
||||
rmode = FindVideoMode();
|
||||
}
|
||||
|
||||
SetupVideoMode(rmode); // reconfigure VI
|
||||
VIDEO_SetPreRetraceCallback(NULL);
|
||||
|
||||
GXColor background = {0, 0, 0, 255};
|
||||
@ -929,17 +933,9 @@ ResetVideo_Menu ()
|
||||
Mtx44 p;
|
||||
f32 yscale;
|
||||
u32 xfbHeight;
|
||||
GXRModeObj * rmode = FindVideoMode();
|
||||
|
||||
SetupVideoMode();
|
||||
VIDEO_Configure (vmode);
|
||||
VIDEO_Flush();
|
||||
VIDEO_WaitVSync();
|
||||
if (vmode->viTVMode & VI_NON_INTERLACE)
|
||||
VIDEO_WaitVSync();
|
||||
else
|
||||
while (VIDEO_GetNextField())
|
||||
VIDEO_WaitVSync();
|
||||
|
||||
SetupVideoMode(rmode); // reconfigure VI
|
||||
VIDEO_SetPreRetraceCallback((VIRetraceCallback)UpdatePads);
|
||||
|
||||
// clears the bg to color and clears the z buffer
|
||||
|
Loading…
Reference in New Issue
Block a user