2013-04-19 02:52:48 +00:00
|
|
|
// vmachine.cpp -- wrapper to fake virtual machine for client
|
|
|
|
|
2013-04-23 07:39:09 +00:00
|
|
|
#include "../game/q_shared.h"
|
2013-04-19 02:52:48 +00:00
|
|
|
#include "vmachine.h"
|
|
|
|
#pragma warning (disable : 4514)
|
|
|
|
/*
|
|
|
|
==============================================================
|
|
|
|
|
|
|
|
VIRTUAL MACHINE
|
|
|
|
|
|
|
|
==============================================================
|
|
|
|
*/
|
2013-04-20 06:19:40 +00:00
|
|
|
intptr_t VM_Call( intptr_t callnum, ... )
|
2013-04-19 02:52:48 +00:00
|
|
|
{
|
2013-04-20 06:19:40 +00:00
|
|
|
intptr_t args[9];
|
|
|
|
int i;
|
|
|
|
va_list ap;
|
2013-04-19 02:52:48 +00:00
|
|
|
// assert (cgvm.entryPoint);
|
|
|
|
|
|
|
|
if (cgvm.entryPoint)
|
|
|
|
{
|
2013-04-20 06:19:40 +00:00
|
|
|
va_start(ap, callnum);
|
|
|
|
for (i = 0; i < 9; i++) {
|
|
|
|
args[i] = va_arg(ap, intptr_t);
|
|
|
|
}
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
return cgvm.entryPoint( callnum, args[0], args[1], args[2],
|
|
|
|
args[3], args[4], args[5], args[6], args[7], args[8] );
|
2013-04-19 02:52:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
VM_DllSyscall
|
|
|
|
|
|
|
|
we pass this to the cgame dll to call back into the client
|
|
|
|
============
|
|
|
|
*/
|
2013-04-20 06:19:40 +00:00
|
|
|
extern intptr_t CL_CgameSystemCalls( intptr_t *args );
|
|
|
|
extern intptr_t CL_UISystemCalls( intptr_t *args );
|
|
|
|
|
|
|
|
intptr_t VM_DllSyscall( intptr_t arg, ... ) {
|
|
|
|
#if !defined(__i386__) || defined(__clang__)
|
|
|
|
intptr_t args[15];
|
|
|
|
int i;
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
args[0] = arg;
|
|
|
|
|
|
|
|
va_start(ap, arg);
|
|
|
|
for (i = 1; i < 15; i++)
|
|
|
|
args[i] = va_arg(ap, intptr_t);
|
|
|
|
va_end(ap);
|
2013-04-19 02:52:48 +00:00
|
|
|
|
2013-04-20 06:19:40 +00:00
|
|
|
return CL_CgameSystemCalls( args );
|
|
|
|
#else
|
2013-04-19 02:52:48 +00:00
|
|
|
// return cgvm->systemCall( &arg );
|
|
|
|
return CL_CgameSystemCalls( &arg );
|
2013-04-20 06:19:40 +00:00
|
|
|
#endif
|
2013-04-19 02:52:48 +00:00
|
|
|
}
|