- add PAL/NTSC defines

This commit is contained in:
Ilya Shurumov 2020-05-26 18:21:40 +06:00
parent b73b3f93fb
commit 049ec30076
4 changed files with 20 additions and 47 deletions

View File

@ -18,15 +18,14 @@
#endif
#include <assert.h>
#define FIXED_TIME_STEP 16
#define SWAP_INTERVAL 1
#if defined(NTSC_VERSION)
#define COUNTER_UPDATE_INTERVAL (263)
#define FIXED_TIME_STEP 16 // 16.6667 = 60 FPS
#else
#define COUNTER_UPDATE_INTERVAL (313)
#define FIXED_TIME_STEP 20 // 20.0 = 50 FPS
#endif
#define SWAP_INTERVAL 1
#include <stdio.h>
#include <string.h>
#include <SDL.h>
@ -318,7 +317,6 @@ static int Emulator_InitialiseGLEW()
SDL_Thread* g_vblankThread = NULL;
SDL_mutex* g_vblankMutex = NULL;
volatile bool g_stopVblank = false;
volatile int g_vblankTime = 0;
volatile int g_vblanksDone = 0;
volatile int g_lastVblankCnt = 0;
@ -364,9 +362,11 @@ int Emulator_DoVSyncCallback()
int vblankThreadMain(void* data)
{
int vblankTime = SDL_GetTicks();
do
{
int delta = g_vblankTime + FIXED_TIME_STEP - SDL_GetTicks();
int delta = vblankTime + FIXED_TIME_STEP - SDL_GetTicks();
if (delta < 0)
{
@ -374,7 +374,7 @@ int vblankThreadMain(void* data)
SDL_LockMutex(g_vblankMutex);
g_vblanksDone++;
g_vblankTime = SDL_GetTicks();
vblankTime = SDL_GetTicks();
SDL_UnlockMutex(g_vblankMutex);
}
@ -400,8 +400,6 @@ static int Emulator_InitialiseCore()
return FALSE;
}
g_vblankTime = SDL_GetTicks();
return TRUE;
}
@ -438,8 +436,6 @@ void Emulator_Initialise(char* windowName, int width, int height)
}
g_swapTime = SDL_GetTicks() - FIXED_TIME_STEP;
//counter_thread = std::thread(Emulator_CounterLoop);
}
void Emulator_GetScreenSize(int& screenWidth, int& screenHeight)
@ -447,38 +443,6 @@ void Emulator_GetScreenSize(int& screenWidth, int& screenHeight)
SDL_GetWindowSize(g_window, &screenWidth, &screenHeight);
}
void Emulator_CounterLoop()
{
static int numUpdates = 0;
int last_time = 0;
while (TRUE)
{
int now = SDL_GetTicks();
if (now > last_time + 1000)
{
numUpdates = 0;
last_time = now;
}
if (numUpdates++ <= 60)
{
for (int i = 0; i < 3; i++)
{
//if (!counters[i].IsStopped)
{
counters[i].cycle += COUNTER_UPDATE_INTERVAL;
if (counters[i].target > 0)
{
counters[i].cycle %= counters[i].target;
}
}
}
}
}
}
void Emulator_GenerateLineArray(struct Vertex* vertex, VERTTYPE* p0, VERTTYPE* p1, ushort gteidx)
{
// swap line coordinates for left-to-right and up-to-bottom direction

View File

@ -54,11 +54,20 @@ int VSyncCallback(void(*f)(void))
long GetVideoMode(void)
{
#ifdef NTSC_VERSION
return MODE_NTSC;
#else
return MODE_PAL;
#endif
}
long SetVideoMode(long mode)
{
UNIMPLEMENTED();
#ifdef NTSC_VERSION
return MODE_NTSC;
#else
return MODE_PAL;
#endif
}

View File

@ -99,7 +99,7 @@ void InitSound(void)
ResetSound();
XM_OnceOffInit(0); // [A] PAL or NTSC here
XM_OnceOffInit(GetVideoMode()); // [A] PAL or NTSC here
SetMasterVolume(gMasterVolume);
VSyncCallback(VsyncProc);

View File

@ -98,7 +98,7 @@
<Optimization>Disabled</Optimization>
<SDLCheck>false</SDLCheck>
<ConformanceMode>false</ConformanceMode>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;GLEW;OGL;USE_32_BIT_ADDR;SIMPLE_SPOOL;USE_CRT_MALLOC;PGXP;COLLISION_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;GLEW;OGL;USE_32_BIT_ADDR;SIMPLE_SPOOL;USE_CRT_MALLOC;PGXP;COLLISION_DEBUG;NTSC_VERSION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>./;EMULATOR;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<CompileAs>CompileAsCpp</CompileAs>
@ -133,7 +133,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>false</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;GLEW;OGL;USE_32_BIT_ADDR;PGXP;DEBUG_OPTIONS;SIMPLE_SPOOL;USE_CRT_MALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;GLEW;OGL;USE_32_BIT_ADDR;PGXP;DEBUG_OPTIONS;SIMPLE_SPOOL;USE_CRT_MALLOC;NTSC_VERSION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>false</ConformanceMode>
<CompileAs>CompileAsCpp</CompileAs>
<AdditionalIncludeDirectories>./;EMULATOR;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>