mirror of
https://github.com/UberGames/ioef.git
synced 2025-02-12 06:50:43 +00:00
support for 64bit native mods
This commit is contained in:
parent
334fa9c48c
commit
88171d6bb7
14 changed files with 50 additions and 51 deletions
|
@ -43,7 +43,7 @@ This is the only way control passes into the module.
|
||||||
This must be the very first function compiled into the .q3vm file
|
This must be the very first function compiled into the .q3vm file
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
|
long vmMain( long command, long arg0, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6, long arg7, long arg8, long arg9, long arg10, long arg11 ) {
|
||||||
|
|
||||||
switch ( command ) {
|
switch ( command ) {
|
||||||
case CG_INIT:
|
case CG_INIT:
|
||||||
|
|
|
@ -28,10 +28,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
#include "cg_local.h"
|
#include "cg_local.h"
|
||||||
|
|
||||||
static int (QDECL *syscall)( int arg, ... ) = (int (QDECL *)( int, ...))-1;
|
static long (QDECL *syscall)( int arg, ... ) = (long (QDECL *)( int, ...))-1;
|
||||||
|
|
||||||
|
|
||||||
void dllEntry( int (QDECL *syscallptr)( int arg,... ) ) {
|
void dllEntry( long (QDECL *syscallptr)( int arg,... ) ) {
|
||||||
syscall = syscallptr;
|
syscall = syscallptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -412,9 +412,7 @@ CL_CgameSystemCalls
|
||||||
The cgame module is making a system call
|
The cgame module is making a system call
|
||||||
====================
|
====================
|
||||||
*/
|
*/
|
||||||
#define VMA(x) VM_ArgPtr(args[x])
|
long CL_CgameSystemCalls( long *args ) {
|
||||||
#define VMF(x) ((float *)args)[x]
|
|
||||||
int CL_CgameSystemCalls( int *args ) {
|
|
||||||
switch( args[0] ) {
|
switch( args[0] ) {
|
||||||
case CG_PRINT:
|
case CG_PRINT:
|
||||||
Com_Printf( "%s", VMA(1) );
|
Com_Printf( "%s", VMA(1) );
|
||||||
|
|
|
@ -757,10 +757,6 @@ static int FloatAsInt( float f ) {
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *VM_ArgPtr( int intValue );
|
|
||||||
#define VMA(x) VM_ArgPtr(args[x])
|
|
||||||
#define VMF(x) ((float *)args)[x]
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
====================
|
====================
|
||||||
CL_UISystemCalls
|
CL_UISystemCalls
|
||||||
|
@ -768,7 +764,7 @@ CL_UISystemCalls
|
||||||
The ui module is making a system call
|
The ui module is making a system call
|
||||||
====================
|
====================
|
||||||
*/
|
*/
|
||||||
int CL_UISystemCalls( int *args ) {
|
long CL_UISystemCalls( long *args ) {
|
||||||
switch( args[0] ) {
|
switch( args[0] ) {
|
||||||
case UI_ERROR:
|
case UI_ERROR:
|
||||||
Com_Error( ERR_DROP, "%s", VMA(1) );
|
Com_Error( ERR_DROP, "%s", VMA(1) );
|
||||||
|
|
|
@ -200,7 +200,7 @@ This is the only way control passes into the module.
|
||||||
This must be the very first function compiled into the .q3vm file
|
This must be the very first function compiled into the .q3vm file
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
|
long vmMain( long command, long arg0, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6, long arg7, long arg8, long arg9, long arg10, long arg11 ) {
|
||||||
switch ( command ) {
|
switch ( command ) {
|
||||||
case GAME_INIT:
|
case GAME_INIT:
|
||||||
G_InitGame( arg0, arg1, arg2 );
|
G_InitGame( arg0, arg1, arg2 );
|
||||||
|
@ -210,7 +210,7 @@ int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int a
|
||||||
return 0;
|
return 0;
|
||||||
case GAME_CLIENT_CONNECT:
|
case GAME_CLIENT_CONNECT:
|
||||||
#warning 64bit broken!
|
#warning 64bit broken!
|
||||||
return (int)ClientConnect( arg0, arg1, arg2 );
|
return ClientConnect( arg0, arg1, arg2 );
|
||||||
case GAME_CLIENT_THINK:
|
case GAME_CLIENT_THINK:
|
||||||
ClientThink( arg0 );
|
ClientThink( arg0 );
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -40,7 +40,7 @@ This is the only way control passes into the module.
|
||||||
This must be the very first function compiled into the .qvm file
|
This must be the very first function compiled into the .qvm file
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
|
long vmMain( long command, long arg0, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6, long arg7, long arg8, long arg9, long arg10, long arg11 ) {
|
||||||
switch ( command ) {
|
switch ( command ) {
|
||||||
case UI_GETAPIVERSION:
|
case UI_GETAPIVERSION:
|
||||||
return UI_API_VERSION;
|
return UI_API_VERSION;
|
||||||
|
|
|
@ -310,7 +310,7 @@ typedef enum {
|
||||||
} sharedTraps_t;
|
} sharedTraps_t;
|
||||||
|
|
||||||
void VM_Init( void );
|
void VM_Init( void );
|
||||||
vm_t *VM_Create( const char *module, int (*systemCalls)(int *),
|
vm_t *VM_Create( const char *module, long (*systemCalls)(long *),
|
||||||
vmInterpret_t interpret );
|
vmInterpret_t interpret );
|
||||||
// module should be bare: "cgame", not "cgame.dll" or "vm/cgame.qvm"
|
// module should be bare: "cgame", not "cgame.dll" or "vm/cgame.qvm"
|
||||||
|
|
||||||
|
@ -318,12 +318,25 @@ void VM_Free( vm_t *vm );
|
||||||
void VM_Clear(void);
|
void VM_Clear(void);
|
||||||
vm_t *VM_Restart( vm_t *vm );
|
vm_t *VM_Restart( vm_t *vm );
|
||||||
|
|
||||||
int QDECL VM_Call( vm_t *vm, int callNum, ... );
|
long QDECL VM_Call( vm_t *vm, long callNum, ... );
|
||||||
|
|
||||||
void VM_Debug( int level );
|
void VM_Debug( int level );
|
||||||
|
|
||||||
void *VM_ArgPtr( int intValue );
|
void *VM_ArgPtr( long intValue );
|
||||||
void *VM_ExplicitArgPtr( vm_t *vm, int intValue );
|
void *VM_ExplicitArgPtr( vm_t *vm, long intValue );
|
||||||
|
|
||||||
|
#define VMA(x) VM_ArgPtr(args[x])
|
||||||
|
static inline float _vmf(long x)
|
||||||
|
{
|
||||||
|
union {
|
||||||
|
long l;
|
||||||
|
float fh, fl;
|
||||||
|
} t;
|
||||||
|
t.l = x;
|
||||||
|
return t.fl;
|
||||||
|
}
|
||||||
|
#define VMF(x) _vmf(args[x])
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==============================================================
|
==============================================================
|
||||||
|
@ -936,8 +949,8 @@ void Sys_Init (void);
|
||||||
|
|
||||||
// general development dll loading for virtual machine testing
|
// general development dll loading for virtual machine testing
|
||||||
// fqpath param added 7/20/02 by T.Ray - Sys_LoadDll is only called in vm.c at this time
|
// fqpath param added 7/20/02 by T.Ray - Sys_LoadDll is only called in vm.c at this time
|
||||||
void * QDECL Sys_LoadDll( const char *name, char *fqpath , int (QDECL **entryPoint)(int, ...),
|
void * QDECL Sys_LoadDll( const char *name, char *fqpath , long (QDECL **entryPoint)(long, ...),
|
||||||
int (QDECL *systemcalls)(int, ...) );
|
long (QDECL *systemcalls)(long, ...) );
|
||||||
void Sys_UnloadDll( void *dllHandle );
|
void Sys_UnloadDll( void *dllHandle );
|
||||||
|
|
||||||
void Sys_UnloadGame( void );
|
void Sys_UnloadGame( void );
|
||||||
|
|
|
@ -329,10 +329,10 @@ Dlls will call this directly
|
||||||
|
|
||||||
============
|
============
|
||||||
*/
|
*/
|
||||||
int QDECL VM_DllSyscall( int arg, ... ) {
|
long QDECL VM_DllSyscall( long arg, ... ) {
|
||||||
#if ((defined __linux__) && (defined __powerpc__))
|
#if ((defined __linux__) && !(defined __i386__))
|
||||||
// rcg010206 - see commentary above
|
// rcg010206 - see commentary above
|
||||||
int args[16];
|
long args[16];
|
||||||
int i;
|
int i;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
|
@ -340,7 +340,7 @@ int QDECL VM_DllSyscall( int arg, ... ) {
|
||||||
|
|
||||||
va_start(ap, arg);
|
va_start(ap, arg);
|
||||||
for (i = 1; i < sizeof (args) / sizeof (args[i]); i++)
|
for (i = 1; i < sizeof (args) / sizeof (args[i]); i++)
|
||||||
args[i] = va_arg(ap, int);
|
args[i] = va_arg(ap, long);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
return currentVM->systemCall( args );
|
return currentVM->systemCall( args );
|
||||||
|
@ -367,7 +367,7 @@ vm_t *VM_Restart( vm_t *vm ) {
|
||||||
// DLL's can't be restarted in place
|
// DLL's can't be restarted in place
|
||||||
if ( vm->dllHandle ) {
|
if ( vm->dllHandle ) {
|
||||||
char name[MAX_QPATH];
|
char name[MAX_QPATH];
|
||||||
int (*systemCall)( int *parms );
|
long (*systemCall)( long *parms );
|
||||||
|
|
||||||
systemCall = vm->systemCall;
|
systemCall = vm->systemCall;
|
||||||
Q_strncpyz( name, vm->name, sizeof( name ) );
|
Q_strncpyz( name, vm->name, sizeof( name ) );
|
||||||
|
@ -437,7 +437,7 @@ it will attempt to load as a system dll
|
||||||
|
|
||||||
#define STACK_SIZE 0x20000
|
#define STACK_SIZE 0x20000
|
||||||
|
|
||||||
vm_t *VM_Create( const char *module, int (*systemCalls)(int *),
|
vm_t *VM_Create( const char *module, long (*systemCalls)(long *),
|
||||||
vmInterpret_t interpret ) {
|
vmInterpret_t interpret ) {
|
||||||
vm_t *vm;
|
vm_t *vm;
|
||||||
vmHeader_t *header;
|
vmHeader_t *header;
|
||||||
|
@ -624,7 +624,7 @@ void VM_Clear(void) {
|
||||||
lastVM = NULL;
|
lastVM = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *VM_ArgPtr( int intValue ) {
|
void *VM_ArgPtr( long intValue ) {
|
||||||
if ( !intValue ) {
|
if ( !intValue ) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -640,7 +640,7 @@ void *VM_ArgPtr( int intValue ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void *VM_ExplicitArgPtr( vm_t *vm, int intValue ) {
|
void *VM_ExplicitArgPtr( vm_t *vm, long intValue ) {
|
||||||
if ( !intValue ) {
|
if ( !intValue ) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -685,7 +685,7 @@ locals from sp
|
||||||
#define MAX_STACK 256
|
#define MAX_STACK 256
|
||||||
#define STACK_MASK (MAX_STACK-1)
|
#define STACK_MASK (MAX_STACK-1)
|
||||||
|
|
||||||
int QDECL VM_Call( vm_t *vm, int callnum, ... ) {
|
long QDECL VM_Call( vm_t *vm, long callnum, ... ) {
|
||||||
vm_t *oldVM;
|
vm_t *oldVM;
|
||||||
int r;
|
int r;
|
||||||
int i;
|
int i;
|
||||||
|
@ -699,17 +699,17 @@ int QDECL VM_Call( vm_t *vm, int callnum, ... ) {
|
||||||
lastVM = vm;
|
lastVM = vm;
|
||||||
|
|
||||||
if ( vm_debugLevel ) {
|
if ( vm_debugLevel ) {
|
||||||
Com_Printf( "VM_Call( %i )\n", callnum );
|
Com_Printf( "VM_Call( %ld )\n", callnum );
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we have a dll loaded, call it directly
|
// if we have a dll loaded, call it directly
|
||||||
if ( vm->entryPoint ) {
|
if ( vm->entryPoint ) {
|
||||||
//rcg010207 - see dissertation at top of VM_DllSyscall() in this file.
|
//rcg010207 - see dissertation at top of VM_DllSyscall() in this file.
|
||||||
int args[16];
|
long args[16];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, callnum);
|
va_start(ap, callnum);
|
||||||
for (i = 0; i < sizeof (args) / sizeof (args[i]); i++) {
|
for (i = 0; i < sizeof (args) / sizeof (args[i]); i++) {
|
||||||
args[i] = va_arg(ap, int);
|
args[i] = va_arg(ap, long);
|
||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
|
@ -729,7 +729,7 @@ int QDECL VM_Call( vm_t *vm, int callnum, ... ) {
|
||||||
a.callnum = callnum;
|
a.callnum = callnum;
|
||||||
va_start(ap, callnum);
|
va_start(ap, callnum);
|
||||||
for (i = 0; i < sizeof (a.args) / sizeof (a.args[0]); i++) {
|
for (i = 0; i < sizeof (a.args) / sizeof (a.args[0]); i++) {
|
||||||
a.args[i] = va_arg(ap, int);
|
a.args[i] = va_arg(ap, long);
|
||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
r = VM_CallInterpreted( vm, &a.callnum );
|
r = VM_CallInterpreted( vm, &a.callnum );
|
||||||
|
|
|
@ -127,7 +127,7 @@ struct vm_s {
|
||||||
// DO NOT MOVE OR CHANGE THESE WITHOUT CHANGING THE VM_OFFSET_* DEFINES
|
// DO NOT MOVE OR CHANGE THESE WITHOUT CHANGING THE VM_OFFSET_* DEFINES
|
||||||
// USED BY THE ASM CODE
|
// USED BY THE ASM CODE
|
||||||
int programStack; // the vm may be recursively entered
|
int programStack; // the vm may be recursively entered
|
||||||
int (*systemCall)( int *parms );
|
long (*systemCall)( long *parms );
|
||||||
|
|
||||||
//------------------------------------
|
//------------------------------------
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ struct vm_s {
|
||||||
|
|
||||||
// for dynamic linked modules
|
// for dynamic linked modules
|
||||||
void *dllHandle;
|
void *dllHandle;
|
||||||
int (QDECL *entryPoint)( int callNum, ... );
|
long (QDECL *entryPoint)( long callNum, ... );
|
||||||
|
|
||||||
// for interpreted modules
|
// for interpreted modules
|
||||||
qboolean currentlyInterpreting;
|
qboolean currentlyInterpreting;
|
||||||
|
|
|
@ -305,16 +305,7 @@ SV_GameSystemCalls
|
||||||
The module is making a system call
|
The module is making a system call
|
||||||
====================
|
====================
|
||||||
*/
|
*/
|
||||||
//rcg010207 - see my comments in VM_DllSyscall(), in qcommon/vm.c ...
|
long SV_GameSystemCalls( long *args ) {
|
||||||
#if ((defined __linux__) && (defined __powerpc__))
|
|
||||||
#define VMA(x) ((void *) args[x])
|
|
||||||
#else
|
|
||||||
#define VMA(x) VM_ArgPtr(args[x])
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define VMF(x) ((float *)args)[x]
|
|
||||||
|
|
||||||
int SV_GameSystemCalls( int *args ) {
|
|
||||||
switch( args[0] ) {
|
switch( args[0] ) {
|
||||||
case G_PRINT:
|
case G_PRINT:
|
||||||
Com_Printf( "%s", VMA(1) );
|
Com_Printf( "%s", VMA(1) );
|
||||||
|
|
|
@ -165,7 +165,7 @@ void _UI_KeyEvent( int key, qboolean down );
|
||||||
void _UI_MouseEvent( int dx, int dy );
|
void _UI_MouseEvent( int dx, int dy );
|
||||||
void _UI_Refresh( int realtime );
|
void _UI_Refresh( int realtime );
|
||||||
qboolean _UI_IsFullscreen( void );
|
qboolean _UI_IsFullscreen( void );
|
||||||
int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
|
long vmMain( long command, long arg0, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6, long arg7, long arg8, long arg9, long arg10, long arg11 ) {
|
||||||
switch ( command ) {
|
switch ( command ) {
|
||||||
case UI_GETAPIVERSION:
|
case UI_GETAPIVERSION:
|
||||||
return UI_API_VERSION;
|
return UI_API_VERSION;
|
||||||
|
|
|
@ -130,6 +130,7 @@ ifeq ($(PLATFORM),linux)
|
||||||
OPTIMIZE = -O3 -ffast-math -funroll-loops -fomit-frame-pointer -fno-strict-aliasing
|
OPTIMIZE = -O3 -ffast-math -funroll-loops -fomit-frame-pointer -fno-strict-aliasing
|
||||||
ifeq ($(ARCH),x86_64)
|
ifeq ($(ARCH),x86_64)
|
||||||
OPTIMIZE = -O3 -fomit-frame-pointer -ffast-math -falign-loops=2 -falign-jumps=2 -falign-functions=2 -fstrength-reduce -fno-strict-aliasing
|
OPTIMIZE = -O3 -fomit-frame-pointer -ffast-math -falign-loops=2 -falign-jumps=2 -falign-functions=2 -fstrength-reduce -fno-strict-aliasing
|
||||||
|
BASE_CFLAGS += -DHAVE_VM_NATIVE
|
||||||
else
|
else
|
||||||
ifeq ($(ARCH),i386)
|
ifeq ($(ARCH),i386)
|
||||||
OPTIMIZE = -O3 -march=i686 -fomit-frame-pointer -ffast-math -falign-loops=2 -falign-jumps=2 -falign-functions=2 -fno-strict-aliasing -fstrength-reduce
|
OPTIMIZE = -O3 -march=i686 -fomit-frame-pointer -ffast-math -falign-loops=2 -falign-jumps=2 -falign-functions=2 -fno-strict-aliasing -fstrength-reduce
|
||||||
|
|
|
@ -708,11 +708,11 @@ changed the load procedure to match VFS logic, and allow developer use
|
||||||
extern char *FS_BuildOSPath( const char *base, const char *game, const char *qpath );
|
extern char *FS_BuildOSPath( const char *base, const char *game, const char *qpath );
|
||||||
|
|
||||||
void *Sys_LoadDll( const char *name, char *fqpath ,
|
void *Sys_LoadDll( const char *name, char *fqpath ,
|
||||||
int (**entryPoint)(int, ...),
|
long (**entryPoint)(long, ...),
|
||||||
int (*systemcalls)(int, ...) )
|
long (*systemcalls)(long, ...) )
|
||||||
{
|
{
|
||||||
void *libHandle;
|
void *libHandle;
|
||||||
void (*dllEntry)( int (*syscallptr)(int, ...) );
|
void (*dllEntry)( long (*syscallptr)(long, ...) );
|
||||||
char curpath[MAX_OSPATH];
|
char curpath[MAX_OSPATH];
|
||||||
char fname[MAX_OSPATH];
|
char fname[MAX_OSPATH];
|
||||||
char *basepath;
|
char *basepath;
|
||||||
|
|
|
@ -527,10 +527,10 @@ extern char *FS_BuildOSPath( const char *base, const char *game, const char *qp
|
||||||
// fqpath will be empty if dll not loaded, otherwise will hold fully qualified path of dll module loaded
|
// fqpath will be empty if dll not loaded, otherwise will hold fully qualified path of dll module loaded
|
||||||
// fqpath buffersize must be at least MAX_QPATH+1 bytes long
|
// fqpath buffersize must be at least MAX_QPATH+1 bytes long
|
||||||
void * QDECL Sys_LoadDll( const char *name, char *fqpath , int (QDECL **entryPoint)(int, ...),
|
void * QDECL Sys_LoadDll( const char *name, char *fqpath , int (QDECL **entryPoint)(int, ...),
|
||||||
int (QDECL *systemcalls)(int, ...) ) {
|
long (QDECL *systemcalls)(long, ...) ) {
|
||||||
static int lastWarning = 0;
|
static int lastWarning = 0;
|
||||||
HINSTANCE libHandle;
|
HINSTANCE libHandle;
|
||||||
void (QDECL *dllEntry)( int (QDECL *syscallptr)(int, ...) );
|
void (QDECL *dllEntry)( long (QDECL *syscallptr)(long, ...) );
|
||||||
char *basepath;
|
char *basepath;
|
||||||
char *cdpath;
|
char *cdpath;
|
||||||
char *gamedir;
|
char *gamedir;
|
||||||
|
|
Loading…
Reference in a new issue