| 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 |
#include "ui_local.h" |
| 24 |
|
| 25 |
// this file is only included when building a dll |
| 26 |
// syscalls.asm is included instead when building a qvm |
| 27 |
#ifdef Q3_VM |
| 28 |
#error "Do not use in VM build" |
| 29 |
#endif |
| 30 |
|
| 31 |
static intptr_t (QDECL *syscall)( intptr_t arg, ... ) = (intptr_t (QDECL *)( intptr_t, ...))-1; |
| 32 |
|
| 33 |
void dllEntry( intptr_t (QDECL *syscallptr)( intptr_t arg,... ) ) { |
| 34 |
syscall = syscallptr; |
| 35 |
} |
| 36 |
|
| 37 |
int PASSFLOAT( float x ) { |
| 38 |
float floatTemp; |
| 39 |
floatTemp = x; |
| 40 |
return *(int *)&floatTemp; |
| 41 |
} |
| 42 |
|
| 43 |
void trap_Print( const char *string ) { |
| 44 |
syscall( UI_PRINT, string ); |
| 45 |
} |
| 46 |
|
| 47 |
void trap_Error( const char *string ) { |
| 48 |
syscall( UI_ERROR, string ); |
| 49 |
} |
| 50 |
|
| 51 |
int trap_Milliseconds( void ) { |
| 52 |
return syscall( UI_MILLISECONDS ); |
| 53 |
} |
| 54 |
|
| 55 |
void trap_Cvar_Register( vmCvar_t *cvar, const char *var_name, const char *value, int flags ) { |
| 56 |
syscall( UI_CVAR_REGISTER, cvar, var_name, value, flags ); |
| 57 |
} |
| 58 |
|
| 59 |
void trap_Cvar_Update( vmCvar_t *cvar ) { |
| 60 |
syscall( UI_CVAR_UPDATE, cvar ); |
| 61 |
} |
| 62 |
|
| 63 |
void trap_Cvar_Set( const char *var_name, const char *value ) { |
| 64 |
syscall( UI_CVAR_SET, var_name, value ); |
| 65 |
} |
| 66 |
|
| 67 |
float trap_Cvar_VariableValue( const char *var_name ) { |
| 68 |
int temp; |
| 69 |
temp = syscall( UI_CVAR_VARIABLEVALUE, var_name ); |
| 70 |
return (*(float*)&temp); |
| 71 |
} |
| 72 |
|
| 73 |
void trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize ) { |
| 74 |
syscall( UI_CVAR_VARIABLESTRINGBUFFER, var_name, buffer, bufsize ); |
| 75 |
} |
| 76 |
|
| 77 |
void trap_Cvar_SetValue( const char *var_name, float value ) { |
| 78 |
syscall( UI_CVAR_SETVALUE, var_name, PASSFLOAT( value ) ); |
| 79 |
} |
| 80 |
|
| 81 |
void trap_Cvar_Reset( const char *name ) { |
| 82 |
syscall( UI_CVAR_RESET, name ); |
| 83 |
} |
| 84 |
|
| 85 |
void trap_Cvar_Create( const char *var_name, const char *var_value, int flags ) { |
| 86 |
syscall( UI_CVAR_CREATE, var_name, var_value, flags ); |
| 87 |
} |
| 88 |
|
| 89 |
void trap_Cvar_InfoStringBuffer( int bit, char *buffer, int bufsize ) { |
| 90 |
syscall( UI_CVAR_INFOSTRINGBUFFER, bit, buffer, bufsize ); |
| 91 |
} |
| 92 |
|
| 93 |
int trap_Argc( void ) { |
| 94 |
return syscall( UI_ARGC ); |
| 95 |
} |
| 96 |
|
| 97 |
void trap_Argv( int n, char *buffer, int bufferLength ) { |
| 98 |
syscall( UI_ARGV, n, buffer, bufferLength ); |
| 99 |
} |
| 100 |
|
| 101 |
void trap_Cmd_ExecuteText( int exec_when, const char *text ) { |
| 102 |
syscall( UI_CMD_EXECUTETEXT, exec_when, text ); |
| 103 |
} |
| 104 |
|
| 105 |
int trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode ) { |
| 106 |
return syscall( UI_FS_FOPENFILE, qpath, f, mode ); |
| 107 |
} |
| 108 |
|
| 109 |
void trap_FS_Read( void *buffer, int len, fileHandle_t f ) { |
| 110 |
syscall( UI_FS_READ, buffer, len, f ); |
| 111 |
} |
| 112 |
|
| 113 |
void trap_FS_Write( const void *buffer, int len, fileHandle_t f ) { |
| 114 |
syscall( UI_FS_WRITE, buffer, len, f ); |
| 115 |
} |
| 116 |
|
| 117 |
void trap_FS_FCloseFile( fileHandle_t f ) { |
| 118 |
syscall( UI_FS_FCLOSEFILE, f ); |
| 119 |
} |
| 120 |
|
| 121 |
int trap_FS_GetFileList( const char *path, const char *extension, char *listbuf, int bufsize ) { |
| 122 |
return syscall( UI_FS_GETFILELIST, path, extension, listbuf, bufsize ); |
| 123 |
} |
| 124 |
|
| 125 |
int trap_FS_Seek( fileHandle_t f, long offset, int origin ) { |
| 126 |
return syscall( UI_FS_SEEK, f, offset, origin ); |
| 127 |
} |
| 128 |
|
| 129 |
qhandle_t trap_R_RegisterModel( const char *name ) { |
| 130 |
return syscall( UI_R_REGISTERMODEL, name ); |
| 131 |
} |
| 132 |
|
| 133 |
qhandle_t trap_R_RegisterSkin( const char *name ) { |
| 134 |
return syscall( UI_R_REGISTERSKIN, name ); |
| 135 |
} |
| 136 |
|
| 137 |
void trap_R_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) { |
| 138 |
syscall( UI_R_REGISTERFONT, fontName, pointSize, font ); |
| 139 |
} |
| 140 |
|
| 141 |
qhandle_t trap_R_RegisterShaderNoMip( const char *name ) { |
| 142 |
return syscall( UI_R_REGISTERSHADERNOMIP, name ); |
| 143 |
} |
| 144 |
|
| 145 |
void trap_R_ClearScene( void ) { |
| 146 |
syscall( UI_R_CLEARSCENE ); |
| 147 |
} |
| 148 |
|
| 149 |
void trap_R_AddRefEntityToScene( const refEntity_t *re ) { |
| 150 |
syscall( UI_R_ADDREFENTITYTOSCENE, re ); |
| 151 |
} |
| 152 |
|
| 153 |
void trap_R_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts ) { |
| 154 |
syscall( UI_R_ADDPOLYTOSCENE, hShader, numVerts, verts ); |
| 155 |
} |
| 156 |
|
| 157 |
void trap_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ) { |
| 158 |
syscall( UI_R_ADDLIGHTTOSCENE, org, PASSFLOAT(intensity), PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b) ); |
| 159 |
} |
| 160 |
|
| 161 |
void trap_R_RenderScene( const refdef_t *fd ) { |
| 162 |
syscall( UI_R_RENDERSCENE, fd ); |
| 163 |
} |
| 164 |
|
| 165 |
void trap_R_SetColor( const float *rgba ) { |
| 166 |
syscall( UI_R_SETCOLOR, rgba ); |
| 167 |
} |
| 168 |
|
| 169 |
void trap_R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ) { |
| 170 |
syscall( UI_R_DRAWSTRETCHPIC, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), hShader ); |
| 171 |
} |
| 172 |
|
| 173 |
void trap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs ) { |
| 174 |
syscall( UI_R_MODELBOUNDS, model, mins, maxs ); |
| 175 |
} |
| 176 |
|
| 177 |
void trap_UpdateScreen( void ) { |
| 178 |
syscall( UI_UPDATESCREEN ); |
| 179 |
} |
| 180 |
|
| 181 |
int trap_CM_LerpTag( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame, float frac, const char *tagName ) { |
| 182 |
return syscall( UI_CM_LERPTAG, tag, mod, startFrame, endFrame, PASSFLOAT(frac), tagName ); |
| 183 |
} |
| 184 |
|
| 185 |
void trap_S_StartLocalSound( sfxHandle_t sfx, int channelNum ) { |
| 186 |
syscall( UI_S_STARTLOCALSOUND, sfx, channelNum ); |
| 187 |
} |
| 188 |
|
| 189 |
sfxHandle_t trap_S_RegisterSound( const char *sample, qboolean compressed ) { |
| 190 |
return syscall( UI_S_REGISTERSOUND, sample, compressed ); |
| 191 |
} |
| 192 |
|
| 193 |
void trap_Key_KeynumToStringBuf( int keynum, char *buf, int buflen ) { |
| 194 |
syscall( UI_KEY_KEYNUMTOSTRINGBUF, keynum, buf, buflen ); |
| 195 |
} |
| 196 |
|
| 197 |
void trap_Key_GetBindingBuf( int keynum, char *buf, int buflen ) { |
| 198 |
syscall( UI_KEY_GETBINDINGBUF, keynum, buf, buflen ); |
| 199 |
} |
| 200 |
|
| 201 |
void trap_Key_SetBinding( int keynum, const char *binding ) { |
| 202 |
syscall( UI_KEY_SETBINDING, keynum, binding ); |
| 203 |
} |
| 204 |
|
| 205 |
qboolean trap_Key_IsDown( int keynum ) { |
| 206 |
return syscall( UI_KEY_ISDOWN, keynum ); |
| 207 |
} |
| 208 |
|
| 209 |
qboolean trap_Key_GetOverstrikeMode( void ) { |
| 210 |
return syscall( UI_KEY_GETOVERSTRIKEMODE ); |
| 211 |
} |
| 212 |
|
| 213 |
void trap_Key_SetOverstrikeMode( qboolean state ) { |
| 214 |
syscall( UI_KEY_SETOVERSTRIKEMODE, state ); |
| 215 |
} |
| 216 |
|
| 217 |
void trap_Key_ClearStates( void ) { |
| 218 |
syscall( UI_KEY_CLEARSTATES ); |
| 219 |
} |
| 220 |
|
| 221 |
int trap_Key_GetCatcher( void ) { |
| 222 |
return syscall( UI_KEY_GETCATCHER ); |
| 223 |
} |
| 224 |
|
| 225 |
void trap_Key_SetCatcher( int catcher ) { |
| 226 |
syscall( UI_KEY_SETCATCHER, catcher ); |
| 227 |
} |
| 228 |
|
| 229 |
void trap_GetClipboardData( char *buf, int bufsize ) { |
| 230 |
syscall( UI_GETCLIPBOARDDATA, buf, bufsize ); |
| 231 |
} |
| 232 |
|
| 233 |
void trap_GetClientState( uiClientState_t *state ) { |
| 234 |
syscall( UI_GETCLIENTSTATE, state ); |
| 235 |
} |
| 236 |
|
| 237 |
void trap_GetGlconfig( glconfig_t *glconfig ) { |
| 238 |
syscall( UI_GETGLCONFIG, glconfig ); |
| 239 |
} |
| 240 |
|
| 241 |
int trap_GetConfigString( int index, char* buff, int buffsize ) { |
| 242 |
return syscall( UI_GETCONFIGSTRING, index, buff, buffsize ); |
| 243 |
} |
| 244 |
|
| 245 |
int trap_LAN_GetServerCount( int source ) { |
| 246 |
return syscall( UI_LAN_GETSERVERCOUNT, source ); |
| 247 |
} |
| 248 |
|
| 249 |
void trap_LAN_GetServerAddressString( int source, int n, char *buf, int buflen ) { |
| 250 |
syscall( UI_LAN_GETSERVERADDRESSSTRING, source, n, buf, buflen ); |
| 251 |
} |
| 252 |
|
| 253 |
void trap_LAN_GetServerInfo( int source, int n, char *buf, int buflen ) { |
| 254 |
syscall( UI_LAN_GETSERVERINFO, source, n, buf, buflen ); |
| 255 |
} |
| 256 |
|
| 257 |
int trap_LAN_GetServerPing( int source, int n ) { |
| 258 |
return syscall( UI_LAN_GETSERVERPING, source, n ); |
| 259 |
} |
| 260 |
|
| 261 |
int trap_LAN_GetPingQueueCount( void ) { |
| 262 |
return syscall( UI_LAN_GETPINGQUEUECOUNT ); |
| 263 |
} |
| 264 |
|
| 265 |
int trap_LAN_ServerStatus( const char *serverAddress, char *serverStatus, int maxLen ) { |
| 266 |
return syscall( UI_LAN_SERVERSTATUS, serverAddress, serverStatus, maxLen ); |
| 267 |
} |
| 268 |
|
| 269 |
void trap_LAN_SaveCachedServers( void ) { |
| 270 |
syscall( UI_LAN_SAVECACHEDSERVERS ); |
| 271 |
} |
| 272 |
|
| 273 |
void trap_LAN_LoadCachedServers( void ) { |
| 274 |
syscall( UI_LAN_LOADCACHEDSERVERS ); |
| 275 |
} |
| 276 |
|
| 277 |
void trap_LAN_ResetPings(int n) { |
| 278 |
syscall( UI_LAN_RESETPINGS, n ); |
| 279 |
} |
| 280 |
|
| 281 |
void trap_LAN_ClearPing( int n ) { |
| 282 |
syscall( UI_LAN_CLEARPING, n ); |
| 283 |
} |
| 284 |
|
| 285 |
void trap_LAN_GetPing( int n, char *buf, int buflen, int *pingtime ) { |
| 286 |
syscall( UI_LAN_GETPING, n, buf, buflen, pingtime ); |
| 287 |
} |
| 288 |
|
| 289 |
void trap_LAN_GetPingInfo( int n, char *buf, int buflen ) { |
| 290 |
syscall( UI_LAN_GETPINGINFO, n, buf, buflen ); |
| 291 |
} |
| 292 |
|
| 293 |
void trap_LAN_MarkServerVisible( int source, int n, qboolean visible ) { |
| 294 |
syscall( UI_LAN_MARKSERVERVISIBLE, source, n, visible ); |
| 295 |
} |
| 296 |
|
| 297 |
int trap_LAN_ServerIsVisible( int source, int n) { |
| 298 |
return syscall( UI_LAN_SERVERISVISIBLE, source, n ); |
| 299 |
} |
| 300 |
|
| 301 |
qboolean trap_LAN_UpdateVisiblePings( int source ) { |
| 302 |
return syscall( UI_LAN_UPDATEVISIBLEPINGS, source ); |
| 303 |
} |
| 304 |
|
| 305 |
int trap_LAN_AddServer(int source, const char *name, const char *addr) { |
| 306 |
return syscall( UI_LAN_ADDSERVER, source, name, addr ); |
| 307 |
} |
| 308 |
|
| 309 |
void trap_LAN_RemoveServer(int source, const char *addr) { |
| 310 |
syscall( UI_LAN_REMOVESERVER, source, addr ); |
| 311 |
} |
| 312 |
|
| 313 |
int trap_LAN_CompareServers( int source, int sortKey, int sortDir, int s1, int s2 ) { |
| 314 |
return syscall( UI_LAN_COMPARESERVERS, source, sortKey, sortDir, s1, s2 ); |
| 315 |
} |
| 316 |
|
| 317 |
int trap_MemoryRemaining( void ) { |
| 318 |
return syscall( UI_MEMORY_REMAINING ); |
| 319 |
} |
| 320 |
|
| 321 |
void trap_GetCDKey( char *buf, int buflen ) { |
| 322 |
syscall( UI_GET_CDKEY, buf, buflen ); |
| 323 |
} |
| 324 |
|
| 325 |
void trap_SetCDKey( char *buf ) { |
| 326 |
syscall( UI_SET_CDKEY, buf ); |
| 327 |
} |
| 328 |
|
| 329 |
int trap_PC_AddGlobalDefine( char *define ) { |
| 330 |
return syscall( UI_PC_ADD_GLOBAL_DEFINE, define ); |
| 331 |
} |
| 332 |
|
| 333 |
int trap_PC_LoadSource( const char *filename ) { |
| 334 |
return syscall( UI_PC_LOAD_SOURCE, filename ); |
| 335 |
} |
| 336 |
|
| 337 |
int trap_PC_FreeSource( int handle ) { |
| 338 |
return syscall( UI_PC_FREE_SOURCE, handle ); |
| 339 |
} |
| 340 |
|
| 341 |
int trap_PC_ReadToken( int handle, pc_token_t *pc_token ) { |
| 342 |
return syscall( UI_PC_READ_TOKEN, handle, pc_token ); |
| 343 |
} |
| 344 |
|
| 345 |
int trap_PC_SourceFileAndLine( int handle, char *filename, int *line ) { |
| 346 |
return syscall( UI_PC_SOURCE_FILE_AND_LINE, handle, filename, line ); |
| 347 |
} |
| 348 |
|
| 349 |
void trap_S_StopBackgroundTrack( void ) { |
| 350 |
syscall( UI_S_STOPBACKGROUNDTRACK ); |
| 351 |
} |
| 352 |
|
| 353 |
void trap_S_StartBackgroundTrack( const char *intro, const char *loop) { |
| 354 |
syscall( UI_S_STARTBACKGROUNDTRACK, intro, loop ); |
| 355 |
} |
| 356 |
|
| 357 |
int trap_RealTime(qtime_t *qtime) { |
| 358 |
return syscall( UI_REAL_TIME, qtime ); |
| 359 |
} |
| 360 |
|
| 361 |
// this returns a handle. arg0 is the name in the format "idlogo.roq", set arg1 to NULL, alteredstates to qfalse (do not alter gamestate) |
| 362 |
int trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits) { |
| 363 |
return syscall(UI_CIN_PLAYCINEMATIC, arg0, xpos, ypos, width, height, bits); |
| 364 |
} |
| 365 |
|
| 366 |
// stops playing the cinematic and ends it. should always return FMV_EOF |
| 367 |
// cinematics must be stopped in reverse order of when they are started |
| 368 |
e_status trap_CIN_StopCinematic(int handle) { |
| 369 |
return syscall(UI_CIN_STOPCINEMATIC, handle); |
| 370 |
} |
| 371 |
|
| 372 |
|
| 373 |
// 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. |
| 374 |
e_status trap_CIN_RunCinematic (int handle) { |
| 375 |
return syscall(UI_CIN_RUNCINEMATIC, handle); |
| 376 |
} |
| 377 |
|
| 378 |
|
| 379 |
// draws the current frame |
| 380 |
void trap_CIN_DrawCinematic (int handle) { |
| 381 |
syscall(UI_CIN_DRAWCINEMATIC, handle); |
| 382 |
} |
| 383 |
|
| 384 |
|
| 385 |
// allows you to resize the animation dynamically |
| 386 |
void trap_CIN_SetExtents (int handle, int x, int y, int w, int h) { |
| 387 |
syscall(UI_CIN_SETEXTENTS, handle, x, y, w, h); |
| 388 |
} |
| 389 |
|
| 390 |
|
| 391 |
void trap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset ) { |
| 392 |
syscall( UI_R_REMAP_SHADER, oldShader, newShader, timeOffset ); |
| 393 |
} |
| 394 |
|
| 395 |
qboolean trap_VerifyCDKey( const char *key, const char *chksum) { |
| 396 |
return syscall( UI_VERIFY_CDKEY, key, chksum); |
| 397 |
} |
| 398 |
|
| 399 |
void trap_SetPbClStatus( int status ) { |
| 400 |
syscall( UI_SET_PBCLSTATUS, status ); |
| 401 |
} |