Fixing timing with MinGW. Direct X failing now gives informative message.
This commit is contained in:
@@ -25,7 +25,8 @@ DELETECOMMAND=rm
|
|||||||
SLASH=/
|
SLASH=/
|
||||||
ASM=nasm
|
ASM=nasm
|
||||||
ASMFLAGSORIG=-O1
|
ASMFLAGSORIG=-O1
|
||||||
CFLAGSORIG=-O3 -march=i586 -ffast-math -fomit-frame-pointer -fno-unroll-loops -Wall -Wno-unused
|
CFLAGSORIG=-march=i586 -ffast-math -fomit-frame-pointer -fno-unroll-loops -Wall -Wno-unused
|
||||||
|
COPT=-O3
|
||||||
LIBSORIG=-lz -lpng
|
LIBSORIG=-lz -lpng
|
||||||
|
|
||||||
ifeq ($(PLATFORM),)
|
ifeq ($(PLATFORM),)
|
||||||
@@ -163,10 +164,10 @@ endif
|
|||||||
.SUFFIXES: .c .cpp .asm
|
.SUFFIXES: .c .cpp .asm
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
${CC} ${CFLAGS} -o $@ -c $<
|
${CC} ${COPT} ${CFLAGS} -o $@ -c $<
|
||||||
|
|
||||||
%.o: %.cpp
|
%.o: %.cpp
|
||||||
${CPPC} ${CFLAGS} -o $@ -c $<
|
${CPPC} ${COPT} ${CFLAGS} -o $@ -c $<
|
||||||
|
|
||||||
%.o: %.asm
|
%.o: %.asm
|
||||||
${ASM} ${ASMFLAGS} -o $@ $<
|
${ASM} ${ASMFLAGS} -o $@ $<
|
||||||
@@ -289,7 +290,7 @@ ${WINDIR}/ztcp.o: $<
|
|||||||
${WINDIR}/zsnes.o: ${WINDIR}/zsnes.rc
|
${WINDIR}/zsnes.o: ${WINDIR}/zsnes.rc
|
||||||
${WINDRES} --include-dir ${WINDIR} ${WINDIR}/zsnes.rc -o${WINDIR}/zsnes.o
|
${WINDRES} --include-dir ${WINDIR} ${WINDIR}/zsnes.rc -o${WINDIR}/zsnes.o
|
||||||
${WINDIR}/winlink.o: ${WINDIR}/winlink.cpp ${WINDIR}/resource.h
|
${WINDIR}/winlink.o: ${WINDIR}/winlink.cpp ${WINDIR}/resource.h
|
||||||
${CPPC} ${CFLAGS} -masm=intel -O0 -o $@ -c ${WINDIR}/winlink.cpp
|
${CPPC} -O0 ${CFLAGS} -masm=intel -o $@ -c ${WINDIR}/winlink.cpp
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
${DELETECOMMAND} ${EXE}
|
${DELETECOMMAND} ${EXE}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ along with this program; if not, write to the Free Software
|
|||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#define DIRECTINPUT_VERSION 0x0800
|
#define DIRECTINPUT_VERSION 0x0800
|
||||||
#define DIRECTSOUND_VERSION 0x0800
|
#define DIRECTSOUND_VERSION 0x0800
|
||||||
|
|
||||||
@@ -236,6 +235,14 @@ extern "C" void FreeDirectX()
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" void DXLoadError()
|
||||||
|
{
|
||||||
|
if (MessageBox(NULL, "Sorry, you need to install or reinstall DirectX v8.0 or higher\nto use ZSNESW.\nWould you like to go to the DirectX homepage?", "Error", MB_ICONINFORMATION | MB_YESNO) == IDYES)
|
||||||
|
{
|
||||||
|
ShellExecute(NULL, NULL, "http://www.microsoft.com/directx/", NULL, NULL, 0);
|
||||||
|
}
|
||||||
|
FreeDirectX();
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" void ImportDirectX()
|
extern "C" void ImportDirectX()
|
||||||
{
|
{
|
||||||
@@ -243,9 +250,7 @@ extern "C" void ImportDirectX()
|
|||||||
|
|
||||||
if (hM_dinput8 == NULL)
|
if (hM_dinput8 == NULL)
|
||||||
{
|
{
|
||||||
if (MessageBox(NULL, "Sorry, you need DirectX v8.0 or higher to use\nZSNESW. Would you like to go to the DirectX homepage?", "Error", MB_ICONINFORMATION | MB_YESNO) == IDYES)
|
DXLoadError();
|
||||||
ShellExecute(NULL, NULL, "http://www.microsoft.com/directx/", NULL, NULL, 0);
|
|
||||||
FreeDirectX();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pDirectInput8Create = (lpDirectInput8Create) GetProcAddress(hM_dinput8, dinput8_imp);
|
pDirectInput8Create = (lpDirectInput8Create) GetProcAddress(hM_dinput8, dinput8_imp);
|
||||||
@@ -255,7 +260,7 @@ extern "C" void ImportDirectX()
|
|||||||
char err[256];
|
char err[256];
|
||||||
wsprintf(err,"Failed to import %s:%s", dinput8_dll, dinput8_imp);
|
wsprintf(err,"Failed to import %s:%s", dinput8_dll, dinput8_imp);
|
||||||
MessageBox(NULL, err, "Error", MB_ICONERROR);
|
MessageBox(NULL, err, "Error", MB_ICONERROR);
|
||||||
FreeDirectX();
|
DXLoadError();
|
||||||
}
|
}
|
||||||
|
|
||||||
hM_ddraw = LoadLibrary(ddraw_dll);
|
hM_ddraw = LoadLibrary(ddraw_dll);
|
||||||
@@ -265,7 +270,7 @@ extern "C" void ImportDirectX()
|
|||||||
char err[256];
|
char err[256];
|
||||||
wsprintf(err,"Failed to import %s",ddraw_dll);
|
wsprintf(err,"Failed to import %s",ddraw_dll);
|
||||||
MessageBox(NULL, err,"Error",MB_ICONERROR);
|
MessageBox(NULL, err,"Error",MB_ICONERROR);
|
||||||
FreeDirectX();
|
DXLoadError();
|
||||||
}
|
}
|
||||||
|
|
||||||
pDirectDrawCreateEx = (lpDirectDrawCreateEx) GetProcAddress(hM_ddraw, ddraw_imp);
|
pDirectDrawCreateEx = (lpDirectDrawCreateEx) GetProcAddress(hM_ddraw, ddraw_imp);
|
||||||
@@ -275,7 +280,7 @@ extern "C" void ImportDirectX()
|
|||||||
char err[256];
|
char err[256];
|
||||||
wsprintf(err,"Failed to import %s:%s", ddraw_dll, ddraw_imp);
|
wsprintf(err,"Failed to import %s:%s", ddraw_dll, ddraw_imp);
|
||||||
MessageBox(NULL, err, "Error", MB_ICONERROR);
|
MessageBox(NULL, err, "Error", MB_ICONERROR);
|
||||||
FreeDirectX();
|
DXLoadError();
|
||||||
}
|
}
|
||||||
|
|
||||||
hM_dsound = LoadLibrary(dsound_dll);
|
hM_dsound = LoadLibrary(dsound_dll);
|
||||||
@@ -285,7 +290,7 @@ extern "C" void ImportDirectX()
|
|||||||
char err[256];
|
char err[256];
|
||||||
wsprintf(err,"Failed to import %s",dsound_dll);
|
wsprintf(err,"Failed to import %s",dsound_dll);
|
||||||
MessageBox(NULL, err,"Error",MB_ICONERROR);
|
MessageBox(NULL, err,"Error",MB_ICONERROR);
|
||||||
FreeDirectX();
|
DXLoadError();
|
||||||
}
|
}
|
||||||
|
|
||||||
pDirectSoundCreate8 = (lpDirectSoundCreate8) GetProcAddress(hM_dsound, dsound_imp);
|
pDirectSoundCreate8 = (lpDirectSoundCreate8) GetProcAddress(hM_dsound, dsound_imp);
|
||||||
@@ -295,23 +300,17 @@ extern "C" void ImportDirectX()
|
|||||||
char err[256];
|
char err[256];
|
||||||
wsprintf(err,"Failed to import %s:%s", dsound_dll, dsound_imp);
|
wsprintf(err,"Failed to import %s:%s", dsound_dll, dsound_imp);
|
||||||
MessageBox(NULL, err, "Error", MB_ICONERROR);
|
MessageBox(NULL, err, "Error", MB_ICONERROR);
|
||||||
FreeDirectX();
|
DXLoadError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Nach: I'm not sure why we have such a number for NTSC, but MinGW
|
// milliseconds per world update
|
||||||
//is using floating point arithmetic with it and going really slow.
|
#define UPDATE_TICKS_GAME (1000.855001760297741789468390082/60.0)
|
||||||
//So for MinGW I set it to the same idea as PAL
|
#define UPDATE_TICKS_GAMEPAL (20.0)
|
||||||
#ifdef __GNUC__
|
#define UPDATE_TICKS_GUI (1000.0/36.0)
|
||||||
#define UPDATE_TICKS_GAME (1000/60)
|
#define UPDATE_TICKS_UDP (1000.0/60.0)
|
||||||
#else
|
|
||||||
#define UPDATE_TICKS_GAME (1000.855001760297741789468390082/60) // milliseconds per world update
|
|
||||||
#endif
|
|
||||||
#define UPDATE_TICKS_GAMEPAL (1000/50) // milliseconds per world update
|
|
||||||
#define UPDATE_TICKS_GUI (1000/36) // milliseconds per world update
|
|
||||||
#define UPDATE_TICKS_UDP (1000/60) // milliseconds per world update
|
|
||||||
|
|
||||||
__int64 start, end, freq, update_ticks_pc, start2, end2, update_ticks_pc2;
|
double start, end, freq, update_ticks_pc, start2, end2, update_ticks_pc2;
|
||||||
|
|
||||||
void ReleaseDirectDraw();
|
void ReleaseDirectDraw();
|
||||||
void ReleaseDirectSound();
|
void ReleaseDirectSound();
|
||||||
@@ -1777,15 +1776,15 @@ extern unsigned char romispal;
|
|||||||
|
|
||||||
void Start60HZ(void)
|
void Start60HZ(void)
|
||||||
{
|
{
|
||||||
update_ticks_pc2 = UPDATE_TICKS_UDP * freq / 1000;
|
update_ticks_pc2 = UPDATE_TICKS_UDP * freq / 1000.0;
|
||||||
|
|
||||||
if (romispal==1)
|
if (romispal==1)
|
||||||
{
|
{
|
||||||
update_ticks_pc = UPDATE_TICKS_GAMEPAL * freq / 1000;
|
update_ticks_pc = UPDATE_TICKS_GAMEPAL * freq / 1000.0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
update_ticks_pc = (__int64) (UPDATE_TICKS_GAME * freq / 1000);
|
update_ticks_pc = UPDATE_TICKS_GAME * freq / 1000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QueryPerformanceCounter((LARGE_INTEGER*)&start);
|
QueryPerformanceCounter((LARGE_INTEGER*)&start);
|
||||||
@@ -1806,8 +1805,8 @@ void Stop60HZ(void)
|
|||||||
|
|
||||||
void Start36HZ(void)
|
void Start36HZ(void)
|
||||||
{
|
{
|
||||||
update_ticks_pc2 = UPDATE_TICKS_UDP * freq / 1000;
|
update_ticks_pc2 = UPDATE_TICKS_UDP * freq / 1000.0;
|
||||||
update_ticks_pc = UPDATE_TICKS_GUI * freq / 1000;
|
update_ticks_pc = UPDATE_TICKS_GUI * freq / 1000.0;
|
||||||
|
|
||||||
QueryPerformanceCounter((LARGE_INTEGER*)&start);
|
QueryPerformanceCounter((LARGE_INTEGER*)&start);
|
||||||
QueryPerformanceCounter((LARGE_INTEGER*)&start2);
|
QueryPerformanceCounter((LARGE_INTEGER*)&start2);
|
||||||
@@ -3039,12 +3038,12 @@ void FrameSemaphore()
|
|||||||
{
|
{
|
||||||
if (T60HZEnabled == 1)
|
if (T60HZEnabled == 1)
|
||||||
{
|
{
|
||||||
int delay;
|
double delay;
|
||||||
QueryPerformanceCounter((LARGE_INTEGER*)&end);
|
QueryPerformanceCounter((LARGE_INTEGER*)&end);
|
||||||
|
|
||||||
delay = (int) ((update_ticks_pc - (end - start)) * 1000 / freq) - 3;
|
delay = ((update_ticks_pc - (end - start)) * 1000.0 / freq) - 3.0;
|
||||||
|
|
||||||
if (delay>0) WaitForSingleObject(hLock, delay);
|
if (delay>0.0) WaitForSingleObject(hLock, (unsigned int)delay);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3057,4 +3056,3 @@ void ZsnesPage()
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user