#include "conproc.h"
#include "direct.h"
-// LordHavoc: raised min to 24mb (was 8.5mb)
-#define MINIMUM_WIN_MEMORY 0x1800000
-// LordHavoc: raised max to 24mb (was 16mb)
-#define MAXIMUM_WIN_MEMORY 0x1800000
-
#define CONSOLE_ERROR_TIMEOUT 60.0 // # of seconds to wait on Sys_Error running
// dedicated before exiting
#define PAUSE_SLEEP 50 // sleep time on pause or minimization
static HANDLE heventParent;
static HANDLE heventChild;
-void MaskExceptions (void);
void Sys_InitFloatTime (void);
-void Sys_PushFPCW_SetHigh (void);
-void Sys_PopFPCW (void);
volatile int sys_checksum;
Sys_PageIn
================
*/
+/*
void Sys_PageIn (void *ptr, int size)
{
byte *x;
}
}
}
+*/
/*
{
int pos;
int end;
- int t;
-
- t = VID_ForceUnlockedAndReturnState ();
pos = ftell (f);
fseek (f, 0, SEEK_END);
end = ftell (f);
fseek (f, pos, SEEK_SET);
- VID_ForceLockState (t);
-
return end;
}
{
FILE *f;
int i, retval;
- int t;
-
- t = VID_ForceUnlockedAndReturnState ();
i = findhandle ();
retval = filelength(f);
}
- VID_ForceLockState (t);
-
return retval;
}
{
FILE *f;
int i;
- int t;
- t = VID_ForceUnlockedAndReturnState ();
-
i = findhandle ();
f = fopen(path, "wb");
Host_Error ("Error opening %s: %s", path,strerror(errno));
sys_handles[i] = f;
- VID_ForceLockState (t);
-
return i;
}
void Sys_FileClose (int handle)
{
- int t;
-
- t = VID_ForceUnlockedAndReturnState ();
fclose (sys_handles[handle]);
sys_handles[handle] = NULL;
- VID_ForceLockState (t);
}
void Sys_FileSeek (int handle, int position)
{
- int t;
-
- t = VID_ForceUnlockedAndReturnState ();
fseek (sys_handles[handle], position, SEEK_SET);
- VID_ForceLockState (t);
}
int Sys_FileRead (int handle, void *dest, int count)
{
- int t, x;
-
- t = VID_ForceUnlockedAndReturnState ();
- x = fread (dest, 1, count, sys_handles[handle]);
- VID_ForceLockState (t);
- return x;
+ return fread (dest, 1, count, sys_handles[handle]);
}
int Sys_FileWrite (int handle, void *data, int count)
{
- int t, x;
-
- t = VID_ForceUnlockedAndReturnState ();
- x = fwrite (data, 1, count, sys_handles[handle]);
- VID_ForceLockState (t);
- return x;
+ return fwrite (data, 1, count, sys_handles[handle]);
}
int Sys_FileTime (char *path)
{
FILE *f;
- int t, retval;
+ int retval;
- t = VID_ForceUnlockedAndReturnState ();
-
f = fopen(path, "rb");
if (f)
retval = -1;
}
- VID_ForceLockState (t);
return retval;
}
}
-//#ifndef _M_IX86
-
-void Sys_SetFPCW (void)
-{
-}
-
-void Sys_PushFPCW_SetHigh (void)
-{
-}
-
-void Sys_PopFPCW (void)
-{
-}
-
-void MaskExceptions (void)
-{
-}
-
-//#endif
-
/*
================
Sys_Init
unsigned int lowpart, highpart;
OSVERSIONINFO vinfo;
- MaskExceptions ();
- Sys_SetFPCW ();
-
if (!QueryPerformanceFrequency (&PerformanceFreq))
Sys_Error ("No hardware timer available");
// get 32 out of the 64 time bits such that we have around
// 1 microsecond resolution
+#ifdef __BORLANDC__
+ lowpart = (unsigned int)PerformanceFreq.u.LowPart;
+ highpart = (unsigned int)PerformanceFreq.u.HighPart;
+#else
lowpart = (unsigned int)PerformanceFreq.LowPart;
highpart = (unsigned int)PerformanceFreq.HighPart;
- lowshift = 0;
+#endif
+ lowshift = 0;
while (highpart || (lowpart > 2000000.0))
{
static int in_sys_error3 = 0;
if (!in_sys_error3)
- {
in_sys_error3 = 1;
- VID_ForceUnlockedAndReturnState ();
- }
va_start (argptr, error);
vsprintf (text, error, argptr);
void Sys_Quit (void)
{
- VID_ForceUnlockedAndReturnState ();
-
Host_Shutdown();
if (tevent)
unsigned int temp, t2;
double time;
- Sys_PushFPCW_SetHigh ();
-
QueryPerformanceCounter (&PerformanceCount);
+#ifdef __BORLANDC__
+ temp = ((unsigned int)PerformanceCount.u.LowPart >> lowshift) |
+ ((unsigned int)PerformanceCount.u.HighPart << (32 - lowshift));
+#else
+
temp = ((unsigned int)PerformanceCount.LowPart >> lowshift) |
((unsigned int)PerformanceCount.HighPart << (32 - lowshift));
-
+#endif
if (first)
{
oldtime = temp;
}
}
- Sys_PopFPCW ();
-
return curtime;
}
void SleepUntilInput (int time)
{
- MsgWaitForMultipleObjects(1, &tevent, FALSE, time, QS_ALLINPUT);
+ MsgWaitForMultipleObjects(1, &tevent, false, time, QS_ALLINPUT);
}
int global_nCmdShow;
char *argv[MAX_NUM_ARGVS];
static char *empty_string = "";
-HWND hwnd_dialog;
-
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
- quakeparms_t parms;
double time, oldtime, newtime/*, timediff*/;
MEMORYSTATUS lpBuffer;
static char cwd[1024];
int t;
- RECT rect;
/* previous instances do not exist in Win32 */
if (hPrevInstance)
if (cwd[strlen(cwd)-1] == '/')
cwd[strlen(cwd)-1] = 0;
- parms.basedir = cwd;
- parms.cachedir = NULL;
+ host_parms.basedir = cwd;
+ host_parms.cachedir = NULL;
- parms.argc = 1;
+ host_parms.argc = 1;
argv[0] = empty_string;
- while (*lpCmdLine && (parms.argc < MAX_NUM_ARGVS))
+ while (*lpCmdLine && (host_parms.argc < MAX_NUM_ARGVS))
{
while (*lpCmdLine && ((*lpCmdLine <= 32) || (*lpCmdLine > 126)))
lpCmdLine++;
if (*lpCmdLine)
{
- argv[parms.argc] = lpCmdLine;
- parms.argc++;
+ argv[host_parms.argc] = lpCmdLine;
+ host_parms.argc++;
while (*lpCmdLine && ((*lpCmdLine > 32) && (*lpCmdLine <= 126)))
lpCmdLine++;
}
}
- parms.argv = argv;
+ host_parms.argv = argv;
- COM_InitArgv (parms.argc, parms.argv);
+ COM_InitArgv (host_parms.argc, host_parms.argv);
- parms.argc = com_argc;
- parms.argv = com_argv;
+ host_parms.argc = com_argc;
+ host_parms.argv = com_argv;
isDedicated = (COM_CheckParm ("-dedicated") != 0);
- if (!isDedicated)
- {
- hwnd_dialog = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, NULL);
-
- if (hwnd_dialog)
- {
- if (GetWindowRect (hwnd_dialog, &rect))
- {
- if (rect.left > (rect.top * 2))
- {
- SetWindowPos (hwnd_dialog, 0,
- (rect.left / 2) - ((rect.right - rect.left) / 2),
- rect.top, 0, 0,
- SWP_NOZORDER | SWP_NOSIZE);
- }
- }
-
- ShowWindow (hwnd_dialog, SW_SHOWDEFAULT);
- UpdateWindow (hwnd_dialog);
- SetForegroundWindow (hwnd_dialog);
- }
- }
-
// take the greater of all the available memory or half the total memory,
// but at least 8 Mb and no more than 16 Mb, unless they explicitly
// request otherwise
- parms.memsize = lpBuffer.dwAvailPhys;
-
- if (parms.memsize < MINIMUM_WIN_MEMORY)
- parms.memsize = MINIMUM_WIN_MEMORY;
+ /*
+ host_parms.memsize = lpBuffer.dwAvailPhys;
- if (parms.memsize < (lpBuffer.dwTotalPhys >> 1))
- parms.memsize = lpBuffer.dwTotalPhys >> 1;
+ if (host_parms.memsize < MINIMUM_WIN_MEMORY)
+ host_parms.memsize = MINIMUM_WIN_MEMORY;
- if (parms.memsize > MAXIMUM_WIN_MEMORY)
- parms.memsize = MAXIMUM_WIN_MEMORY;
+ if (host_parms.memsize < (lpBuffer.dwTotalPhys >> 1))
+ host_parms.memsize = lpBuffer.dwTotalPhys >> 1;
- if (COM_CheckParm ("-heapsize"))
- {
- t = COM_CheckParm("-heapsize") + 1;
-
- if (t < com_argc)
- parms.memsize = atoi (com_argv[t]) * 1024;
- }
+ if (host_parms.memsize > MAXIMUM_WIN_MEMORY)
+ host_parms.memsize = MAXIMUM_WIN_MEMORY;
+ */
+ host_parms.memsize = DEFAULTMEM * 1048576;
- if (COM_CheckParm ("-mem"))
+ if ((t = COM_CheckParm("-heapsize")))
{
- t = COM_CheckParm("-mem") + 1;
-
+ t++;
if (t < com_argc)
- parms.memsize = atoi (com_argv[t]) * 1048576;
+ host_parms.memsize = atoi (com_argv[t]) * 1024;
}
-
- if (COM_CheckParm ("-winmem"))
+ else if ((t = COM_CheckParm("-mem")) || (t = COM_CheckParm("-winmem")))
{
- t = COM_CheckParm("-winmem") + 1;
-
+ t++;
if (t < com_argc)
- parms.memsize = atoi (com_argv[t]) * 1048576;
+ host_parms.memsize = atoi (com_argv[t]) * 1048576;
}
- parms.membase = malloc (parms.memsize);
+ host_parms.membase = qmalloc(host_parms.memsize);
- if (!parms.membase)
+ if (!host_parms.membase)
Sys_Error ("Not enough memory free; check disk space\n");
- Sys_PageIn (parms.membase, parms.memsize);
+// Sys_PageIn (parms.membase, parms.memsize);
- tevent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ tevent = CreateEvent(NULL, false, false, NULL);
if (!tevent)
Sys_Error ("Couldn't create event");
S_BlockSound ();
Sys_Printf ("Host_Init\n");
- Host_Init (&parms);
+ Host_Init ();
oldtime = Sys_FloatTime ();
}
/* return success of application */
- return TRUE;
+ return true;
}