summaryrefslogtreecommitdiff
path: root/apps/plugins/sdl/progs/quake/sys_null.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/sdl/progs/quake/sys_null.c')
-rw-r--r--apps/plugins/sdl/progs/quake/sys_null.c232
1 files changed, 232 insertions, 0 deletions
diff --git a/apps/plugins/sdl/progs/quake/sys_null.c b/apps/plugins/sdl/progs/quake/sys_null.c
new file mode 100644
index 0000000000..057d61de72
--- /dev/null
+++ b/apps/plugins/sdl/progs/quake/sys_null.c
@@ -0,0 +1,232 @@
1/*
2Copyright (C) 1996-1997 Id Software, Inc.
3
4This program is free software; you can redistribute it and/or
5modify it under the terms of the GNU General Public License
6as published by the Free Software Foundation; either version 2
7of the License, or (at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13See the GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19*/
20// sys_null.h -- null system driver to aid porting efforts
21
22#include "quakedef.h"
23#include "errno.h"
24
25/*
26===============================================================================
27
28FILE IO
29
30===============================================================================
31*/
32
33#define MAX_HANDLES 10
34FILE *sys_handles[MAX_HANDLES];
35
36int findhandle (void)
37{
38 int i;
39
40 for (i=1 ; i<MAX_HANDLES ; i++)
41 if (!sys_handles[i])
42 return i;
43 Sys_Error ("out of handles");
44 return -1;
45}
46
47/*
48================
49filelength
50================
51*/
52int filelength (FILE *f)
53{
54 int pos;
55 int end;
56
57 pos = ftell (f);
58 fseek (f, 0, SEEK_END);
59 end = ftell (f);
60 fseek (f, pos, SEEK_SET);
61
62 return end;
63}
64
65int Sys_FileOpenRead (char *path, int *hndl)
66{
67 FILE *f;
68 int i;
69
70 i = findhandle ();
71
72 f = fopen(path, "rb");
73 if (!f)
74 {
75 *hndl = -1;
76 return -1;
77 }
78 sys_handles[i] = f;
79 *hndl = i;
80
81 return filelength(f);
82}
83
84int Sys_FileOpenWrite (char *path)
85{
86 FILE *f;
87 int i;
88
89 i = findhandle ();
90
91 f = fopen(path, "wb");
92 if (!f)
93 Sys_Error ("Error opening %s: %s", path,strerror(errno));
94 sys_handles[i] = f;
95
96 return i;
97}
98
99void Sys_FileClose (int handle)
100{
101 fclose (sys_handles[handle]);
102 sys_handles[handle] = NULL;
103}
104
105void Sys_FileSeek (int handle, int position)
106{
107 fseek (sys_handles[handle], position, SEEK_SET);
108}
109
110int Sys_FileRead (int handle, void *dest, int count)
111{
112 return fread (dest, 1, count, sys_handles[handle]);
113}
114
115int Sys_FileWrite (int handle, void *data, int count)
116{
117 return fwrite (data, 1, count, sys_handles[handle]);
118}
119
120int Sys_FileTime (char *path)
121{
122 FILE *f;
123
124 f = fopen(path, "rb");
125 if (f)
126 {
127 fclose(f);
128 return 1;
129 }
130
131 return -1;
132}
133
134void Sys_mkdir (char *path)
135{
136}
137
138
139/*
140===============================================================================
141
142SYSTEM IO
143
144===============================================================================
145*/
146
147void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length)
148{
149}
150
151
152void Sys_Error (char *error, ...)
153{
154 va_list argptr;
155
156 printf ("Sys_Error: ");
157 va_start (argptr,error);
158 vprintf (error,argptr);
159 va_end (argptr);
160 printf ("\n");
161
162 exit (1);
163}
164
165void Sys_Printf (char *fmt, ...)
166{
167 va_list argptr;
168
169 va_start (argptr,fmt);
170 vprintf (fmt,argptr);
171 va_end (argptr);
172}
173
174void Sys_Quit (void)
175{
176 exit (0);
177}
178
179double Sys_FloatTime (void)
180{
181 static double t;
182
183 t += 0.1;
184
185 return t;
186}
187
188char *Sys_ConsoleInput (void)
189{
190 return NULL;
191}
192
193void Sys_Sleep (void)
194{
195}
196
197void Sys_SendKeyEvents (void)
198{
199}
200
201void Sys_HighFPPrecision (void)
202{
203}
204
205void Sys_LowFPPrecision (void)
206{
207}
208
209//=============================================================================
210
211void main (int argc, char **argv)
212{
213 static quakeparms_t parms;
214
215 parms.memsize = 8*1024*1024;
216 parms.membase = malloc (parms.memsize);
217 parms.basedir = ".";
218
219 COM_InitArgv (argc, argv);
220
221 parms.argc = com_argc;
222 parms.argv = com_argv;
223
224 printf ("Host_Init\n");
225 Host_Init (&parms);
226 while (1)
227 {
228 Host_Frame (0.1);
229 }
230}
231
232