From 732b7608299b1bbe40d65088498d9b37ab7d9265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Wed, 22 Jul 2020 14:56:28 +0300 Subject: 64-bit on Windows --- src/skel/crossplatform.h | 2 +- src/skel/glfw/glfw.cpp | 2 +- src/skel/win/win.cpp | 47 ++++++++++++++++++++++++++++++++++++++--------- src/skel/win/win.h | 8 ++++++-- 4 files changed, 46 insertions(+), 13 deletions(-) (limited to 'src/skel') diff --git a/src/skel/crossplatform.h b/src/skel/crossplatform.h index a21877c1..678d3ec4 100644 --- a/src/skel/crossplatform.h +++ b/src/skel/crossplatform.h @@ -4,7 +4,7 @@ // Functions that's different on glfw and win but have same signature, should be located on platform.h. #ifdef _WIN32 -// This only has as Win header. +// This only has as Windows header, which is lighter (as long as WITHWINDOWS isn't defined / isn't included). #include "win.h" extern DWORD _dwOperatingSystemVersion; #else diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 8b479681..a0a5a171 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -63,7 +63,7 @@ static psGlobalType PsGlobal; #undef MAKEPOINTS #define MAKEPOINTS(l) (*((POINTS /*FAR*/ *)&(l))) -unsigned long _dwMemAvailPhys; +size_t _dwMemAvailPhys; RwUInt32 gGameState; #ifdef _WIN32 diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index 93f9b8f2..f8e5c38e 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -19,7 +19,12 @@ #pragma warning( push ) #pragma warning( disable : 4005) + +#ifdef USE_D3D9 +#include +#else #include +#endif #include #include #include @@ -27,7 +32,9 @@ #define WM_GRAPHNOTIFY WM_USER+13 +#ifndef USE_D3D9 #pragma comment( lib, "d3d8.lib" ) +#endif #pragma comment( lib, "ddraw.lib" ) #pragma comment( lib, "Winmm.lib" ) #pragma comment( lib, "dxguid.lib" ) @@ -102,7 +109,7 @@ IMediaSeeking *pMS = nil; DWORD dwDXVersion; SIZE_T _dwMemTotalPhys; -SIZE_T _dwMemAvailPhys; +size_t _dwMemAvailPhys; SIZE_T _dwMemTotalVirtual; SIZE_T _dwMemAvailVirtual; DWORD _dwMemTotalVideo; @@ -453,6 +460,16 @@ DWORD GetDXVersion() dwDXVersion = 0x700; pDD7->Release(); +#ifdef USE_D3D9 + HINSTANCE hD3D9DLL = LoadLibrary("D3D9.DLL"); + if (hD3D9DLL != nil) { + FreeLibrary(hDDrawDLL); + FreeLibrary(hD3D9DLL); + + dwDXVersion = 0x900; + return dwDXVersion; + } +#endif //------------------------------------------------------------------------- // DirectX 8.0 Checks @@ -502,6 +519,7 @@ DWORD GetDXVersion() /* ***************************************************************************** */ +#ifndef _WIN64 static char cpuvendor[16] = "UnknownVendr"; __declspec(naked) const char * _psGetCpuVendr() { @@ -575,6 +593,7 @@ void _psPrintCpuInfo() if ( FeaturesEx & 0x80000000 ) debug("with 3DNow"); } +#endif /* ***************************************************************************** @@ -650,9 +669,9 @@ psInitialize(void) gGameState = GS_START_UP; TRACE("gGameState = GS_START_UP"); - +#ifndef _WIN64 _psPrintCpuInfo(); - +#endif OSVERSIONINFO verInfo; verInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); @@ -1298,8 +1317,11 @@ RwBool IsForegroundApp() UINT GetBestRefreshRate(UINT width, UINT height, UINT depth) { +#ifdef USE_D3D9 + LPDIRECT3D9 d3d = Direct3DCreate9(D3D_SDK_VERSION); +#else LPDIRECT3D8 d3d = Direct3DCreate8(D3D_SDK_VERSION); - +#endif ASSERT(d3d != nil); UINT refreshRate = INT_MAX; @@ -1312,14 +1334,21 @@ UINT GetBestRefreshRate(UINT width, UINT height, UINT depth) else format = D3DFMT_R5G6B5; +#ifdef USE_D3D9 + UINT modeCount = d3d->GetAdapterModeCount(GcurSel, format); +#else UINT modeCount = d3d->GetAdapterModeCount(GcurSel); - +#endif + for ( UINT i = 0; i < modeCount; i++ ) { D3DDISPLAYMODE mode; +#ifdef USE_D3D9 + d3d->EnumAdapterModes(GcurSel, format, i, &mode); +#else d3d->EnumAdapterModes(GcurSel, i, &mode); - +#endif if ( mode.Width == width && mode.Height == height && mode.Format == format ) { if ( mode.RefreshRate == 0 ) @@ -1612,7 +1641,7 @@ CommandLineToArgv(RwChar *cmdLine, RwInt32 *argCount) RwInt32 i, len; RwChar *res, *str, **aptr; - len = strlen(cmdLine); + len = (int)strlen(cmdLine); /* * Count the number of arguments... @@ -1700,11 +1729,11 @@ void InitialiseLanguage() { WORD primUserLCID = PRIMARYLANGID(GetSystemDefaultLCID()); WORD primSystemLCID = PRIMARYLANGID(GetUserDefaultLCID()); - WORD primLayout = PRIMARYLANGID((DWORD)GetKeyboardLayout(0)); + WORD primLayout = PRIMARYLANGID((DWORD_PTR)GetKeyboardLayout(0)); WORD subUserLCID = SUBLANGID(GetSystemDefaultLCID()); WORD subSystemLCID = SUBLANGID(GetUserDefaultLCID()); - WORD subLayout = SUBLANGID((DWORD)GetKeyboardLayout(0)); + WORD subLayout = SUBLANGID((DWORD_PTR)GetKeyboardLayout(0)); if ( primUserLCID == LANG_GERMAN || primSystemLCID == LANG_GERMAN diff --git a/src/skel/win/win.h b/src/skel/win/win.h index eb32cb72..9427822d 100644 --- a/src/skel/win/win.h +++ b/src/skel/win/win.h @@ -9,8 +9,12 @@ #endif /* (!defined(RSREGSETBREAKALLOC)) */ #ifndef _INC_WINDOWS -#define _X86_ -#include + #ifdef _WIN64 + #define _AMD64_ + #else + #define _X86_ + #endif + #include #endif enum eWinVersion -- cgit v1.2.3