- [Psy-X] proper SetVideoMode/GetVideoMode, NTSC or PAL timestep

This commit is contained in:
Ilya Shurumov 2020-11-21 15:12:58 +06:00
parent d0d21ee687
commit 9d7f707a99
3 changed files with 25 additions and 27 deletions

View File

@ -758,7 +758,7 @@ void LaunchGame(void)
fakeOtherPlayer = 0;
ResetGraph(1);
SetVideoMode(1);
SetVideoMode(video_mode);
gMissionCompletionState = PAUSEMODE_GAMEOVER;

View File

@ -15,11 +15,8 @@
#endif
#include <assert.h>
#if defined(NTSC_VERSION)
#define FIXED_TIME_STEP (1.0/60.0) // 60 FPS clock
#else
#define FIXED_TIME_STEP (1.0/50.0) // 50 FPS clock
#endif
#define FIXED_TIME_STEP_NTSC (1.0/60.0) // 60 FPS clock
#define FIXED_TIME_STEP_PAL (1.0/50.0) // 50 FPS clock
#define SWAP_INTERVAL 1
@ -340,12 +337,15 @@ int Emulator_DoVSyncCallback()
int vblankThreadMain(void* data)
{
Emulator_InitHPCTimer(&g_vblankTimer);
do
{
const long vmode = GetVideoMode();
const double timestep = vmode == MODE_NTSC ? FIXED_TIME_STEP_NTSC : FIXED_TIME_STEP_PAL;
double delta = Emulator_GetHPCTime(&g_vblankTimer, 0);
if (delta > FIXED_TIME_STEP)
if (delta > timestep)
{
// do vblank events
SDL_LockMutex(g_vblankMutex);
@ -1901,6 +1901,9 @@ void Emulator_SwapWindow()
void Emulator_WaitForTimestep(int count)
{
const long vmode = GetVideoMode();
const double timestep = vmode == MODE_NTSC ? FIXED_TIME_STEP_NTSC : FIXED_TIME_STEP_PAL;
// additional wait for swap
if (g_swapInterval > 0)
{
@ -1909,7 +1912,7 @@ void Emulator_WaitForTimestep(int count)
{
SDL_Delay(0); // yield
delta = Emulator_GetHPCTime(&g_swapTimer, 0);
} while (delta < FIXED_TIME_STEP * count);
} while (delta < timestep * count);
Emulator_GetHPCTime(&g_swapTimer, 1);
}

View File

@ -5,6 +5,7 @@
#include <SDL_timer.h>
int vmode = MODE_NTSC;
void(*vsync_callback)(void) = NULL;
int StopCallback(void)
@ -15,8 +16,9 @@ int StopCallback(void)
int ResetCallback(void)
{
int old = (int)vsync_callback;
vsync_callback = NULL;
return 0;
return old;
}
extern unsigned int g_swapTime;
@ -44,26 +46,19 @@ int VSync(int mode)
int VSyncCallback(void(*f)(void))
{
int old = (int)vsync_callback;
vsync_callback = f;
return 0;
}
long GetVideoMode(void)
{
#ifdef NTSC_VERSION
return MODE_NTSC;
#else
return MODE_PAL;
#endif
return old;
}
long SetVideoMode(long mode)
{
UNIMPLEMENTED();
#ifdef NTSC_VERSION
return MODE_NTSC;
#else
return MODE_PAL;
#endif
int old = vmode;
vmode = mode;
return old;
}
long GetVideoMode()
{
return vmode;
}