From 54d65a0eadffbcd430ff32d173ef201b06dfbdc3 Mon Sep 17 00:00:00 2001 From: Ludwig Nussel Date: Tue, 30 Aug 2005 21:25:54 +0000 Subject: [PATCH] - load qvm file by default again to avoid 'unpure' error - fix loading qvms in 64bit q3 --- code/qcommon/qcommon.h | 4 ++-- code/qcommon/vm.c | 3 +-- code/qcommon/vm_interpreted.c | 15 ++++++++++++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h index 9b5bd5dd..3cad8418 100644 --- a/code/qcommon/qcommon.h +++ b/code/qcommon/qcommon.h @@ -330,10 +330,10 @@ static inline float _vmf(long x) { union { long l; - float fh, fl; + float f; } t; t.l = x; - return t.fl; + return t.f; } #define VMF(x) _vmf(args[x]) diff --git a/code/qcommon/vm.c b/code/qcommon/vm.c index 2700d595..713e6aee 100644 --- a/code/qcommon/vm.c +++ b/code/qcommon/vm.c @@ -484,8 +484,7 @@ vm_t *VM_Create( const char *module, long (*systemCalls)(long *), } } - // always try dll first? -- ln - if ( 1 || interpret == VMI_NATIVE ) { + if ( interpret == VMI_NATIVE ) { // try to load as a system dll Com_Printf( "Loading dll file %s.\n", vm->name ); vm->dllHandle = Sys_LoadDll( module, vm->fqpath , &vm->entryPoint, VM_DllSyscall ); diff --git a/code/qcommon/vm_interpreted.c b/code/qcommon/vm_interpreted.c index e2d69a7f..1989a5d7 100644 --- a/code/qcommon/vm_interpreted.c +++ b/code/qcommon/vm_interpreted.c @@ -518,7 +518,20 @@ nextInstruction2: *(int *)&image[ programStack + 4 ] = -1 - programCounter; //VM_LogSyscalls( (int *)&image[ programStack + 4 ] ); - r = vm->systemCall( (int *)&image[ programStack + 4 ] ); + { + long* argptr = (long *)&image[ programStack + 4 ]; + #if __WORDSIZE == 64 + // the vm has ints on the stack, we expect + // longs so we have to convert it + long argarr[16]; + int i; + for (i = 0; i < 16; ++i) { + argarr[i] = *(int*)&image[ programStack + 4 + 4*i ]; + argptr = argarr; + } + #endif + r = vm->systemCall( argptr ); + } #ifdef DEBUG_VM // this is just our stack frame pointer, only needed