reaction/code/cgame/cg_syscalls.c

540 lines
13 KiB
C
Raw Normal View History

//-----------------------------------------------------------------------------
//
// $Id$
//
//-----------------------------------------------------------------------------
//
2001-12-31 16:28:42 +00:00
// $Log$
// Revision 1.9 2003/04/19 17:41:26 jbravo
// Applied changes that where in 1.29h -> 1.32b gamecode.
//
// Revision 1.8 2002/06/16 20:06:13 jbravo
// Reindented all the source files with "indent -kr -ut -i8 -l120 -lc120 -sob -bad -bap"
//
2002-01-11 20:20:58 +00:00
// Revision 1.7 2002/01/11 20:20:58 jbravo
// Adding TP to main branch
//
// Revision 1.6 2002/01/11 19:48:29 jbravo
// Formatted the source in non DOS format.
//
2001-12-31 16:28:42 +00:00
// Revision 1.5 2001/12/31 16:28:41 jbravo
// I made a Booboo with the Log tag.
//
//
//-----------------------------------------------------------------------------
2001-05-06 20:50:27 +00:00
// Copyright (C) 1999-2000 Id Software, Inc.
//
// cg_syscalls.c -- this file is only included when building a dll
// cg_syscalls.asm is included instead when building a qvm
#ifdef Q3_VM
#error "Do not use in VM build"
#endif
2001-05-06 20:50:27 +00:00
#include "cg_local.h"
static intptr_t (QDECL *syscall)( intptr_t arg, ... ) = (intptr_t (QDECL *)( intptr_t, ...))-1;
2001-05-06 20:50:27 +00:00
Q_EXPORT void dllEntry( intptr_t (QDECL *syscallptr)( intptr_t arg,... ) ) {
2001-05-06 20:50:27 +00:00
syscall = syscallptr;
}
int PASSFLOAT(float x)
{
2012-01-13 21:27:15 +00:00
floatint_t fi;
2001-05-06 20:50:27 +00:00
2012-01-13 21:27:15 +00:00
fi.f = x;
return fi.i;
2001-05-06 20:50:27 +00:00
}
void trap_Print(const char *fmt)
{
syscall(CG_PRINT, fmt);
2001-05-06 20:50:27 +00:00
}
void trap_Error(const char *fmt)
{
syscall(CG_ERROR, fmt);
2011-07-19 14:50:21 +00:00
exit(1);
2001-05-06 20:50:27 +00:00
}
int trap_Milliseconds(void)
{
return syscall(CG_MILLISECONDS);
2001-05-06 20:50:27 +00:00
}
void trap_Cvar_Register(vmCvar_t * vmCvar, const char *varName, const char *defaultValue, int flags)
{
syscall(CG_CVAR_REGISTER, vmCvar, varName, defaultValue, flags);
2001-05-06 20:50:27 +00:00
}
void trap_Cvar_Update(vmCvar_t * vmCvar)
{
syscall(CG_CVAR_UPDATE, vmCvar);
2001-05-06 20:50:27 +00:00
}
void trap_Cvar_Set(const char *var_name, const char *value)
{
syscall(CG_CVAR_SET, var_name, value);
2001-05-06 20:50:27 +00:00
}
void trap_Cvar_VariableStringBuffer(const char *var_name, char *buffer, int bufsize)
{
syscall(CG_CVAR_VARIABLESTRINGBUFFER, var_name, buffer, bufsize);
2001-05-06 20:50:27 +00:00
}
int trap_Argc(void)
{
return syscall(CG_ARGC);
2001-05-06 20:50:27 +00:00
}
void trap_Argv(int n, char *buffer, int bufferLength)
{
syscall(CG_ARGV, n, buffer, bufferLength);
2001-05-06 20:50:27 +00:00
}
void trap_Args(char *buffer, int bufferLength)
{
syscall(CG_ARGS, buffer, bufferLength);
2001-05-06 20:50:27 +00:00
}
int trap_FS_FOpenFile(const char *qpath, fileHandle_t * f, fsMode_t mode)
{
return syscall(CG_FS_FOPENFILE, qpath, f, mode);
2001-05-06 20:50:27 +00:00
}
void trap_FS_Read(void *buffer, int len, fileHandle_t f)
{
syscall(CG_FS_READ, buffer, len, f);
2001-05-06 20:50:27 +00:00
}
void trap_FS_Write(const void *buffer, int len, fileHandle_t f)
{
syscall(CG_FS_WRITE, buffer, len, f);
2001-05-06 20:50:27 +00:00
}
void trap_FS_FCloseFile(fileHandle_t f)
{
syscall(CG_FS_FCLOSEFILE, f);
2001-05-06 20:50:27 +00:00
}
int trap_FS_Seek(fileHandle_t f, long offset, int origin)
{
return syscall(CG_FS_SEEK, f, offset, origin);
}
void trap_SendConsoleCommand(const char *text)
{
syscall(CG_SENDCONSOLECOMMAND, text);
2001-05-06 20:50:27 +00:00
}
void trap_AddCommand(const char *cmdName)
{
syscall(CG_ADDCOMMAND, cmdName);
2001-05-06 20:50:27 +00:00
}
void trap_RemoveCommand(const char *cmdName)
{
syscall(CG_REMOVECOMMAND, cmdName);
2001-05-06 20:50:27 +00:00
}
void trap_SendClientCommand(const char *s)
{
syscall(CG_SENDCLIENTCOMMAND, s);
2001-05-06 20:50:27 +00:00
}
void trap_UpdateScreen(void)
{
syscall(CG_UPDATESCREEN);
2001-05-06 20:50:27 +00:00
}
void trap_CM_LoadMap(const char *mapname)
{
syscall(CG_CM_LOADMAP, mapname);
2001-05-06 20:50:27 +00:00
}
int trap_CM_NumInlineModels(void)
{
return syscall(CG_CM_NUMINLINEMODELS);
2001-05-06 20:50:27 +00:00
}
clipHandle_t trap_CM_InlineModel(int index)
{
return syscall(CG_CM_INLINEMODEL, index);
2001-05-06 20:50:27 +00:00
}
clipHandle_t trap_CM_TempBoxModel(const vec3_t mins, const vec3_t maxs)
{
return syscall(CG_CM_TEMPBOXMODEL, mins, maxs);
2001-05-06 20:50:27 +00:00
}
clipHandle_t trap_CM_TempCapsuleModel(const vec3_t mins, const vec3_t maxs)
{
return syscall(CG_CM_TEMPCAPSULEMODEL, mins, maxs);
}
int trap_CM_PointContents(const vec3_t p, clipHandle_t model)
{
return syscall(CG_CM_POINTCONTENTS, p, model);
2001-05-06 20:50:27 +00:00
}
int trap_CM_TransformedPointContents(const vec3_t p, clipHandle_t model, const vec3_t origin, const vec3_t angles)
{
return syscall(CG_CM_TRANSFORMEDPOINTCONTENTS, p, model, origin, angles);
2001-05-06 20:50:27 +00:00
}
void trap_CM_BoxTrace(trace_t * results, const vec3_t start, const vec3_t end,
const vec3_t mins, const vec3_t maxs, clipHandle_t model, int brushmask)
{
syscall(CG_CM_BOXTRACE, results, start, end, mins, maxs, model, brushmask);
2001-05-06 20:50:27 +00:00
}
void trap_CM_CapsuleTrace(trace_t * results, const vec3_t start, const vec3_t end,
const vec3_t mins, const vec3_t maxs, clipHandle_t model, int brushmask)
{
syscall(CG_CM_CAPSULETRACE, results, start, end, mins, maxs, model, brushmask);
}
void trap_CM_TransformedBoxTrace(trace_t * results, const vec3_t start, const vec3_t end,
const vec3_t mins, const vec3_t maxs,
clipHandle_t model, int brushmask, const vec3_t origin, const vec3_t angles)
{
syscall(CG_CM_TRANSFORMEDBOXTRACE, results, start, end, mins, maxs, model, brushmask, origin, angles);
2001-05-06 20:50:27 +00:00
}
void trap_CM_TransformedCapsuleTrace(trace_t * results, const vec3_t start, const vec3_t end,
const vec3_t mins, const vec3_t maxs,
clipHandle_t model, int brushmask, const vec3_t origin, const vec3_t angles)
{
syscall(CG_CM_TRANSFORMEDCAPSULETRACE, results, start, end, mins, maxs, model, brushmask, origin, angles);
}
int trap_CM_MarkFragments(int numPoints, const vec3_t * points,
const vec3_t projection,
int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t * fragmentBuffer)
{
return syscall(CG_CM_MARKFRAGMENTS, numPoints, points, projection, maxPoints, pointBuffer, maxFragments,
fragmentBuffer);
2001-05-06 20:50:27 +00:00
}
void trap_S_StartSound(vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx)
{
syscall(CG_S_STARTSOUND, origin, entityNum, entchannel, sfx);
2001-05-06 20:50:27 +00:00
}
void trap_S_StartLocalSound(sfxHandle_t sfx, int channelNum)
{
syscall(CG_S_STARTLOCALSOUND, sfx, channelNum);
2001-05-06 20:50:27 +00:00
}
void trap_S_ClearLoopingSounds(qboolean killall)
{
syscall(CG_S_CLEARLOOPINGSOUNDS, killall);
2001-05-06 20:50:27 +00:00
}
void trap_S_AddLoopingSound(int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx)
{
syscall(CG_S_ADDLOOPINGSOUND, entityNum, origin, velocity, sfx);
2001-05-06 20:50:27 +00:00
}
void trap_S_AddRealLoopingSound(int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx)
{
syscall(CG_S_ADDREALLOOPINGSOUND, entityNum, origin, velocity, sfx);
2001-05-06 20:50:27 +00:00
}
void trap_S_StopLoopingSound(int entityNum)
{
syscall(CG_S_STOPLOOPINGSOUND, entityNum);
2001-05-06 20:50:27 +00:00
}
void trap_S_UpdateEntityPosition(int entityNum, const vec3_t origin)
{
syscall(CG_S_UPDATEENTITYPOSITION, entityNum, origin);
2001-05-06 20:50:27 +00:00
}
void trap_S_Respatialize(int entityNum, const vec3_t origin, vec3_t axis[3], int inwater)
{
syscall(CG_S_RESPATIALIZE, entityNum, origin, axis, inwater);
2001-05-06 20:50:27 +00:00
}
sfxHandle_t trap_S_RegisterSound(const char *sample, qboolean compressed)
{
return syscall(CG_S_REGISTERSOUND, sample, compressed);
2001-05-06 20:50:27 +00:00
}
void trap_S_StartBackgroundTrack(const char *intro, const char *loop)
{
syscall(CG_S_STARTBACKGROUNDTRACK, intro, loop);
2001-05-06 20:50:27 +00:00
}
void trap_R_LoadWorldMap(const char *mapname)
{
syscall(CG_R_LOADWORLDMAP, mapname);
2001-05-06 20:50:27 +00:00
}
qhandle_t trap_R_RegisterModel(const char *name)
{
return syscall(CG_R_REGISTERMODEL, name);
2001-05-06 20:50:27 +00:00
}
qhandle_t trap_R_RegisterSkin(const char *name)
{
return syscall(CG_R_REGISTERSKIN, name);
2001-05-06 20:50:27 +00:00
}
qhandle_t trap_R_RegisterShader(const char *name)
{
return syscall(CG_R_REGISTERSHADER, name);
2001-05-06 20:50:27 +00:00
}
qhandle_t trap_R_RegisterShaderNoMip(const char *name)
{
return syscall(CG_R_REGISTERSHADERNOMIP, name);
2001-05-06 20:50:27 +00:00
}
void trap_R_RegisterFont(const char *fontName, int pointSize, fontInfo_t * font)
{
syscall(CG_R_REGISTERFONT, fontName, pointSize, font);
2001-05-06 20:50:27 +00:00
}
void trap_R_ClearScene(void)
{
syscall(CG_R_CLEARSCENE);
2001-05-06 20:50:27 +00:00
}
void trap_R_AddRefEntityToScene(const refEntity_t * re)
{
syscall(CG_R_ADDREFENTITYTOSCENE, re);
2001-05-06 20:50:27 +00:00
}
void trap_R_AddPolyToScene(qhandle_t hShader, int numVerts, const polyVert_t * verts)
{
syscall(CG_R_ADDPOLYTOSCENE, hShader, numVerts, verts);
2001-05-06 20:50:27 +00:00
}
void trap_R_AddPolysToScene(qhandle_t hShader, int numVerts, const polyVert_t * verts, int num)
{
syscall(CG_R_ADDPOLYSTOSCENE, hShader, numVerts, verts, num);
}
int trap_R_LightForPoint(vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir)
{
return syscall(CG_R_LIGHTFORPOINT, point, ambientLight, directedLight, lightDir);
2001-05-06 20:50:27 +00:00
}
void trap_R_AddLightToScene(const vec3_t org, float intensity, float r, float g, float b)
{
syscall(CG_R_ADDLIGHTTOSCENE, org, PASSFLOAT(intensity), PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b));
2001-05-06 20:50:27 +00:00
}
void trap_R_AddAdditiveLightToScene(const vec3_t org, float intensity, float r, float g, float b)
{
syscall(CG_R_ADDADDITIVELIGHTTOSCENE, org, PASSFLOAT(intensity), PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b));
}
void trap_R_RenderScene(const refdef_t * fd)
{
syscall(CG_R_RENDERSCENE, fd);
2001-05-06 20:50:27 +00:00
}
void trap_R_SetColor(const float *rgba)
{
syscall(CG_R_SETCOLOR, rgba);
2001-05-06 20:50:27 +00:00
}
void trap_R_DrawStretchPic(float x, float y, float w, float h,
float s1, float t1, float s2, float t2, qhandle_t hShader)
{
syscall(CG_R_DRAWSTRETCHPIC, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1),
PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), hShader);
2001-05-06 20:50:27 +00:00
}
void trap_R_ModelBounds(clipHandle_t model, vec3_t mins, vec3_t maxs)
{
syscall(CG_R_MODELBOUNDS, model, mins, maxs);
2001-05-06 20:50:27 +00:00
}
int trap_R_LerpTag(orientation_t * tag, clipHandle_t mod, int startFrame, int endFrame, float frac, const char *tagName)
{
return syscall(CG_R_LERPTAG, tag, mod, startFrame, endFrame, PASSFLOAT(frac), tagName);
2001-05-06 20:50:27 +00:00
}
void trap_R_RemapShader(const char *oldShader, const char *newShader, const char *timeOffset)
{
syscall(CG_R_REMAP_SHADER, oldShader, newShader, timeOffset);
2001-05-06 20:50:27 +00:00
}
void trap_GetGlconfig(glconfig_t * glconfig)
{
syscall(CG_GETGLCONFIG, glconfig);
2001-05-06 20:50:27 +00:00
}
void trap_GetGameState(gameState_t * gamestate)
{
syscall(CG_GETGAMESTATE, gamestate);
2001-05-06 20:50:27 +00:00
}
void trap_GetCurrentSnapshotNumber(int *snapshotNumber, int *serverTime)
{
syscall(CG_GETCURRENTSNAPSHOTNUMBER, snapshotNumber, serverTime);
2001-05-06 20:50:27 +00:00
}
qboolean trap_GetSnapshot(int snapshotNumber, snapshot_t * snapshot)
{
return syscall(CG_GETSNAPSHOT, snapshotNumber, snapshot);
2001-05-06 20:50:27 +00:00
}
qboolean trap_GetServerCommand(int serverCommandNumber)
{
return syscall(CG_GETSERVERCOMMAND, serverCommandNumber);
2001-05-06 20:50:27 +00:00
}
int trap_GetCurrentCmdNumber(void)
{
return syscall(CG_GETCURRENTCMDNUMBER);
2001-05-06 20:50:27 +00:00
}
qboolean trap_GetUserCmd(int cmdNumber, usercmd_t * ucmd)
{
return syscall(CG_GETUSERCMD, cmdNumber, ucmd);
2001-05-06 20:50:27 +00:00
}
void trap_SetUserCmdValue(int stateValue, float sensitivityScale)
{
syscall(CG_SETUSERCMDVALUE, stateValue, PASSFLOAT(sensitivityScale));
2001-05-06 20:50:27 +00:00
}
void testPrintInt(char *string, int i)
{
syscall(CG_TESTPRINTINT, string, i);
2001-05-06 20:50:27 +00:00
}
void testPrintFloat(char *string, float f)
{
syscall(CG_TESTPRINTFLOAT, string, PASSFLOAT(f));
2001-05-06 20:50:27 +00:00
}
int trap_MemoryRemaining(void)
{
return syscall(CG_MEMORY_REMAINING);
2001-05-06 20:50:27 +00:00
}
qboolean trap_Key_IsDown(int keynum)
{
return syscall(CG_KEY_ISDOWN, keynum);
2001-05-06 20:50:27 +00:00
}
int trap_Key_GetCatcher(void)
{
return syscall(CG_KEY_GETCATCHER);
2001-05-06 20:50:27 +00:00
}
void trap_Key_SetCatcher(int catcher)
{
syscall(CG_KEY_SETCATCHER, catcher);
2001-05-06 20:50:27 +00:00
}
int trap_Key_GetKey(const char *binding)
{
return syscall(CG_KEY_GETKEY, binding);
2001-05-06 20:50:27 +00:00
}
int trap_PC_AddGlobalDefine(char *define)
{
return syscall(CG_PC_ADD_GLOBAL_DEFINE, define);
2001-05-06 20:50:27 +00:00
}
int trap_PC_LoadSource(const char *filename)
{
return syscall(CG_PC_LOAD_SOURCE, filename);
2001-05-06 20:50:27 +00:00
}
int trap_PC_FreeSource(int handle)
{
return syscall(CG_PC_FREE_SOURCE, handle);
2001-05-06 20:50:27 +00:00
}
int trap_PC_ReadToken(int handle, pc_token_t * pc_token)
{
return syscall(CG_PC_READ_TOKEN, handle, pc_token);
2001-05-06 20:50:27 +00:00
}
int trap_PC_SourceFileAndLine(int handle, char *filename, int *line)
{
return syscall(CG_PC_SOURCE_FILE_AND_LINE, handle, filename, line);
2001-05-06 20:50:27 +00:00
}
void trap_S_StopBackgroundTrack(void)
{
syscall(CG_S_STOPBACKGROUNDTRACK);
2001-05-06 20:50:27 +00:00
}
int trap_RealTime(qtime_t * qtime)
{
return syscall(CG_REAL_TIME, qtime);
2001-05-06 20:50:27 +00:00
}
void trap_SnapVector(float *v)
{
syscall(CG_SNAPVECTOR, v);
2001-05-06 20:50:27 +00:00
}
// this returns a handle. arg0 is the name in the format "idlogo.roq", set arg1 to NULL, alteredstates to qfalse (do not alter gamestate)
int trap_CIN_PlayCinematic(const char *arg0, int xpos, int ypos, int width, int height, int bits)
{
return syscall(CG_CIN_PLAYCINEMATIC, arg0, xpos, ypos, width, height, bits);
2001-05-06 20:50:27 +00:00
}
2001-05-06 20:50:27 +00:00
// stops playing the cinematic and ends it. should always return FMV_EOF
// cinematics must be stopped in reverse order of when they are started
e_status trap_CIN_StopCinematic(int handle)
{
return syscall(CG_CIN_STOPCINEMATIC, handle);
2001-05-06 20:50:27 +00:00
}
// 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.
e_status trap_CIN_RunCinematic(int handle)
{
return syscall(CG_CIN_RUNCINEMATIC, handle);
2001-05-06 20:50:27 +00:00
}
// draws the current frame
void trap_CIN_DrawCinematic(int handle)
{
syscall(CG_CIN_DRAWCINEMATIC, handle);
2001-05-06 20:50:27 +00:00
}
// allows you to resize the animation dynamically
void trap_CIN_SetExtents(int handle, int x, int y, int w, int h)
{
syscall(CG_CIN_SETEXTENTS, handle, x, y, w, h);
2001-05-06 20:50:27 +00:00
}
/*
qboolean trap_loadCamera( const char *name ) {
return syscall( CG_LOADCAMERA, name );
}
void trap_startCamera(int time) {
syscall(CG_STARTCAMERA, time);
}
qboolean trap_getCameraInfo( int time, vec3_t *origin, vec3_t *angles) {
return syscall( CG_GETCAMERAINFO, time, origin, angles );
}
*/
qboolean trap_GetEntityToken(char *buffer, int bufferSize)
{
return syscall(CG_GET_ENTITY_TOKEN, buffer, bufferSize);
}
qboolean trap_R_inPVS(const vec3_t p1, const vec3_t p2)
{
return syscall(CG_R_INPVS, p1, p2);
2002-01-11 20:20:58 +00:00
}
2011-03-10 18:54:24 +00:00
void trap_RQ3_Key_KeynumToStringBuf(int keynum, char *buf, int buflen)
{
syscall(CG_RQ3_KEY_KEYNUMTOSTRINGBUF, keynum, buf, buflen);
}