aboutsummaryrefslogtreecommitdiff
path: root/engines/glk/glulxe/glulxe_types.h
diff options
context:
space:
mode:
authorPaul Gilbert2019-04-14 21:07:25 -0700
committerPaul Gilbert2019-04-17 20:46:06 -0700
commit6307fd08ce7cbb0b939f520f9741aef884f66f88 (patch)
tree22d665b969305df24735777df38ac638a9b7a29f /engines/glk/glulxe/glulxe_types.h
parentc3ebb5e68a0b36d992a48b508ab15c13a2edfd9c (diff)
downloadscummvm-rg350-6307fd08ce7cbb0b939f520f9741aef884f66f88.tar.gz
scummvm-rg350-6307fd08ce7cbb0b939f520f9741aef884f66f88.tar.bz2
scummvm-rg350-6307fd08ce7cbb0b939f520f9741aef884f66f88.zip
GLK: GLULXE: Added exec methods
Diffstat (limited to 'engines/glk/glulxe/glulxe_types.h')
-rw-r--r--engines/glk/glulxe/glulxe_types.h218
1 files changed, 176 insertions, 42 deletions
diff --git a/engines/glk/glulxe/glulxe_types.h b/engines/glk/glulxe/glulxe_types.h
index b06e43536a..b4c9a14569 100644
--- a/engines/glk/glulxe/glulxe_types.h
+++ b/engines/glk/glulxe/glulxe_types.h
@@ -26,53 +26,53 @@
#include "common/scummsys.h"
namespace Glk {
-namespace Glulxe {
+ namespace Glulxe {
-class Glulxe;
+ class Glulxe;
-/**
- * Comment this definition to turn off memory-address checking. With verification on,
- * all reads and writes to main memory will be checked to ensure they're in range.
- * This is slower, but prevents malformed game files from crashing the interpreter.
- */
+ /**
+ * Comment this definition to turn off memory-address checking. With verification on,
+ * all reads and writes to main memory will be checked to ensure they're in range.
+ * This is slower, but prevents malformed game files from crashing the interpreter.
+ */
#define VERIFY_MEMORY_ACCESS (1)
-/**
- * Uncomment this definition to permit an exception for memory-address checking for @glk and @copy
- * opcodes that try to write to memory address 0. This was a bug in old Superglus-built game files.
- */
-/* #define TOLERATE_SUPERGLUS_BUG (1) */
+ /**
+ * Uncomment this definition to permit an exception for memory-address checking for @glk and @copy
+ * opcodes that try to write to memory address 0. This was a bug in old Superglus-built game files.
+ */
+ /* #define TOLERATE_SUPERGLUS_BUG (1) */
-/**
- * Uncomment this definition to turn on Glulx VM profiling. In this mode, all function calls are timed,
- * and the timing information is written to a data file called "profile-raw".
- * (Build note: on Linux, glibc may require you to also define _BSD_SOURCE or _DEFAULT_SOURCE or both
- * for the timeradd() macro.)
- */
-/* #define VM_PROFILING (1) */
+ /**
+ * Uncomment this definition to turn on Glulx VM profiling. In this mode, all function calls are timed,
+ * and the timing information is written to a data file called "profile-raw".
+ * (Build note: on Linux, glibc may require you to also define _BSD_SOURCE or _DEFAULT_SOURCE or both
+ * for the timeradd() macro.)
+ */
+ /* #define VM_PROFILING (1) */
-/**
- * Uncomment this definition to turn on the Glulx debugger. You should only do this when debugging
- * facilities are desired; it slows down the interpreter. If you do, you will need to build with libxml2;
- * see the Makefile.
- */
-/* #define VM_DEBUGGER (1) */
+ /**
+ * Uncomment this definition to turn on the Glulx debugger. You should only do this when debugging
+ * facilities are desired; it slows down the interpreter. If you do, you will need to build with libxml2;
+ * see the Makefile.
+ */
+ /* #define VM_DEBUGGER (1) */
-/**
- * Comment this definition to turn off floating-point support. You might need to do this if you are building
- * on a very limited platform with no math library. */
+ /**
+ * Comment this definition to turn off floating-point support. You might need to do this if you are building
+ * on a very limited platform with no math library. */
#define FLOAT_SUPPORT (1)
-/**
- * Comment this definition to not cache the original state of RAM in (real) memory. This saves some memory,
- * but slows down save/restore/undo operations, which will have to read the original state off disk
- * every time.
- */
+ /**
+ * Comment this definition to not cache the original state of RAM in (real) memory. This saves some memory,
+ * but slows down save/restore/undo operations, which will have to read the original state off disk
+ * every time.
+ */
#define SERIALIZE_CACHE_RAM (1)
-/**
- * Some macros to read and write integers to memory, always in big-endian format.
- */
+ /**
+ * Some macros to read and write integers to memory, always in big-endian format.
+ */
#define Read4(ptr) READ_BE_UINT32(ptr)
#define Read2(ptr) READ_BE_UINT16(ptr)
#define Read1(ptr) ((byte)(((byte *)(ptr))[0]))
@@ -95,12 +95,12 @@ class Glulxe;
#define MemW2(adr, vl) (VerifyW(adr, 2), Write2(memmap+(adr), (vl)))
#define MemW4(adr, vl) (VerifyW(adr, 4), Write4(memmap+(adr), (vl)))
-/**
- * Macros to access values on the stack. These *must* be used with proper alignment!
- * (That is, Stk4 and StkW4 must take addresses which are multiples of four, etc.)
- * If the alignment rules are not followed, the program will see performance
- * degradation or even crashes, depending on the machine CPU.
- */
+ /**
+ * Macros to access values on the stack. These *must* be used with proper alignment!
+ * (That is, Stk4 and StkW4 must take addresses which are multiples of four, etc.)
+ * If the alignment rules are not followed, the program will see performance
+ * degradation or even crashes, depending on the machine CPU.
+ */
#define Stk1(adr) \
(*((unsigned char *)(stack+(adr))))
#define Stk2(adr) \
@@ -115,6 +115,140 @@ class Glulxe;
#define StkW4(adr, vl) \
(*((uint32 *)(stack+(adr))) = (uint32)(vl))
+enum Opcode {
+ op_nop = 0x00,
+
+ op_add = 0x10,
+ op_sub = 0x11,
+ op_mul = 0x12,
+ op_div = 0x13,
+ op_mod = 0x14,
+ op_neg = 0x15,
+ op_bitand = 0x18,
+ op_bitor = 0x19,
+ op_bitxor = 0x1A,
+ op_bitnot = 0x1B,
+ op_shiftl = 0x1C,
+ op_sshiftr = 0x1D,
+ op_ushiftr = 0x1E,
+
+ op_jump = 0x20,
+ op_jz = 0x22,
+ op_jnz = 0x23,
+ op_jeq = 0x24,
+ op_jne = 0x25,
+ op_jlt = 0x26,
+ op_jge = 0x27,
+ op_jgt = 0x28,
+ op_jle = 0x29,
+ op_jltu = 0x2A,
+ op_jgeu = 0x2B,
+ op_jgtu = 0x2C,
+ op_jleu = 0x2D,
+
+ op_call = 0x30,
+ op_return = 0x31,
+ op_catch = 0x32,
+ op_throw = 0x33,
+ op_tailcall = 0x34,
+
+ op_copy = 0x40,
+ op_copys = 0x41,
+ op_copyb = 0x42,
+ op_sexs = 0x44,
+ op_sexb = 0x45,
+ op_aload = 0x48,
+ op_aloads = 0x49,
+ op_aloadb = 0x4A,
+ op_aloadbit = 0x4B,
+ op_astore = 0x4C,
+ op_astores = 0x4D,
+ op_astoreb = 0x4E,
+ op_astorebit = 0x4F,
+
+ op_stkcount = 0x50,
+ op_stkpeek = 0x51,
+ op_stkswap = 0x52,
+ op_stkroll = 0x53,
+ op_stkcopy = 0x54,
+
+ op_streamchar = 0x70,
+ op_streamnum = 0x71,
+ op_streamstr = 0x72,
+ op_streamunichar = 0x73,
+
+ op_gestalt = 0x100,
+ op_debugtrap = 0x101,
+ op_getmemsize = 0x102,
+ op_setmemsize = 0x103,
+ op_jumpabs = 0x104,
+
+ op_random = 0x110,
+ op_setrandom = 0x111,
+
+ op_quit = 0x120,
+ op_verify = 0x121,
+ op_restart = 0x122,
+ op_save = 0x123,
+ op_restore = 0x124,
+ op_saveundo = 0x125,
+ op_restoreundo = 0x126,
+ op_protect = 0x127,
+
+ op_glk = 0x130,
+
+ op_getstringtbl = 0x140,
+ op_setstringtbl = 0x141,
+ op_getiosys = 0x148,
+ op_setiosys = 0x149,
+
+ op_linearsearch = 0x150,
+ op_binarysearch = 0x151,
+ op_linkedsearch = 0x152,
+
+ op_callf = 0x160,
+ op_callfi = 0x161,
+ op_callfii = 0x162,
+ op_callfiii = 0x163,
+
+ op_mzero = 0x170,
+ op_mcopy = 0x171,
+ op_malloc = 0x178,
+ op_mfree = 0x179,
+
+ op_accelfunc = 0x180,
+ op_accelparam = 0x181,
+
+ op_numtof = 0x190,
+ op_ftonumz = 0x191,
+ op_ftonumn = 0x192,
+ op_ceil = 0x198,
+ op_floor = 0x199,
+ op_fadd = 0x1A0,
+ op_fsub = 0x1A1,
+ op_fmul = 0x1A2,
+ op_fdiv = 0x1A3,
+ op_fmod = 0x1A4,
+ op_sqrt = 0x1A8,
+ op_exp = 0x1A9,
+ op_log = 0x1AA,
+ op_pow = 0x1AB,
+ op_sin = 0x1B0,
+ op_cos = 0x1B1,
+ op_tan = 0x1B2,
+ op_asin = 0x1B3,
+ op_acos = 0x1B4,
+ op_atan = 0x1B5,
+ op_atan2 = 0x1B6,
+ op_jfeq = 0x1C0,
+ op_jfne = 0x1C1,
+ op_jflt = 0x1C2,
+ op_jfle = 0x1C3,
+ op_jfgt = 0x1C4,
+ op_jfge = 0x1C5,
+ op_jisnan = 0x1C8,
+ op_jisinf = 0x1C9
+};
struct dispatch_splot_struct {
int numwanted;