1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462
|
/*
===========================================================================
Return to Castle Wolfenstein single player GPL Source Code
Copyright (C) 1999-2010 id Software LLC, a ZeniMax Media company.
This file is part of the Return to Castle Wolfenstein single player GPL Source Code (RTCW SP Source Code).
RTCW SP Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
RTCW SP Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with RTCW SP Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the RTCW SP Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the RTCW SP Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "ui_local.h"
// this file is only included when building a dll
// syscalls.asm is included instead when building a qvm
#ifdef Q3_VM
#error "Do not use in VM build"
#endif
static intptr_t (QDECL *syscall)( intptr_t arg, ... ) = (intptr_t (QDECL *)( intptr_t, ...))-1;
Q_EXPORT void dllEntry( intptr_t (QDECL *syscallptr)( intptr_t arg,... ) ) {
syscall = syscallptr;
}
int PASSFLOAT( float x ) {
floatint_t fi;
fi.f = x;
return fi.i;
}
void trap_Print( const char *string ) {
syscall( UI_PRINT, string );
}
void trap_Error(const char *string)
{
syscall(UI_ERROR, string);
// shut up GCC warning about returning functions, because we know better
exit(1);
}
int trap_Milliseconds( void ) {
return syscall( UI_MILLISECONDS );
}
void trap_Cvar_Register( vmCvar_t *cvar, const char *var_name, const char *value, int flags ) {
syscall( UI_CVAR_REGISTER, cvar, var_name, value, flags );
}
void trap_Cvar_Update( vmCvar_t *cvar ) {
syscall( UI_CVAR_UPDATE, cvar );
}
void trap_Cvar_Set( const char *var_name, const char *value ) {
syscall( UI_CVAR_SET, var_name, value );
}
float trap_Cvar_VariableValue( const char *var_name ) {
floatint_t fi;
fi.i = syscall( UI_CVAR_VARIABLEVALUE, var_name );
return fi.f;
}
void trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize ) {
syscall( UI_CVAR_VARIABLESTRINGBUFFER, var_name, buffer, bufsize );
}
void trap_Cvar_SetValue( const char *var_name, float value ) {
syscall( UI_CVAR_SETVALUE, var_name, PASSFLOAT( value ) );
}
void trap_Cvar_Reset( const char *name ) {
syscall( UI_CVAR_RESET, name );
}
void trap_Cvar_Create( const char *var_name, const char *var_value, int flags ) {
syscall( UI_CVAR_CREATE, var_name, var_value, flags );
}
void trap_Cvar_InfoStringBuffer( int bit, char *buffer, int bufsize ) {
syscall( UI_CVAR_INFOSTRINGBUFFER, bit, buffer, bufsize );
}
int trap_Argc( void ) {
return syscall( UI_ARGC );
}
void trap_Argv( int n, char *buffer, int bufferLength ) {
syscall( UI_ARGV, n, buffer, bufferLength );
}
void trap_Cmd_ExecuteText( int exec_when, const char *text ) {
syscall( UI_CMD_EXECUTETEXT, exec_when, text );
}
int trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode ) {
return syscall( UI_FS_FOPENFILE, qpath, f, mode );
}
void trap_FS_Read( void *buffer, int len, fileHandle_t f ) {
syscall( UI_FS_READ, buffer, len, f );
}
//----(SA) added
void trap_FS_Seek( fileHandle_t f, long offset, int origin ) {
syscall( UI_FS_SEEK, f, offset, origin );
}
//----(SA) end
void trap_FS_Write( const void *buffer, int len, fileHandle_t f ) {
syscall( UI_FS_WRITE, buffer, len, f );
}
void trap_FS_FCloseFile( fileHandle_t f ) {
syscall( UI_FS_FCLOSEFILE, f );
}
int trap_FS_GetFileList( const char *path, const char *extension, char *listbuf, int bufsize ) {
return syscall( UI_FS_GETFILELIST, path, extension, listbuf, bufsize );
}
int trap_FS_Delete( const char *filename ) {
return syscall( UI_FS_DELETEFILE, filename );
}
qhandle_t trap_R_RegisterModel( const char *name ) {
return syscall( UI_R_REGISTERMODEL, name );
}
qhandle_t trap_R_RegisterSkin( const char *name ) {
return syscall( UI_R_REGISTERSKIN, name );
}
void trap_R_RegisterFont( const char *fontName, int pointSize, fontInfo_t *font ) {
syscall( UI_R_REGISTERFONT, fontName, pointSize, font );
}
qhandle_t trap_R_RegisterShaderNoMip( const char *name ) {
return syscall( UI_R_REGISTERSHADERNOMIP, name );
}
void trap_R_ClearScene( void ) {
syscall( UI_R_CLEARSCENE );
}
void trap_R_AddRefEntityToScene( const refEntity_t *re ) {
syscall( UI_R_ADDREFENTITYTOSCENE, re );
}
void trap_R_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts ) {
syscall( UI_R_ADDPOLYTOSCENE, hShader, numVerts, verts );
}
void trap_R_AddPolysToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts, int num ) {
syscall( UI_R_ADDPOLYSTOSCENE, hShader, numVerts, verts, num );
}
void trap_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b, int overdraw ) {
syscall( UI_R_ADDLIGHTTOSCENE, org, PASSFLOAT( intensity ), PASSFLOAT( r ), PASSFLOAT( g ), PASSFLOAT( b ), overdraw );
}
void trap_R_AddCoronaToScene( const vec3_t org, float r, float g, float b, float scale, int id, int flags ) {
syscall( UI_R_ADDCORONATOSCENE, org, PASSFLOAT( r ), PASSFLOAT( g ), PASSFLOAT( b ), PASSFLOAT( scale ), id, flags );
}
void trap_R_RenderScene( const refdef_t *fd ) {
syscall( UI_R_RENDERSCENE, fd );
}
void trap_R_SetColor( const float *rgba ) {
syscall( UI_R_SETCOLOR, rgba );
}
void trap_R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ) {
syscall( UI_R_DRAWSTRETCHPIC, PASSFLOAT( x ), PASSFLOAT( y ), PASSFLOAT( w ), PASSFLOAT( h ), PASSFLOAT( s1 ), PASSFLOAT( t1 ), PASSFLOAT( s2 ), PASSFLOAT( t2 ), hShader );
}
void trap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs ) {
syscall( UI_R_MODELBOUNDS, model, mins, maxs );
}
void trap_UpdateScreen( void ) {
syscall( UI_UPDATESCREEN );
}
int trap_CM_LerpTag( orientation_t *tag, const refEntity_t *refent, const char *tagName, int startIndex ) {
return syscall( UI_CM_LERPTAG, tag, refent, tagName, 0 ); // NEFVE - SMF - fixed
}
void trap_S_StartLocalSound( sfxHandle_t sfx, int channelNum ) {
syscall( UI_S_STARTLOCALSOUND, sfx, channelNum );
}
sfxHandle_t trap_S_RegisterSound( const char *sample ) {
return syscall( UI_S_REGISTERSOUND, sample );
}
//----(SA) added (already in cg)
void trap_S_FadeBackgroundTrack( float targetvol, int time, int num ) { // yes, i know. fadebackground coming in, fadestreaming going out. will have to see where functionality leads...
syscall( UI_S_FADESTREAMINGSOUND, PASSFLOAT( targetvol ), time, num ); // 'num' is '0' if it's music, '1' if it's "all streaming sounds"
}
void trap_S_FadeAllSound( float targetvol, int time ) {
syscall( UI_S_FADEALLSOUNDS, PASSFLOAT( targetvol ), time );
}
//----(SA) end
void trap_Key_KeynumToStringBuf( int keynum, char *buf, int buflen ) {
syscall( UI_KEY_KEYNUMTOSTRINGBUF, keynum, buf, buflen );
}
void trap_Key_GetBindingBuf( int keynum, char *buf, int buflen ) {
syscall( UI_KEY_GETBINDINGBUF, keynum, buf, buflen );
}
void trap_Key_SetBinding( int keynum, const char *binding ) {
syscall( UI_KEY_SETBINDING, keynum, binding );
}
qboolean trap_Key_IsDown( int keynum ) {
return syscall( UI_KEY_ISDOWN, keynum );
}
qboolean trap_Key_GetOverstrikeMode( void ) {
return syscall( UI_KEY_GETOVERSTRIKEMODE );
}
void trap_Key_SetOverstrikeMode( qboolean state ) {
syscall( UI_KEY_SETOVERSTRIKEMODE, state );
}
void trap_Key_ClearStates( void ) {
syscall( UI_KEY_CLEARSTATES );
}
int trap_Key_GetCatcher( void ) {
return syscall( UI_KEY_GETCATCHER );
}
void trap_Key_SetCatcher( int catcher ) {
syscall( UI_KEY_SETCATCHER, catcher );
}
void trap_GetClipboardData( char *buf, int bufsize ) {
syscall( UI_GETCLIPBOARDDATA, buf, bufsize );
}
void trap_GetClientState( uiClientState_t *state ) {
syscall( UI_GETCLIENTSTATE, state );
}
void trap_GetGlconfig( glconfig_t *glconfig ) {
syscall( UI_GETGLCONFIG, glconfig );
}
int trap_GetConfigString( int index, char* buff, int buffsize ) {
return syscall( UI_GETCONFIGSTRING, index, buff, buffsize );
}
int trap_LAN_GetLocalServerCount( void ) {
return syscall( UI_LAN_GETLOCALSERVERCOUNT );
}
void trap_LAN_GetLocalServerAddressString( int n, char *buf, int buflen ) {
syscall( UI_LAN_GETLOCALSERVERADDRESSSTRING, n, buf, buflen );
}
int trap_LAN_GetGlobalServerCount( void ) {
return syscall( UI_LAN_GETGLOBALSERVERCOUNT );
}
void trap_LAN_GetGlobalServerAddressString( int n, char *buf, int buflen ) {
syscall( UI_LAN_GETGLOBALSERVERADDRESSSTRING, n, buf, buflen );
}
int trap_LAN_GetPingQueueCount( void ) {
return syscall( UI_LAN_GETPINGQUEUECOUNT );
}
void trap_LAN_ClearPing( int n ) {
syscall( UI_LAN_CLEARPING, n );
}
void trap_LAN_GetPing( int n, char *buf, int buflen, int *pingtime ) {
syscall( UI_LAN_GETPING, n, buf, buflen, pingtime );
}
void trap_LAN_GetPingInfo( int n, char *buf, int buflen ) {
syscall( UI_LAN_GETPINGINFO, n, buf, buflen );
}
// NERVE - SMF
qboolean trap_LAN_UpdateVisiblePings( int source ) {
return syscall( UI_LAN_UPDATEVISIBLEPINGS, source );
}
int trap_LAN_GetServerCount( int source ) {
return syscall( UI_LAN_GETSERVERCOUNT, source );
}
int trap_LAN_CompareServers( int source, int sortKey, int sortDir, int s1, int s2 ) {
return syscall( UI_LAN_COMPARESERVERS, source, sortKey, sortDir, s1, s2 );
}
void trap_LAN_GetServerAddressString( int source, int n, char *buf, int buflen ) {
syscall( UI_LAN_GETSERVERADDRESSSTRING, source, n, buf, buflen );
}
void trap_LAN_GetServerInfo( int source, int n, char *buf, int buflen ) {
syscall( UI_LAN_GETSERVERINFO, source, n, buf, buflen );
}
int trap_LAN_AddServer( int source, const char *name, const char *addr ) {
return syscall( UI_LAN_ADDSERVER, source, name, addr );
}
void trap_LAN_RemoveServer( int source, const char *addr ) {
syscall( UI_LAN_REMOVESERVER, source, addr );
}
int trap_LAN_GetServerPing( int source, int n ) {
return syscall( UI_LAN_GETSERVERPING, source, n );
}
int trap_LAN_ServerIsVisible( int source, int n ) {
return syscall( UI_LAN_SERVERISVISIBLE, source, n );
}
int trap_LAN_ServerStatus( const char *serverAddress, char *serverStatus, int maxLen ) {
return syscall( UI_LAN_SERVERSTATUS, serverAddress, serverStatus, maxLen );
}
void trap_LAN_SaveCachedServers( void ) {
syscall( UI_LAN_SAVECACHEDSERVERS );
}
void trap_LAN_LoadCachedServers( void ) {
syscall( UI_LAN_LOADCACHEDSERVERS );
}
void trap_LAN_MarkServerVisible( int source, int n, qboolean visible ) {
syscall( UI_LAN_MARKSERVERVISIBLE, source, n, visible );
}
void trap_LAN_ResetPings( int n ) {
syscall( UI_LAN_RESETPINGS, n );
}
// -NERVE - SMF
int trap_MemoryRemaining( void ) {
return syscall( UI_MEMORY_REMAINING );
}
void trap_GetCDKey( char *buf, int buflen ) {
syscall( UI_GET_CDKEY, buf, buflen );
}
void trap_SetCDKey( char *buf ) {
syscall( UI_SET_CDKEY, buf );
}
int trap_PC_AddGlobalDefine( char *define ) {
return syscall( UI_PC_ADD_GLOBAL_DEFINE, define );
}
int trap_PC_LoadSource( const char *filename ) {
return syscall( UI_PC_LOAD_SOURCE, filename );
}
int trap_PC_FreeSource( int handle ) {
return syscall( UI_PC_FREE_SOURCE, handle );
}
int trap_PC_ReadToken( int handle, pc_token_t *pc_token ) {
return syscall( UI_PC_READ_TOKEN, handle, pc_token );
}
int trap_PC_SourceFileAndLine( int handle, char *filename, int *line ) {
return syscall( UI_PC_SOURCE_FILE_AND_LINE, handle, filename, line );
}
void trap_S_StopBackgroundTrack( void ) {
syscall( UI_S_STOPBACKGROUNDTRACK );
}
void trap_S_StartBackgroundTrack( const char *intro, const char *loop, int fadeupTime ) {
syscall( UI_S_STARTBACKGROUNDTRACK, intro, loop, fadeupTime );
}
int trap_RealTime( qtime_t *qtime ) {
return syscall( UI_REAL_TIME, qtime );
}
// 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( UI_CIN_PLAYCINEMATIC, arg0, xpos, ypos, width, height, bits );
}
// 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( UI_CIN_STOPCINEMATIC, handle );
}
// 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( UI_CIN_RUNCINEMATIC, handle );
}
// draws the current frame
void trap_CIN_DrawCinematic( int handle ) {
syscall( UI_CIN_DRAWCINEMATIC, handle );
}
// allows you to resize the animation dynamically
void trap_CIN_SetExtents( int handle, int x, int y, int w, int h ) {
syscall( UI_CIN_SETEXTENTS, handle, x, y, w, h );
}
void trap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset ) {
syscall( UI_R_REMAP_SHADER, oldShader, newShader, timeOffset );
}
qboolean trap_VerifyCDKey( const char *key, const char *chksum ) {
return syscall( UI_VERIFY_CDKEY, key, chksum );
}
// NERVE - SMF
qboolean trap_GetLimboString( int index, char *buf ) {
return syscall( UI_CL_GETLIMBOSTRING, index, buf );
}
// -NERVE - SMF
// New in IORTCW
void *trap_Alloc( int size ) {
return (void*)syscall( UI_ALLOC, size );
}
|