-
-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 m, n;
-
-// touch all the memory to make sure it's there. The 16-page skip is to
-// keep Win 95 from thinking we're trying to page ourselves in (we are
-// doing that, of course, but there's no reason we shouldn't)
- x = (byte *)ptr;
-
- for (n=0 ; n<4 ; n++)
- {
- for (m=0 ; m<(size - 16 * 0x1000) ; m += 4)
- {
- sys_checksum += *(int *)&x[m];
- sys_checksum += *(int *)&x[m + 16 * 0x1000];
- }
- }
-}
-
-
-/*
-===============================================================================
-
-FILE IO
-
-===============================================================================
-*/
-
-// LordHavoc: 256 pak files (was 10)
-#define MAX_HANDLES 256
-FILE *sys_handles[MAX_HANDLES];
-
-int findhandle (void)
-{
- int i;
-
- for (i=1 ; i<MAX_HANDLES ; i++)
- if (!sys_handles[i])
- return i;
- Sys_Error ("out of handles");
- return -1;
-}
-
-/*
-================
-filelength
-================
-*/
-int filelength (FILE *f)
-{
- int pos;
- int end;
-
- pos = ftell (f);
- fseek (f, 0, SEEK_END);
- end = ftell (f);
- fseek (f, pos, SEEK_SET);
-
- return end;
-}
-
-int Sys_FileOpenRead (char *path, int *hndl)
-{
- FILE *f;
- int i, retval;
-
- i = findhandle ();
-
- f = fopen(path, "rb");
-
- if (!f)
- {
- *hndl = -1;
- retval = -1;
- }
- else
- {
- sys_handles[i] = f;
- *hndl = i;
- retval = filelength(f);
- }
-
- return retval;
-}
-
-int Sys_FileOpenWrite (char *path)
-{
- FILE *f;
- int i;
-
- i = findhandle ();
-
- f = fopen(path, "wb");
- if (!f)
- Host_Error ("Error opening %s: %s", path,strerror(errno));
- sys_handles[i] = f;
-
- return i;
-}
-
-void Sys_FileClose (int handle)
-{
- fclose (sys_handles[handle]);
- sys_handles[handle] = NULL;
-}
-
-void Sys_FileSeek (int handle, int position)
-{
- fseek (sys_handles[handle], position, SEEK_SET);
-}
-
-int Sys_FileRead (int handle, void *dest, int count)
-{
- return fread (dest, 1, count, sys_handles[handle]);
-}
-
-int Sys_FileWrite (int handle, void *data, int count)
-{
- return fwrite (data, 1, count, sys_handles[handle]);
-}
-
-int Sys_FileTime (char *path)
-{
- FILE *f;
- int retval;
-
- f = fopen(path, "rb");
-
- if (f)
- {
- fclose(f);
- retval = 1;
- }
- else
- {
- retval = -1;
- }
-
- return retval;
-}
-
-void Sys_mkdir (char *path)
-{
- _mkdir (path);
-}