video code cleanup/corrections

This commit is contained in:
dborth 2009-06-15 08:23:19 +00:00
parent 6bf2a1f353
commit 17278b6332
5 changed files with 155 additions and 183 deletions

View File

@ -4,7 +4,7 @@
* softdev July 2006
* crunchy2 May 2007
* Michniewski 2008
* Tantric September 2008
* Tantric 2008-2009
*
* s9xsupport.cpp
*
@ -41,74 +41,66 @@ static long long prev;
static long long now;
/*** Miscellaneous Functions ***/
void
S9xMessage (int /*type */ , int /*number */ , const char *message)
void S9xMessage(int /*type */, int /*number */, const char *message)
{
#define MAX_MESSAGE_LEN (36 * 3)
static char buffer[MAX_MESSAGE_LEN + 1];
strncpy (buffer, message, MAX_MESSAGE_LEN);
buffer[MAX_MESSAGE_LEN] = 0;
S9xSetInfoString (buffer);
static char buffer[MAX_MESSAGE_LEN + 1];
strncpy(buffer, message, MAX_MESSAGE_LEN);
buffer[MAX_MESSAGE_LEN] = 0;
S9xSetInfoString(buffer);
}
void
S9xExit ()
void S9xExit()
{
/*** Nintendo Gamecube will NEVER get here ... unless
something major went wrong !!
In which case, I'll settle for a reboot first -;)
***/
ExitApp();
}
/*** File based functions ***/
const char *
S9xChooseFilename (bool8 read_only)
S9xChooseFilename(bool8 read_only)
{
return NULL;
return NULL;
}
const char *
S9xChooseMovieFilename (bool8 read_only)
S9xChooseMovieFilename(bool8 read_only)
{
return NULL;
return NULL;
}
const char *
S9xGetDirectory (enum s9x_getdirtype dirtype)
S9xGetDirectory(enum s9x_getdirtype dirtype)
{
return NULL;
return NULL;
}
const char *
S9xGetFilename (const char *ex, enum s9x_getdirtype dirtype)
S9xGetFilename(const char *ex, enum s9x_getdirtype dirtype)
{
return NULL;
return NULL;
}
const char *
S9xGetFilenameInc (const char *e, enum s9x_getdirtype dirtype)
S9xGetFilenameInc(const char *e, enum s9x_getdirtype dirtype)
{
return NULL;
return NULL;
}
/*** Memory based functions ***/
void
S9xAutoSaveSRAM ()
void S9xAutoSaveSRAM()
{
}
/*** Sound based functions ***/
void
S9xToggleSoundChannel (int c)
void S9xToggleSoundChannel(int c)
{
if (c == 8)
so.sound_switch = 255;
else
so.sound_switch ^= 1 << c;
S9xSetSoundControl (so.sound_switch);
if (c == 8)
so.sound_switch = 255;
else
so.sound_switch ^= 1 << c;
S9xSetSoundControl(so.sound_switch);
}
/****************************************************************************
@ -116,176 +108,157 @@ S9xToggleSoundChannel (int c)
*
* Main initialisation for NGC sound system
***************************************************************************/
bool8
S9xOpenSoundDevice (int mode, bool8 stereo, int buffer_size)
bool8 S9xOpenSoundDevice(int mode, bool8 stereo, int buffer_size)
{
so.stereo = TRUE;
so.playback_rate = 32000;
so.sixteen_bit = TRUE;
so.encoded = 0;
so.buffer_size = 4096;
so.sound_switch = 255;
S9xSetPlaybackRate (so.playback_rate);
so.stereo = TRUE;
so.playback_rate = 32000;
so.sixteen_bit = TRUE;
so.encoded = 0;
so.buffer_size = 4096;
so.sound_switch = 255;
S9xSetPlaybackRate(so.playback_rate);
InitAudio ();
return TRUE;
InitAudio();
return TRUE;
}
/*** Deprecated function. NGC uses threaded sound ***/
void
S9xGenerateSound ()
void S9xGenerateSound()
{
}
/* eke-eke */
void S9xInitSync()
{
FrameTimer = 0;
prev = gettime();
FrameTimer = 0;
prev = gettime();
}
/*** Synchronisation ***/
extern int timerstyle;
void S9xSyncSpeed ()
{
uint32 skipFrms = Settings.SkipFrames;
uint32 skipFrms = Settings.SkipFrames;
if ( Settings.TurboMode )
skipFrms = Settings.TurboSkipFrames;
if (Settings.TurboMode)
skipFrms = Settings.TurboSkipFrames;
if ( timerstyle == 0 ) /* use NGC vertical sync (VSYNC) with NTSC roms */
{
while (FrameTimer == 0)
{
usleep (50);
}
if (timerstyle == 0) /* use NGC vertical sync (VSYNC) with NTSC roms */
{
while (FrameTimer == 0)
{
usleep(50);
}
if (FrameTimer > skipFrms)
FrameTimer = skipFrms;
if (FrameTimer > skipFrms)
FrameTimer = skipFrms;
if ((FrameTimer > 1) && (IPPU.SkippedFrames < skipFrms))
{
IPPU.SkippedFrames++;
IPPU.RenderThisFrame = FALSE;
}
else
{
IPPU.SkippedFrames = 0;
IPPU.RenderThisFrame = TRUE;
}
if ((FrameTimer > 1) && (IPPU.SkippedFrames < skipFrms))
{
IPPU.SkippedFrames++;
IPPU.RenderThisFrame = FALSE;
}
else
{
IPPU.SkippedFrames = 0;
IPPU.RenderThisFrame = TRUE;
}
}
else /* use internal timer for PAL roms */
{
unsigned int timediffallowed = Settings.TurboMode ? 0 : Settings.FrameTime;
now = gettime();
else /* use internal timer for PAL roms */
{
unsigned int timediffallowed = Settings.TurboMode ? 0 : Settings.FrameTime;
now = gettime();
if (diff_usec(prev, now) > timediffallowed)
{
/*while ( diff_usec((prev, now) < timediffallowed * 2) {
now = gettime();
}*/
if (diff_usec(prev, now) > timediffallowed)
{
/* Timer has already expired */
if (IPPU.SkippedFrames < skipFrms)
{
IPPU.SkippedFrames++;
IPPU.RenderThisFrame = FALSE;
}
else
{
IPPU.SkippedFrames = 0;
IPPU.RenderThisFrame = TRUE;
}
}
else
{
/*** Ahead - so hold up ***/
while (diff_usec(prev, now) < timediffallowed)
{
now = gettime();
usleep(50);
}
IPPU.RenderThisFrame = TRUE;
IPPU.SkippedFrames = 0;
}
/* Timer has already expired */
if (IPPU.SkippedFrames < skipFrms)
{
IPPU.SkippedFrames++;
IPPU.RenderThisFrame = FALSE;
}
else
{
IPPU.SkippedFrames = 0;
IPPU.RenderThisFrame = TRUE;
}
}
else
{
/*** Ahead - so hold up ***/
while (diff_usec(prev, now) < timediffallowed) now=gettime();
IPPU.RenderThisFrame = TRUE;
IPPU.SkippedFrames = 0;
}
prev = now;
}
if ( !Settings.TurboMode )
FrameTimer--;
return;
prev = now;
}
if (!Settings.TurboMode)
FrameTimer--;
return;
}
/*** Video / Display related functions ***/
bool8
S9xInitUpdate ()
bool8 S9xInitUpdate()
{
/***
* Is this necessary in 1.50 ?
* memset (GFX.Screen, 0, IMAGE_WIDTH * IMAGE_HEIGHT * 2);
*/
return (TRUE);
return (TRUE);
}
bool8
S9xDeinitUpdate (int Width, int Height)
bool8 S9xDeinitUpdate(int Width, int Height)
{
update_video (Width, Height);
return (TRUE);
update_video(Width, Height);
return (TRUE);
}
bool8
S9xContinueUpdate (int Width, int Height)
bool8 S9xContinueUpdate(int Width, int Height)
{
return (TRUE);
return (TRUE);
}
void
S9xSetPalette ()
void S9xSetPalette()
{
return;
return;
}
/*** Input functions ***/
void
S9xHandlePortCommand (s9xcommand_t cmd, int16 data1, int16 data2)
void S9xHandlePortCommand(s9xcommand_t cmd, int16 data1, int16 data2)
{
return;
return;
}
bool
S9xPollButton (uint32 id, bool * pressed)
bool S9xPollButton(uint32 id, bool * pressed)
{
return 0;
return 0;
}
bool
S9xPollAxis (uint32 id, int16 * value)
bool S9xPollAxis(uint32 id, int16 * value)
{
return 0;
return 0;
}
bool
S9xPollPointer (uint32 id, int16 * x, int16 * y)
bool S9xPollPointer(uint32 id, int16 * x, int16 * y)
{
return 0;
return 0;
}
void
S9xLoadSDD1Data ()
void S9xLoadSDD1Data()
{
Memory.FreeSDD1Data();
Memory.FreeSDD1Data ();
Settings.SDD1Pack = FALSE;
Settings.SDD1Pack = FALSE;
if (strncmp(Memory.ROMName, "Star Ocean", 10) == 0)
Settings.SDD1Pack = TRUE;
if (strncmp (Memory.ROMName, "Star Ocean", 10) == 0)
Settings.SDD1Pack = TRUE;
if (strncmp (Memory.ROMName, "STREET FIGHTER ALPHA2", 21) == 0)
Settings.SDD1Pack = TRUE;
return;
if (strncmp(Memory.ROMName, "STREET FIGHTER ALPHA2", 21) == 0)
Settings.SDD1Pack = TRUE;
return;
}
/****************************************************************************
@ -294,22 +267,20 @@ S9xLoadSDD1Data ()
***************************************************************************/
/*** splitpath function ***/
void
_splitpath (char const *buffer, char *drive, char *dir, char *fname,
char *ext)
void _splitpath(char const *buffer, char *drive, char *dir, char *fname,
char *ext)
{
return; /*** Do nothing - NGC code should NEVER call a function which relies on it ***/
return; // Do nothing - NGC code should NEVER call a function which relies on it
}
void
_makepath (char *filename, const char *drive, const char *dir,
const char *fname, const char *ext)
void _makepath(char *filename, const char *drive, const char *dir,
const char *fname, const char *ext)
{
return; /*** Do nothing - NGC code should NEVER call a function which relies on it ***/
return; // Do nothing - NGC code should NEVER call a function which relies on it
}
char *
S9xBasename (char *name)
S9xBasename(char *name)
{
return name;
return name;
}

View File

@ -197,13 +197,11 @@ void setFrameTimerMethod()
timerstyle = 1;
else
timerstyle = 0;
//timediffallowed = Settings.FrameTimePAL;
} else {
if(vmode_60hz == 1)
timerstyle = 0;
else
timerstyle = 1;
//timediffallowed = Settings.FrameTimeNTSC;
}
return;
}
@ -212,7 +210,6 @@ void setFrameTimerMethod()
* Emulation loop
***************************************************************************/
extern void S9xInitSync();
bool CheckVideo = 0; // for forcing video reset in video.cpp
extern uint32 prevRenderedFrameCount;
static int videoReset;
static int currentMode;
@ -273,21 +270,10 @@ emulate ()
}
if (ConfigRequested)
{
if((GCSettings.render != 0 && videoReset == -1) || videoReset == 0)
{
FreeGfxMem();
ResetVideo_Menu();
ConfigRequested = 0;
GCSettings.render = currentMode;
break; // leave emulation loop
}
else if(videoReset == -1)
{
GCSettings.render = 2;
CheckVideo = 1;
videoReset = 2;
}
videoReset--;
ConfigRequested = 0;
FreeGfxMem();
ResetVideo_Menu();
break;
}
} // emulation loop
} // main loop

View File

@ -100,6 +100,5 @@ extern int ShutdownRequested;
extern int ExitRequested;
extern char appPath[];
extern FreeTypeGX *fontSystem;
extern int timerstyle;
#endif

View File

@ -46,6 +46,8 @@ 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 int oldRenderMode = -1; // set to GCSettings.render when changing (temporarily) to another mode
int CheckVideo = 0; // for forcing video reset
/*** GX ***/
#define TEX_WIDTH 512
@ -311,18 +313,10 @@ copy_to_xfb (u32 arg)
{
if (copynow == GX_TRUE)
{
if(ScreenshotRequested)
{
ScreenshotRequested = 0;
TakeScreenshot();
ConfigRequested = 1;
}
GX_CopyDisp (xfb[whichfb], GX_TRUE);
GX_Flush ();
copynow = GX_FALSE;
}
FrameTimer++;
}
@ -739,7 +733,6 @@ MakeTexture (const void *src, void *dst, s32 width, s32 height)
* Update Video
***************************************************************************/
uint32 prevRenderedFrameCount = 0;
extern bool CheckVideo;
int fscale;
void
@ -834,6 +827,28 @@ update_video (int width, int height)
draw_square (view); // draw the quad
GX_DrawDone ();
if(ScreenshotRequested)
{
if(GCSettings.render == 0) // we can't take a screenshot in Original mode
{
oldRenderMode = 0;
GCSettings.render = 2; // switch to unfiltered mode
CheckVideo = 1; // request the switch
}
else
{
ScreenshotRequested = 0;
TakeScreenshot();
if(oldRenderMode != -1)
{
GCSettings.render = oldRenderMode;
oldRenderMode = -1;
}
ConfigRequested = 1;
}
}
VIDEO_SetNextFramebuffer (xfb[whichfb]);
VIDEO_Flush ();
copynow = GX_TRUE;

View File

@ -41,5 +41,6 @@ extern u8 * gameScreenTex2;
extern u32 FrameTimer;
extern u8 vmode_60hz;
extern int timerstyle;
extern int CheckVideo;
#endif