summaryrefslogtreecommitdiff
path: root/src/qcommon/vm.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/qcommon/vm.h')
-rw-r--r--src/qcommon/vm.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/qcommon/vm.h b/src/qcommon/vm.h
new file mode 100644
index 0000000..26705af
--- /dev/null
+++ b/src/qcommon/vm.h
@@ -0,0 +1,67 @@
+#ifndef QCOMMON_VM_H
+#define QCOMMON_VM_H 1
+
+#include "q_shared.h"
+
+/*
+==============================================================
+
+VIRTUAL MACHINE
+
+==============================================================
+*/
+
+typedef struct vm_s vm_t;
+
+typedef enum {
+ VMI_NATIVE,
+ VMI_BYTECODE,
+ VMI_COMPILED
+} vmInterpret_t;
+
+typedef enum {
+ TRAP_MEMSET = 100,
+ TRAP_MEMCPY,
+ TRAP_STRNCPY,
+ TRAP_SIN,
+ TRAP_COS,
+ TRAP_ATAN2,
+ TRAP_SQRT,
+ TRAP_MATRIXMULTIPLY,
+ TRAP_ANGLEVECTORS,
+ TRAP_PERPENDICULARVECTOR,
+ TRAP_FLOOR,
+ TRAP_CEIL,
+
+ TRAP_TESTPRINTINT,
+ TRAP_TESTPRINTFLOAT
+} sharedTraps_t;
+
+void VM_Init( void );
+vm_t *VM_Create( const char *module, intptr_t (*systemCalls)(intptr_t *), 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);
+void VM_Forced_Unload_Done(void);
+void VM_ClearCallLevel(vm_t *vm);
+vm_t *VM_Restart(vm_t *vm, bool unpure);
+
+intptr_t QDECL VM_Call( vm_t *vm, int callNum, ... );
+
+void VM_Debug( int level );
+
+void *VM_ArgPtr( intptr_t intValue );
+void *VM_ExplicitArgPtr( vm_t *vm, intptr_t intValue );
+
+#define VMA(x) VM_ArgPtr(args[x])
+static ID_INLINE float _vmf(intptr_t x)
+{
+ floatint_t fi;
+ fi.i = (int) x;
+ return fi.f;
+}
+#define VMF(x) _vmf(args[x])
+
+#endif