Debian Codegraph @

code/cgame/cg_syscalls.c

raw ◀ ▶
1 Debian patch touch this file
1 /*
2 ===========================================================================
3 Copyright (C) 1999-2005 Id Software, Inc.
4
5 This file is part of Quake III Arena source code.
6
7 Quake III Arena source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
11
12 Quake III Arena source code is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Quake III Arena source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ===========================================================================
21 */
22 //
23 // cg_syscalls.c -- this file is only included when building a dll
24 // cg_syscalls.asm is included instead when building a qvm
25 #ifdef Q3_VM
26 #error "Do not use in VM build"
27 #endif
28
29 #include "cg_local.h"
30
31 static intptr_t (QDECL *syscall)( intptr_t arg, ... ) = (intptr_t (QDECL *)( intptr_t, ...))-1;
32
33
•34 Q_EXPORT void dllEntry( intptr_t (QDECL *syscallptr)( intptr_t arg,... ) ) {
35 syscall = syscallptr;
36 }
37
38
39 int PASSFLOAT( float x ) {
40 float floatTemp;
41 floatTemp = x;
42 return *(int *)&floatTemp;
43 }
44
45 void trap_Print( const char *fmt ) {
46 syscall( CG_PRINT, fmt );
47 }
48
49 void trap_Error( const char *fmt ) {
50 syscall( CG_ERROR, fmt );
51 exit(CG_ERROR); //Will never occour but makes compiler happy
52 }
53
54 int trap_Milliseconds( void ) {
55 return syscall( CG_MILLISECONDS );
56 }
57
58 void trap_Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags ) {
59 syscall( CG_CVAR_REGISTER, vmCvar, varName, defaultValue, flags );
60 }
61
62 void trap_Cvar_Update( vmCvar_t *vmCvar ) {
63 syscall( CG_CVAR_UPDATE, vmCvar );
64 }
65
66 void trap_Cvar_Set( const char *var_name, const char *value ) {
67 syscall( CG_CVAR_SET, var_name, value );
68 }
69
70 void trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize ) {
71 syscall( CG_CVAR_VARIABLESTRINGBUFFER, var_name, buffer, bufsize );
72 }
73
74 int trap_Argc( void ) {
75 return syscall( CG_ARGC );
76 }
77
78 void trap_Argv( int n, char *buffer, int bufferLength ) {
79 syscall( CG_ARGV, n, buffer, bufferLength );
80 }
81
82 void trap_Args( char *buffer, int bufferLength ) {
83 syscall( CG_ARGS, buffer, bufferLength );
84 }
85
86 int trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode ) {
87 return syscall( CG_FS_FOPENFILE, qpath, f, mode );
88 }
89
90 void trap_FS_Read( void *buffer, int len, fileHandle_t f ) {
91 syscall( CG_FS_READ, buffer, len, f );
92 }
93
94 void trap_FS_Write( const void *buffer, int len, fileHandle_t f ) {
95 syscall( CG_FS_WRITE, buffer, len, f );
96 }
97
98 void trap_FS_FCloseFile( fileHandle_t f ) {
99 syscall( CG_FS_FCLOSEFILE, f );
100 }
101
102 int trap_FS_Seek( fileHandle_t f, long offset, int origin ) {
103 return syscall( CG_FS_SEEK, f, offset, origin );
104 }
105
106 void trap_SendConsoleCommand( const char *text ) {
107 syscall( CG_SENDCONSOLECOMMAND, text );
108 }
109
110 void trap_AddCommand( const char *cmdName ) {
111 syscall( CG_ADDCOMMAND, cmdName );
112 }
113
114 void trap_RemoveCommand( const char *cmdName ) {
115 syscall( CG_REMOVECOMMAND, cmdName );
116 }
117
118 void trap_SendClientCommand( const char *s ) {
119 syscall( CG_SENDCLIENTCOMMAND, s );
120 }
121
122 void trap_UpdateScreen( void ) {
123 syscall( CG_UPDATESCREEN );
124 }
125
126 void trap_CM_LoadMap( const char *mapname ) {
127 syscall( CG_CM_LOADMAP, mapname );
128 }
129
130 int trap_CM_NumInlineModels( void ) {
131 return syscall( CG_CM_NUMINLINEMODELS );
132 }
133
134 clipHandle_t trap_CM_InlineModel( int index ) {
135 return syscall( CG_CM_INLINEMODEL, index );
136 }
137
138 clipHandle_t trap_CM_TempBoxModel( const vec3_t mins, const vec3_t maxs ) {
139 return syscall( CG_CM_TEMPBOXMODEL, mins, maxs );
140 }
141
142 clipHandle_t trap_CM_TempCapsuleModel( const vec3_t mins, const vec3_t maxs ) {
143 return syscall( CG_CM_TEMPCAPSULEMODEL, mins, maxs );
144 }
145
146 int trap_CM_PointContents( const vec3_t p, clipHandle_t model ) {
147 return syscall( CG_CM_POINTCONTENTS, p, model );
148 }
149
150 int trap_CM_TransformedPointContents( const vec3_t p, clipHandle_t model, const vec3_t origin, const vec3_t angles ) {
151 return syscall( CG_CM_TRANSFORMEDPOINTCONTENTS, p, model, origin, angles );
152 }
153
154 void trap_CM_BoxTrace( trace_t *results, const vec3_t start, const vec3_t end,
155 const vec3_t mins, const vec3_t maxs,
156 clipHandle_t model, int brushmask ) {
157 syscall( CG_CM_BOXTRACE, results, start, end, mins, maxs, model, brushmask );
158 }
159
160 void trap_CM_CapsuleTrace( trace_t *results, const vec3_t start, const vec3_t end,
161 const vec3_t mins, const vec3_t maxs,
162 clipHandle_t model, int brushmask ) {
163 syscall( CG_CM_CAPSULETRACE, results, start, end, mins, maxs, model, brushmask );
164 }
165
166 void trap_CM_TransformedBoxTrace( trace_t *results, const vec3_t start, const vec3_t end,
167 const vec3_t mins, const vec3_t maxs,
168 clipHandle_t model, int brushmask,
169 const vec3_t origin, const vec3_t angles ) {
170 syscall( CG_CM_TRANSFORMEDBOXTRACE, results, start, end, mins, maxs, model, brushmask, origin, angles );
171 }
172
173 void trap_CM_TransformedCapsuleTrace( trace_t *results, const vec3_t start, const vec3_t end,
174 const vec3_t mins, const vec3_t maxs,
175 clipHandle_t model, int brushmask,
176 const vec3_t origin, const vec3_t angles ) {
177 syscall( CG_CM_TRANSFORMEDCAPSULETRACE, results, start, end, mins, maxs, model, brushmask, origin, angles );
178 }
179
180 int trap_CM_MarkFragments( int numPoints, const vec3_t *points,
181 const vec3_t projection,
182 int maxPoints, vec3_t pointBuffer,
183 int maxFragments, markFragment_t *fragmentBuffer ) {
184 return syscall( CG_CM_MARKFRAGMENTS, numPoints, points, projection, maxPoints, pointBuffer, maxFragments, fragmentBuffer );
185 }
186
187 void trap_S_StartSound( vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx ) {
188 syscall( CG_S_STARTSOUND, origin, entityNum, entchannel, sfx );
189 }
190
191 void trap_S_StartLocalSound( sfxHandle_t sfx, int channelNum ) {
192 syscall( CG_S_STARTLOCALSOUND, sfx, channelNum );
193 }
194
195 void trap_S_ClearLoopingSounds( qboolean killall ) {
196 syscall( CG_S_CLEARLOOPINGSOUNDS, killall );
197 }
198
199 void trap_S_AddLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx ) {
200 syscall( CG_S_ADDLOOPINGSOUND, entityNum, origin, velocity, sfx );
201 }
202
203 void trap_S_AddRealLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx ) {
204 syscall( CG_S_ADDREALLOOPINGSOUND, entityNum, origin, velocity, sfx );
205 }
206
207 void trap_S_StopLoopingSound( int entityNum ) {
208 syscall( CG_S_STOPLOOPINGSOUND, entityNum );
209 }
210
211 void trap_S_UpdateEntityPosition( int entityNum, const vec3_t origin ) {
212 syscall( CG_S_UPDATEENTITYPOSITION, entityNum, origin );
213 }
214
215 void trap_S_Respatialize( int entityNum, const vec3_t origin, vec3_t axis[3], int inwater ) {
216 syscall( CG_S_RESPATIALIZE, entityNum, origin, axis, inwater );
217 }
218
219 sfxHandle_t trap_S_RegisterSound( const char *sample, qboolean compressed ) {
220 return syscall( CG_S_REGISTERSOUND, sample, compressed );
221 }
222
223 void trap_S_StartBackgroundTrack( const char *intro, const char *loop ) {
224 syscall( CG_S_STARTBACKGROUNDTRACK, intro, loop );
225 }
226
227 void trap_R_LoadWorldMap( const char *mapname ) {
228 syscall( CG_R_LOADWORLDMAP, mapname );
229 }
230
231 qhandle_t trap_R_RegisterModel( const char *name ) {
232 return syscall( CG_R_REGISTERMODEL, name );
233 }
234
235 qhandle_t trap_R_RegisterSkin( const char *name ) {
236 return syscall( CG_R_REGISTERSKIN, name );
237 }
238
239 qhandle_t trap_R_RegisterShader( const char *name ) {
240 return syscall( CG_R_REGISTERSHADER, name );
241 }
242
243 qhandle_t trap_R_RegisterShaderNoMip( const char *name ) {
244 return syscall( CG_R_REGISTERSHADERNOMIP, name );
245 }
246
247 void trap_R_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {
248 syscall(CG_R_REGISTERFONT, fontName, pointSize, font );
249 }
250
251 void trap_R_ClearScene( void ) {
252 syscall( CG_R_CLEARSCENE );
253 }
254
255 void trap_R_AddRefEntityToScene( const refEntity_t *re ) {
256 syscall( CG_R_ADDREFENTITYTOSCENE, re );
257 }
258
259 void trap_R_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts ) {
260 syscall( CG_R_ADDPOLYTOSCENE, hShader, numVerts, verts );
261 }
262
263 void trap_R_AddPolysToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts, int num ) {
264 syscall( CG_R_ADDPOLYSTOSCENE, hShader, numVerts, verts, num );
265 }
266
267 int trap_R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir ) {
268 return syscall( CG_R_LIGHTFORPOINT, point, ambientLight, directedLight, lightDir );
269 }
270
271 void trap_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ) {
272 syscall( CG_R_ADDLIGHTTOSCENE, org, PASSFLOAT(intensity), PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b) );
273 }
274
275 void trap_R_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, float g, float b ) {
276 syscall( CG_R_ADDADDITIVELIGHTTOSCENE, org, PASSFLOAT(intensity), PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b) );
277 }
278
279 void trap_R_RenderScene( const refdef_t *fd ) {
280 syscall( CG_R_RENDERSCENE, fd );
281 }
282
283 void trap_R_SetColor( const float *rgba ) {
284 syscall( CG_R_SETCOLOR, rgba );
285 }
286
287 void trap_R_DrawStretchPic( float x, float y, float w, float h,
288 float s1, float t1, float s2, float t2, qhandle_t hShader ) {
289 syscall( CG_R_DRAWSTRETCHPIC, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), hShader );
290 }
291
292 void trap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs ) {
293 syscall( CG_R_MODELBOUNDS, model, mins, maxs );
294 }
295
296 int trap_R_LerpTag( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame,
297 float frac, const char *tagName ) {
298 return syscall( CG_R_LERPTAG, tag, mod, startFrame, endFrame, PASSFLOAT(frac), tagName );
299 }
300
301 void trap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset ) {
302 syscall( CG_R_REMAP_SHADER, oldShader, newShader, timeOffset );
303 }
304
305 void trap_GetGlconfig( glconfig_t *glconfig ) {
306 syscall( CG_GETGLCONFIG, glconfig );
307 }
308
309 void trap_GetGameState( gameState_t *gamestate ) {
310 syscall( CG_GETGAMESTATE, gamestate );
311 }
312
313 void trap_GetCurrentSnapshotNumber( int *snapshotNumber, int *serverTime ) {
314 syscall( CG_GETCURRENTSNAPSHOTNUMBER, snapshotNumber, serverTime );
315 }
316
317 qboolean trap_GetSnapshot( int snapshotNumber, snapshot_t *snapshot ) {
318 return syscall( CG_GETSNAPSHOT, snapshotNumber, snapshot );
319 }
320
321 qboolean trap_GetServerCommand( int serverCommandNumber ) {
322 return syscall( CG_GETSERVERCOMMAND, serverCommandNumber );
323 }
324
325 int trap_GetCurrentCmdNumber( void ) {
326 return syscall( CG_GETCURRENTCMDNUMBER );
327 }
328
329 qboolean trap_GetUserCmd( int cmdNumber, usercmd_t *ucmd ) {
330 return syscall( CG_GETUSERCMD, cmdNumber, ucmd );
331 }
332
333 void trap_SetUserCmdValue( int stateValue, float sensitivityScale ) {
334 syscall( CG_SETUSERCMDVALUE, stateValue, PASSFLOAT(sensitivityScale) );
335 }
336
337 void testPrintInt( char *string, int i ) {
338 syscall( CG_TESTPRINTINT, string, i );
339 }
340
341 void testPrintFloat( char *string, float f ) {
342 syscall( CG_TESTPRINTFLOAT, string, PASSFLOAT(f) );
343 }
344
345 int trap_MemoryRemaining( void ) {
346 return syscall( CG_MEMORY_REMAINING );
347 }
348
349 qboolean trap_Key_IsDown( int keynum ) {
350 return syscall( CG_KEY_ISDOWN, keynum );
351 }
352
353 int trap_Key_GetCatcher( void ) {
354 return syscall( CG_KEY_GETCATCHER );
355 }
356
357 void trap_Key_SetCatcher( int catcher ) {
358 syscall( CG_KEY_SETCATCHER, catcher );
359 }
360
361 int trap_Key_GetKey( const char *binding ) {
362 return syscall( CG_KEY_GETKEY, binding );
363 }
364
365 int trap_PC_AddGlobalDefine( char *define ) {
366 return syscall( CG_PC_ADD_GLOBAL_DEFINE, define );
367 }
368
369 int trap_PC_LoadSource( const char *filename ) {
370 return syscall( CG_PC_LOAD_SOURCE, filename );
371 }
372
373 int trap_PC_FreeSource( int handle ) {
374 return syscall( CG_PC_FREE_SOURCE, handle );
375 }
376
377 int trap_PC_ReadToken( int handle, pc_token_t *pc_token ) {
378 return syscall( CG_PC_READ_TOKEN, handle, pc_token );
379 }
380
381 int trap_PC_SourceFileAndLine( int handle, char *filename, int *line ) {
382 return syscall( CG_PC_SOURCE_FILE_AND_LINE, handle, filename, line );
383 }
384
385 void trap_S_StopBackgroundTrack( void ) {
386 syscall( CG_S_STOPBACKGROUNDTRACK );
387 }
388
389 int trap_RealTime(qtime_t *qtime) {
390 return syscall( CG_REAL_TIME, qtime );
391 }
392
393 void trap_SnapVector( float *v ) {
394 syscall( CG_SNAPVECTOR, v );
395 }
396
397 // this returns a handle. arg0 is the name in the format "idlogo.roq", set arg1 to NULL, alteredstates to qfalse (do not alter gamestate)
398 int trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits) {
399 return syscall(CG_CIN_PLAYCINEMATIC, arg0, xpos, ypos, width, height, bits);
400 }
401
402 // stops playing the cinematic and ends it. should always return FMV_EOF
403 // cinematics must be stopped in reverse order of when they are started
404 e_status trap_CIN_StopCinematic(int handle) {
405 return syscall(CG_CIN_STOPCINEMATIC, handle);
406 }
407
408
409 // will run a frame of the cinematic but will not draw it. Will return FMV_EOF if the end of the cinematic has been reached.
410 e_status trap_CIN_RunCinematic (int handle) {
411 return syscall(CG_CIN_RUNCINEMATIC, handle);
412 }
413
414
415 // draws the current frame
416 void trap_CIN_DrawCinematic (int handle) {
417 syscall(CG_CIN_DRAWCINEMATIC, handle);
418 }
419
420
421 // allows you to resize the animation dynamically
422 void trap_CIN_SetExtents (int handle, int x, int y, int w, int h) {
423 syscall(CG_CIN_SETEXTENTS, handle, x, y, w, h);
424 }
425
426 /*
427 qboolean trap_loadCamera( const char *name ) {
428 return syscall( CG_LOADCAMERA, name );
429 }
430
431 void trap_startCamera(int time) {
432 syscall(CG_STARTCAMERA, time);
433 }
434
435 qboolean trap_getCameraInfo( int time, vec3_t *origin, vec3_t *angles) {
436 return syscall( CG_GETCAMERAINFO, time, origin, angles );
437 }
438 */
439
440 qboolean trap_GetEntityToken( char *buffer, int bufferSize ) {
441 return syscall( CG_GET_ENTITY_TOKEN, buffer, bufferSize );
442 }
443
444 qboolean trap_R_inPVS( const vec3_t p1, const vec3_t p2 ) {
445 return syscall( CG_R_INPVS, p1, p2 );
446 }