summaryrefslogtreecommitdiffstats
path: root/src/skel/win/win.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/skel/win/win.cpp')
-rw-r--r--src/skel/win/win.cpp135
1 files changed, 52 insertions, 83 deletions
diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp
index ec84e968..e623defb 100644
--- a/src/skel/win/win.cpp
+++ b/src/skel/win/win.cpp
@@ -1,3 +1,5 @@
+#if defined RW_D3D9 || defined RWLIBS
+
#define _WIN32_WINDOWS 0x0500
#define WINVER 0x0500
#define DIRECTINPUT_VERSION 0x0800
@@ -40,36 +42,30 @@
#include "resource.h"
#include "skeleton.h"
#include "platform.h"
-#include "win.h"
+#include "crossplatform.h"
#define MAX_SUBSYSTEMS (16)
-//static RwBool ForegroundApp = TRUE;
-static RwBool &ForegroundApp = *(RwBool*)0x060F000;
+static RwBool ForegroundApp = TRUE;
-//static RwBool RwInitialised = FALSE;
-static RwBool &RwInitialised = *(RwBool*)0x885B88;
+static RwBool RwInitialised = FALSE;
static RwSubSystemInfo GsubSysInfo[MAX_SUBSYSTEMS];
static RwInt32 GnumSubSystems = 0;
static RwInt32 GcurSel = 0, GcurSelVM = 0;
-//static RwBool startupDeactivate;
-static RwBool &startupDeactivate = *(RwBool*)0x8E2878;
+static RwBool startupDeactivate;
-//static RwBool useDefault;
-static RwBool &useDefault = *(RwBool*)0x6510D4;
+static RwBool useDefault;
-//static RwBool defaultFullscreenRes = TRUE;
-static RwBool &defaultFullscreenRes = *(RwBool*)0x60EFFC;
+static RwBool defaultFullscreenRes = TRUE;
/* Class name for the MS Window's window class. */
static const RwChar *AppClassName = RWSTRING("Grand theft auto 3");
-//static psGlobalType PsGlobal;
-static psGlobalType &PsGlobal = *(psGlobalType*)0x72CF60;
+static psGlobalType PsGlobal;
#define PSGLOBAL(var) (((psGlobalType *)(RsGlobal.ps))->var)
@@ -107,14 +103,14 @@ IMediaSeeking *pMS = nil;
DWORD dwDXVersion;
DWORD _dwMemTotalPhys;
-DWORD &_dwMemAvailPhys = *(DWORD*)0x70F29C;
+DWORD _dwMemAvailPhys;
DWORD _dwMemTotalVirtual;
DWORD _dwMemAvailVirtual;
-DWORD &_dwMemTotalVideo = *(DWORD*)0x70F2A8;
+DWORD _dwMemTotalVideo;
DWORD _dwMemAvailVideo;
-DWORD &_dwOperatingSystemVersion = *(DWORD*)0x70F290;
+DWORD _dwOperatingSystemVersion;
-RwUInt32 &gGameState = *(RwUInt32*)0x8F5838;
+RwUInt32 gGameState;
CJoySticks AllValidWinJoys;
CJoySticks::CJoySticks()
@@ -679,11 +675,17 @@ psInitialise(void)
_dwMemAvailVirtual = memstats.dwAvailVirtual;
_GetVideoMemInfo(&_dwMemTotalVideo, &_dwMemAvailVideo);
-
+#ifdef FIX_BUGS
+ debug("Physical memory size %u\n", _dwMemTotalPhys);
+ debug("Available physical memory %u\n", _dwMemAvailPhys);
+ debug("Video memory size %u\n", _dwMemTotalVideo);
+ debug("Available video memory %u\n", _dwMemAvailVideo);
+#else
debug("Physical memory size %d\n", _dwMemTotalPhys);
debug("Available physical memory %d\n", _dwMemAvailPhys);
debug("Video memory size %d\n", _dwMemTotalVideo);
debug("Available video memory %d\n", _dwMemAvailVideo);
+#endif
if ( _dwMemAvailVideo < (12 * 1024 * 1024) /*12 MB*/ )
{
@@ -1321,12 +1323,23 @@ psSelectDevice()
}
else
{
+#ifdef DEFAULT_NATIVE_RESOLUTION
+ // get the native video mode
+ HDC hDevice = GetDC(NULL);
+ int w = GetDeviceCaps(hDevice, HORZRES);
+ int h = GetDeviceCaps(hDevice, VERTRES);
+ int d = GetDeviceCaps(hDevice, BITSPIXEL);
+#else
+ const int w = 640;
+ const int h = 480;
+ const int d = 16;
+#endif
while ( !modeFound && GcurSelVM < RwEngineGetNumVideoModes() )
{
RwEngineGetVideoModeInfo(&vm, GcurSelVM);
- if ( defaultFullscreenRes && vm.width != 640
- || vm.height != 480
- || vm.depth != 16
+ if ( defaultFullscreenRes && vm.width != w
+ || vm.height != h
+ || vm.depth != d
|| !(vm.flags & rwVIDEOMODEEXCLUSIVE) )
++GcurSelVM;
else
@@ -1335,8 +1348,12 @@ psSelectDevice()
if ( !modeFound )
{
+#ifdef DEFAULT_NATIVE_RESOLUTION
+ GcurSelVM = 1;
+#else
MessageBox(nil, "Cannot find 640x480 video mode", "GTA3", MB_OK);
return FALSE;
+#endif
}
}
}
@@ -1351,7 +1368,7 @@ psSelectDevice()
{
return FALSE;
}
-
+
if (vm.flags & rwVIDEOMODEEXCLUSIVE)
{
debug("%dx%dx%d", vm.width, vm.height, vm.depth);
@@ -1739,7 +1756,7 @@ void HandleExit()
*****************************************************************************
*/
int PASCAL
-_WinMain(HINSTANCE instance,
+WinMain(HINSTANCE instance,
HINSTANCE prevInstance __RWUNUSED__,
CMDSTR cmdLine,
int cmdShow)
@@ -1748,9 +1765,17 @@ _WinMain(HINSTANCE instance,
RwV2d pos;
RwInt32 argc, i;
RwChar **argv;
-
+ StaticPatcher::Apply();
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, nil, SPIF_SENDCHANGE);
+/*
+ // TODO: make this an option somewhere
+ AllocConsole();
+ freopen("CONIN$", "r", stdin);
+ freopen("CONOUT$", "w", stdout);
+ freopen("CONOUT$", "w", stderr);
+*/
+
/*
* Initialize the platform independent data.
* This will in turn initialize the platform specific data...
@@ -1971,7 +1996,7 @@ _WinMain(HINSTANCE instance,
++gGameState;
else if ( CPad::GetPad(0)->GetEnterJustDown() )
++gGameState;
- else if ( CPad::GetPad(0)->GetCharJustDown(VK_SPACE) )
+ else if ( CPad::GetPad(0)->GetCharJustDown(' ') )
++gGameState;
else if ( CPad::GetPad(0)->GetAltJustDown() )
++gGameState;
@@ -2007,7 +2032,7 @@ _WinMain(HINSTANCE instance,
++gGameState;
else if ( CPad::GetPad(0)->GetEnterJustDown() )
++gGameState;
- else if ( CPad::GetPad(0)->GetCharJustDown(VK_SPACE) )
+ else if ( CPad::GetPad(0)->GetCharJustDown(' ') )
++gGameState;
else if ( CPad::GetPad(0)->GetAltJustDown() )
++gGameState;
@@ -3010,60 +3035,4 @@ int strcasecmp(const char *str1, const char *str2)
return _strcmpi(str1, str2);
}
#endif
-
-
-STARTPATCHES
- //InjectHook(0x580B30, &CJoySticks::CJoySticks, PATCH_JUMP);
- //InjectHook(0x580B50, &CJoySticks::ClearJoyInfo, PATCH_JUMP);
- InjectHook(0x580B70, _psCreateFolder, PATCH_JUMP);
- InjectHook(0x580BB0, _psGetUserFilesFolder, PATCH_JUMP);
- InjectHook(0x580C70, psCameraBeginUpdate, PATCH_JUMP);
- InjectHook(0x580CA0, psCameraShowRaster, PATCH_JUMP);
- InjectHook(0x580CE0, psTimer, PATCH_JUMP);
- InjectHook(0x580D20, psMouseSetPos, PATCH_JUMP);
- InjectHook(0x580E10, psGetMemoryFunctions, PATCH_JUMP);
- InjectHook(0x580E20, psInstallFileSystem, PATCH_JUMP);
- InjectHook(0x580E30, psNativeTextureSupport, PATCH_JUMP);
- InjectHook(0x580E40, InitApplication, PATCH_JUMP);
- InjectHook(0x580EB0, InitInstance, PATCH_JUMP);
- InjectHook(0x580F30, _GetVideoMemInfo, PATCH_JUMP);
- InjectHook(0x580FA0, GetDXVersion, PATCH_JUMP);
- InjectHook(0x5810C0, _psGetCpuVendr, PATCH_JUMP);
- InjectHook(0x5810E0, _psGetCpuFeatures, PATCH_JUMP);
- InjectHook(0x5810F0, _psGetCpuFeaturesEx, PATCH_JUMP);
- InjectHook(0x581120, _psPrintCpuInfo, PATCH_JUMP);
- InjectHook(0x581180, psInitialise, PATCH_JUMP);
- InjectHook(0x581460, psTerminate, PATCH_JUMP);
- InjectHook(0x581470, _psGetNumVideModes, PATCH_JUMP);
- InjectHook(0x581480, _psFreeVideoModeList, PATCH_JUMP);
- InjectHook(0x5814F0, _psGetVideoModeList, PATCH_JUMP);
- InjectHook(0x581630, _psSelectScreenVM, PATCH_JUMP);
- InjectHook(0x5816B0, WaitForState, PATCH_JUMP);
- InjectHook(0x5816E0, HandleGraphEvent, PATCH_JUMP);
- InjectHook(0x581790, MainWndProc, PATCH_JUMP);
- InjectHook(0x581C90, IsForegroundApp, PATCH_JUMP);
- InjectHook(0x581CB0, GetBestRefreshRate, PATCH_JUMP);
- InjectHook(0x581D80, psSelectDevice, PATCH_JUMP);
- InjectHook(0x581F90, _psSetVideoMode, PATCH_JUMP);
- InjectHook(0x582030, CommandLineToArgv, PATCH_JUMP);
- InjectHook(0x582160, InitialiseLanguage, PATCH_JUMP);
- InjectHook(0x5822F0, CenterVideo, PATCH_JUMP);
- InjectHook(0x582380, PlayMovieInWindow, PATCH_JUMP);
- InjectHook(0x5825E0, CloseInterfaces, PATCH_JUMP);
- InjectHook(0x582680, CloseClip, PATCH_JUMP);
- InjectHook(0x5826A0, HandleExit, PATCH_JUMP);
- InjectHook(0x582710, _WinMain, PATCH_JUMP);
- InjectHook(0x5830D0, _InputInitialise, PATCH_JUMP);
- InjectHook(0x583110, _InputInitialiseMouse, PATCH_JUMP);
- InjectHook(0x583190, CapturePad, PATCH_JUMP);
- InjectHook(0x583580, _InputInitialiseJoys, PATCH_JUMP);
- InjectHook(0x583670, _InputAddJoyStick, PATCH_JUMP);
- InjectHook(0x583810, _InputAddJoys, PATCH_JUMP);
- InjectHook(0x583870, _InputGetMouseState, PATCH_JUMP);
- InjectHook(0x583910, _InputShutdown, PATCH_JUMP);
- InjectHook(0x583940, _InputEnumDevicesCallback, PATCH_JUMP);
- InjectHook(0x583A20, _InputTranslateKey, PATCH_JUMP);
- InjectHook(0x583DC0, _InputTranslateShiftKeyUpDown, PATCH_JUMP);
- InjectHook(0x583E50, _InputTranslateShiftKey, PATCH_JUMP);
- InjectHook(0x583EE0, _InputIsExtended, PATCH_JUMP);
-ENDPATCHES
+#endif \ No newline at end of file