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

View File

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

View File

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

View File

@ -46,6 +46,8 @@ static GXRModeObj *vmode; // Menu video mode
int screenheight; int screenheight;
int screenwidth; 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 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 ***/ /*** GX ***/
#define TEX_WIDTH 512 #define TEX_WIDTH 512
@ -311,18 +313,10 @@ copy_to_xfb (u32 arg)
{ {
if (copynow == GX_TRUE) if (copynow == GX_TRUE)
{ {
if(ScreenshotRequested)
{
ScreenshotRequested = 0;
TakeScreenshot();
ConfigRequested = 1;
}
GX_CopyDisp (xfb[whichfb], GX_TRUE); GX_CopyDisp (xfb[whichfb], GX_TRUE);
GX_Flush (); GX_Flush ();
copynow = GX_FALSE; copynow = GX_FALSE;
} }
FrameTimer++; FrameTimer++;
} }
@ -739,7 +733,6 @@ MakeTexture (const void *src, void *dst, s32 width, s32 height)
* Update Video * Update Video
***************************************************************************/ ***************************************************************************/
uint32 prevRenderedFrameCount = 0; uint32 prevRenderedFrameCount = 0;
extern bool CheckVideo;
int fscale; int fscale;
void void
@ -834,6 +827,28 @@ update_video (int width, int height)
draw_square (view); // draw the quad draw_square (view); // draw the quad
GX_DrawDone (); 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_SetNextFramebuffer (xfb[whichfb]);
VIDEO_Flush (); VIDEO_Flush ();
copynow = GX_TRUE; copynow = GX_TRUE;

View File

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