diff options
author | Paul Gilbert | 2019-04-17 21:18:46 -0700 |
---|---|---|
committer | Paul Gilbert | 2019-04-17 21:18:46 -0700 |
commit | 4d9991668e044d5a001e8efcaf821d5f20c647c6 (patch) | |
tree | 7e0d773db70cbb3a38949490fd0abcbf26d282f2 /engines/glk/glulxe | |
parent | 4ff974778cdd81b6f6b528a1a96667764b12f70e (diff) | |
download | scummvm-rg350-4d9991668e044d5a001e8efcaf821d5f20c647c6.tar.gz scummvm-rg350-4d9991668e044d5a001e8efcaf821d5f20c647c6.tar.bz2 scummvm-rg350-4d9991668e044d5a001e8efcaf821d5f20c647c6.zip |
GLK: GLULXE: Compilation fixes by moving a bunch of macros to be actual methods
Diffstat (limited to 'engines/glk/glulxe')
-rw-r--r-- | engines/glk/glulxe/funcs.cpp | 4 | ||||
-rw-r--r-- | engines/glk/glulxe/glkop.cpp | 116 | ||||
-rw-r--r-- | engines/glk/glulxe/glulxe.h | 41 |
3 files changed, 108 insertions, 53 deletions
diff --git a/engines/glk/glulxe/funcs.cpp b/engines/glk/glulxe/funcs.cpp index 4af52630a3..a6ed1a1f99 100644 --- a/engines/glk/glulxe/funcs.cpp +++ b/engines/glk/glulxe/funcs.cpp @@ -36,14 +36,14 @@ void Glulxe::enter_function(uint funcaddr, uint argc, uint *argv) { accelFunc = accel_get_func(addr); if (accelFunc) { - profile_in(addr, stackptr, TRUE); + profile_in(addr, stackptr, true); val = (this->*accelFunc)(argc, argv); profile_out(stackptr); pop_callstub(val); return; } - profile_in(addr, stackptr, FALSE); + profile_in(addr, stackptr, false); /* Check the Glulx type identifier byte. */ functype = Mem1(addr); diff --git a/engines/glk/glulxe/glkop.cpp b/engines/glk/glulxe/glkop.cpp index cb912ecb19..22031cc878 100644 --- a/engines/glk/glulxe/glkop.cpp +++ b/engines/glk/glulxe/glkop.cpp @@ -65,43 +65,6 @@ namespace Glulxe { To work this code over for a new VM, just diddle the macros. */ -#define ReadMemory(addr) \ - (((addr) == 0xffffffff) \ - ? (stackptr -= 4, Stk4(stackptr)) \ - : (Mem4(addr))) -#define WriteMemory(addr, val) \ - (((addr) == 0xffffffff) \ - ? (StkW4(stackptr, (val)), stackptr += 4) \ - : (MemW4((addr), (val)))) -#define CaptureCArray(addr, len, passin) \ - (grab_temp_c_array(addr, len, passin)) -#define ReleaseCArray(ptr, addr, len, passout) \ - (release_temp_c_array(ptr, addr, len, passout)) -#define CaptureIArray(addr, len, passin) \ - (grab_temp_i_array(addr, len, passin)) -#define ReleaseIArray(ptr, addr, len, passout) \ - (release_temp_i_array(ptr, addr, len, passout)) -#define CapturePtrArray(addr, len, objclass, passin) \ - (grab_temp_ptr_array(addr, len, objclass, passin)) -#define ReleasePtrArray(ptr, addr, len, objclass, passout) \ - (release_temp_ptr_array(ptr, addr, len, objclass, passout)) -#define ReadStructField(addr, fieldnum) \ - (((addr) == 0xffffffff) \ - ? (stackptr -= 4, Stk4(stackptr)) \ - : (Mem4((addr)+(fieldnum)*4))) -#define WriteStructField(addr, fieldnum, val) \ - (((addr) == 0xffffffff) \ - ? (StkW4(stackptr, (val)), stackptr += 4) \ - : (MemW4((addr)+(fieldnum)*4, (val)))) -#define DecodeVMString(addr) \ - (make_temp_string(addr)) -#define ReleaseVMString(ptr) \ - (free_temp_string(ptr)) -#define DecodeVMUstring(addr) \ - (make_temp_ustring(addr)) -#define ReleaseVMUstring(ptr) \ - (free_temp_ustring(ptr)) - static gidispatch_rock_t classtable_register(void *obj, uint objclass) { return g_vm->glulxe_classtable_register(obj, objclass); } @@ -125,9 +88,6 @@ void Glulxe::glkopInit() { classes = nullptr; } -/* init_dispatch(): - Set up the class hash tables and other startup-time stuff. -*/ bool Glulxe::init_dispatch() { int ix; @@ -1338,5 +1298,81 @@ char *Glulxe::get_game_id() { return buf; } +uint Glulxe::ReadMemory(uint addr) { + if (addr == 0xffffffff) { + stackptr -= 4; + return Stk4(stackptr); + } else { + return Mem4(addr); + } +} + +void Glulxe::WriteMemory(uint addr, uint val) { + if (addr == 0xffffffff) { + StkW4(stackptr, (val)); + stackptr += 4; + } else { + MemW4(addr, val); + } +} + +char *Glulxe::CaptureCArray(uint addr, uint len, int passin) { + return grab_temp_c_array(addr, len, passin); +} + +void Glulxe::ReleaseCArray(char *ptr, uint addr, uint len, int passout) { + release_temp_c_array(ptr, addr, len, passout); +} + +uint *Glulxe::CaptureIArray(uint addr, uint len, int passin) { + return grab_temp_i_array(addr, len, passin); +} + +void Glulxe::ReleaseIArray(uint *ptr, uint addr, uint len, int passout) { + release_temp_i_array(ptr, addr, len, passout); +} + +void **Glulxe::CapturePtrArray(uint addr, uint len, int objclass, int passin) { + return grab_temp_ptr_array(addr, len, objclass, passin); +} + +void Glulxe::ReleasePtrArray(void **ptr, uint addr, uint len, int objclass, int passout) { + return release_temp_ptr_array(ptr, addr, len, objclass, passout); +} + +uint Glulxe::ReadStructField(uint addr, uint fieldnum) { + if (addr == 0xffffffff) { + stackptr -= 4; + return Stk4(stackptr); + } else { + return Mem4(addr + (fieldnum * 4)); + } +} + +void Glulxe::WriteStructField(uint addr, uint fieldnum, uint val) { + if (addr == 0xffffffff) { + StkW4(stackptr, val); + stackptr += 4; + } else { + MemW4(addr + (fieldnum * 4), val); + } +} + +char *Glulxe::DecodeVMString(uint addr) { + return make_temp_string(addr); +} + +void Glulxe::ReleaseVMString(char *ptr) { + free_temp_string(ptr); +} + +uint *Glulxe::DecodeVMUstring(uint addr) { + return make_temp_ustring(addr); +} + +void Glulxe::ReleaseVMUstring(uint *ptr) { + free_temp_ustring(ptr); +} + } // End of namespace Glulxe } // End of namespace Glk diff --git a/engines/glk/glulxe/glulxe.h b/engines/glk/glulxe/glulxe.h index b985beb7c4..358563f00b 100644 --- a/engines/glk/glulxe/glulxe.h +++ b/engines/glk/glulxe/glulxe.h @@ -314,6 +314,21 @@ protected: */ char *get_game_id(); + uint ReadMemory(uint addr); + void WriteMemory(uint addr, uint val); + char *CaptureCArray(uint addr, uint len, int passin); + void ReleaseCArray(char *ptr, uint addr, uint len, int passout); + uint *CaptureIArray(uint addr, uint len, int passin); + void ReleaseIArray(uint *ptr, uint addr, uint len, int passout); + void **CapturePtrArray(uint addr, uint len, int objclass, int passin); + void ReleasePtrArray(void **ptr, uint addr, uint len, int objclass, int passout); + uint ReadStructField(uint addr, uint fieldnum); + void WriteStructField(uint addr, uint fieldnum, uint val); + char *DecodeVMString(uint addr); + void ReleaseVMString(char *ptr); + uint *DecodeVMUstring(uint addr); + void ReleaseVMUstring(uint *ptr); + /**@}*/ /** @@ -732,6 +747,9 @@ public: void set_library_select_hook(void(*func)(uint)); + /** + * Set up the class hash tables and other startup-time stuff. + */ bool init_dispatch(); /** @@ -793,22 +811,23 @@ public: void setup_profile(strid_t stream, char *filename); int init_profile(); void profile_set_call_counts(int flag); -#if VM_PROFILING + + #if VM_PROFILING uint profile_opcount; -#define profile_tick() (profile_opcount++) + #define profile_tick() (profile_opcount++) int profile_profiling_active(); void profile_in(uint addr, uint stackuse, int accel); void profile_out(uint stackuse); - void profile_fail(char *reason); + void profile_fail(const char *reason); void profile_quit(); -#else /* VM_PROFILING */ -#define profile_tick() (0) -#define profile_profiling_active() (0) -#define profile_in(addr, stackuse, accel) (0) -#define profile_out(stackuse) (0) -#define profile_fail(reason) (0) -#define profile_quit() (0) -#endif /* VM_PROFILING */ + #else /* VM_PROFILING */ + void profile_tick() {} + void profile_profiling_active() {} + void profile_in(uint addr, uint stackuse, int accel) {} + void profile_out(uint stackuse) {} + void profile_fail(const char *reason) {} + void profile_quit() {} + #endif /* VM_PROFILING */ #if VM_DEBUGGER unsigned long debugger_opcount; |