2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 // sys_null.h -- null system driver to aid porting efforts
25 #include <sys\types.h>
26 #include <sys\timeb.h>
30 ===============================================================================
34 ===============================================================================
37 // LordHavoc: 256 pak files (was 10)
38 #define MAX_HANDLES 256
39 FILE *sys_handles[MAX_HANDLES];
45 for (i=1 ; i<MAX_HANDLES ; i++)
48 Sys_Error ("out of handles");
57 int filelength (FILE *f)
63 fseek (f, 0, SEEK_END);
65 fseek (f, pos, SEEK_SET);
70 int Sys_FileOpenRead (char *path, int *hndl)
77 f = fopen(path, "rb");
89 int Sys_FileOpenWrite (char *path)
96 f = fopen(path, "wb");
98 Sys_Error ("Error opening %s: %s", path,strerror(errno));
104 void Sys_FileClose (int handle)
106 fclose (sys_handles[handle]);
107 sys_handles[handle] = NULL;
110 void Sys_FileSeek (int handle, int position)
112 fseek (sys_handles[handle], position, SEEK_SET);
115 int Sys_FileRead (int handle, void *dest, int count)
117 return fread (dest, 1, count, sys_handles[handle]);
120 int Sys_FileWrite (int handle, void *data, int count)
122 return fwrite (data, 1, count, sys_handles[handle]);
125 int Sys_FileTime (char *path)
129 f = fopen(path, "rb");
139 void Sys_mkdir (char *path)
145 ===============================================================================
149 ===============================================================================
153 void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length)
159 void Sys_DebugLog(char *file, char *fmt, ...)
163 void Sys_Error (char *error, ...)
168 va_start (argptr,error);
169 vsprintf (text, error,argptr);
172 // MessageBox(NULL, text, "Error", 0 /* MB_OK */ );
173 printf ("ERROR: %s\n", text);
178 void Sys_Printf (char *fmt, ...)
182 va_start (argptr,fmt);
183 vprintf (fmt,argptr);
192 double Sys_FloatTime (void)
195 struct _timeb tstruct;
196 static int starttime;
201 starttime = tstruct.time;
202 t = (tstruct.time-starttime) + tstruct.millitm*0.001;
207 void Sys_Sleep (void)
212 void Sys_SendKeyEvents (void)
216 char *Sys_ConsoleInput (void)
218 static char text[256];
220 INPUT_RECORD recs[1024];
248 if (len == sizeof(text))
265 int main (int argc, char **argv)
268 double time, oldtime;
269 static char cwd[1024];
271 memset (&host_parms, 0, sizeof(host_parms));
273 host_parms.memsize = DEFAULTMEM * 1024*1024;
274 host_parms.membase = qmalloc(parms.memsize);
276 _getcwd (cwd, sizeof(cwd));
277 if (cwd[strlen(cwd)-1] == '\\')
278 cwd[strlen(cwd)-1] = 0;
279 host_parms.basedir = cwd;
281 COM_InitArgv (argc, argv);
283 // dedicated server ONLY!
284 if (!COM_CheckParm ("-dedicated"))
286 memcpy (newargv, argv, argc*4);
287 newargv[argc] = "-dedicated";
290 COM_InitArgv (argc, argv);
293 host_parms.argc = argc;
294 host_parms.argv = argv;
296 printf ("Host_Init\n");
299 oldtime = Sys_FloatTime ();
301 /* main window message loop */
304 time = Sys_FloatTime();
305 if (time - oldtime < sys_ticrate.value )
311 Host_Frame ( time - oldtime );
315 /* return success of application */