QVM: use correct prototype for vmMain() entry point, code cleanup
This commit is contained in:
parent
2baea18753
commit
5cfb181777
|
@ -839,10 +839,6 @@ typedef struct
|
|||
byte b7;
|
||||
} qint64;
|
||||
|
||||
typedef intptr_t (*syscall_t)( intptr_t *parms );
|
||||
typedef intptr_t (QDECL *dllSyscall_t)( intptr_t callNum, ... );
|
||||
typedef void (QDECL *dllEntry_t)( dllSyscall_t syscallptr );
|
||||
|
||||
//=============================================
|
||||
/*
|
||||
short BigShort(short l);
|
||||
|
|
|
@ -383,11 +383,18 @@ typedef enum {
|
|||
VM_COUNT
|
||||
} vmIndex_t;
|
||||
|
||||
// we don't need more than 4 arguments (counting callnum) for vmMain, at least in Vanilla Quake3
|
||||
#define MAX_VMMAIN_CALL_ARGS 4
|
||||
|
||||
typedef intptr_t (QDECL *vmMainFunc_t)( int command, int arg0, int arg1, int arg2 );
|
||||
|
||||
typedef intptr_t (*syscall_t)( intptr_t *parms );
|
||||
typedef intptr_t (QDECL *dllSyscall_t)( intptr_t callNum, ... );
|
||||
typedef void (QDECL *dllEntry_t)( dllSyscall_t syscallptr );
|
||||
|
||||
void VM_Init( void );
|
||||
vm_t *VM_Create( vmIndex_t index, syscall_t systemCalls, dllSyscall_t dllSyscalls, vmInterpret_t interpret );
|
||||
|
||||
// module should be bare: "cgame", not "cgame.dll" or "vm/cgame.qvm"
|
||||
|
||||
void VM_Free( vm_t *vm );
|
||||
void VM_Clear(void);
|
||||
void VM_Forced_Unload_Start(void);
|
||||
|
|
|
@ -1687,7 +1687,7 @@ Used to load a development dll instead of a virtual machine
|
|||
TTimo: added some verbosity in debug
|
||||
=================
|
||||
*/
|
||||
static void * QDECL VM_LoadDll( const char *name, dllSyscall_t *entryPoint, dllSyscall_t systemcalls ) {
|
||||
static void * QDECL VM_LoadDll( const char *name, vmMainFunc_t *entryPoint, dllSyscall_t systemcalls ) {
|
||||
|
||||
const char *gamedir = Cvar_VariableString( "fs_game" );
|
||||
char filename[ MAX_QPATH ];
|
||||
|
@ -1954,9 +1954,9 @@ intptr_t QDECL VM_Call( vm_t *vm, int nargs, int callnum, ... )
|
|||
va_list ap;
|
||||
va_start( ap, callnum );
|
||||
for ( i = 0; i < nargs; i++ ) {
|
||||
args[i] = va_arg( ap, int );
|
||||
args[i] = va_arg( ap, int32_t );
|
||||
}
|
||||
va_end(ap);
|
||||
va_end( ap );
|
||||
|
||||
// add more arguments if you're changed MAX_VMMAIN_CALL_ARGS:
|
||||
r = vm->entryPoint( callnum, args[0], args[1], args[2] );
|
||||
|
@ -1975,7 +1975,7 @@ intptr_t QDECL VM_Call( vm_t *vm, int nargs, int callnum, ... )
|
|||
args[0] = callnum;
|
||||
va_start( ap, callnum );
|
||||
for ( i = 0; i < nargs; i++ ) {
|
||||
args[i+1] = va_arg( ap, int );
|
||||
args[i+1] = va_arg( ap, int32_t );
|
||||
}
|
||||
va_end(ap);
|
||||
#ifndef NO_VM_COMPILED
|
||||
|
|
|
@ -3492,7 +3492,7 @@ __recompile:
|
|||
int32_t VM_CallCompiled( vm_t *vm, int nargs, int32_t *args )
|
||||
{
|
||||
int32_t opStack[ MAX_OPSTACK_SIZE ];
|
||||
int stackOnEntry;
|
||||
int32_t stackOnEntry;
|
||||
int32_t *image;
|
||||
int i;
|
||||
|
||||
|
|
|
@ -3213,7 +3213,7 @@ __recompile:
|
|||
int32_t VM_CallCompiled( vm_t *vm, int nargs, int32_t *args )
|
||||
{
|
||||
int32_t opStack[ MAX_OPSTACK_SIZE ];
|
||||
int stackOnEntry;
|
||||
int32_t stackOnEntry;
|
||||
int32_t *image;
|
||||
int i;
|
||||
|
||||
|
|
|
@ -157,10 +157,10 @@ locals from sp
|
|||
int VM_CallInterpreted2( vm_t *vm, int nargs, int32_t *args ) {
|
||||
int32_t stack[MAX_OPSTACK_SIZE];
|
||||
int32_t *opStack, *opStackTop;
|
||||
int programStack;
|
||||
int stackOnEntry;
|
||||
int32_t programStack;
|
||||
int32_t stackOnEntry;
|
||||
byte *image;
|
||||
int v1, v0;
|
||||
int32_t v1, v0;
|
||||
int dataMask;
|
||||
instruction_t *inst, *ci;
|
||||
floatint_t r0, r1;
|
||||
|
|
|
@ -28,9 +28,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#define MAX_OPSTACK_SIZE 512
|
||||
#define PROC_OPSTACK_SIZE 30
|
||||
|
||||
// we don't need more than 4 arguments (counting callnum) for vmMain, at least in Quake3
|
||||
#define MAX_VMMAIN_CALL_ARGS 4
|
||||
|
||||
// don't change
|
||||
// Hardcoded in q3asm an reserved at end of bss
|
||||
#define PROGRAM_STACK_SIZE 0x10000
|
||||
|
@ -176,17 +173,17 @@ struct vm_s {
|
|||
int32_t *opStack; // pointer to local function stack
|
||||
int32_t *opStackTop;
|
||||
|
||||
int programStack; // the vm may be recursively entered
|
||||
int stackBottom; // if programStack < stackBottom, error
|
||||
int32_t programStack; // the vm may be recursively entered
|
||||
int32_t stackBottom; // if programStack < stackBottom, error
|
||||
|
||||
//------------------------------------
|
||||
|
||||
const char *name;
|
||||
const char *name; // module should be bare: "cgame", not "cgame.dll" or "vm/cgame.qvm"
|
||||
vmIndex_t index;
|
||||
|
||||
// for dynamic linked modules
|
||||
void *dllHandle;
|
||||
dllSyscall_t entryPoint;
|
||||
vmMainFunc_t entryPoint;
|
||||
dllSyscall_t dllSyscall;
|
||||
void (*destroy)(vm_t* self);
|
||||
|
||||
|
@ -215,7 +212,7 @@ struct vm_s {
|
|||
int breakCount;
|
||||
|
||||
int32_t *jumpTableTargets;
|
||||
int numJumpTableTargets;
|
||||
int32_t numJumpTableTargets;
|
||||
|
||||
uint32_t crc32sum;
|
||||
|
||||
|
|
|
@ -4827,7 +4827,7 @@ This function is called directly by the generated code
|
|||
int32_t VM_CallCompiled( vm_t *vm, int nargs, int32_t *args )
|
||||
{
|
||||
int32_t opStack[MAX_OPSTACK_SIZE];
|
||||
int stackOnEntry;
|
||||
int32_t stackOnEntry;
|
||||
int32_t *image;
|
||||
#if id386
|
||||
int32_t *oldOpTop;
|
||||
|
|
Loading…
Reference in New Issue