diff options
author | Paul Gilbert | 2018-11-10 22:04:30 -0800 |
---|---|---|
committer | Paul Gilbert | 2018-12-08 19:05:59 -0800 |
commit | f19f92e396e348e095e51becc902cdb5ef62618b (patch) | |
tree | a22fa38da65025e47f03cce2210e77d1621fc7de /engines | |
parent | fc4c3293d10ae25c6792cff8c5648ff4d4369697 (diff) | |
download | scummvm-rg350-f19f92e396e348e095e51becc902cdb5ef62618b.tar.gz scummvm-rg350-f19f92e396e348e095e51becc902cdb5ef62618b.tar.bz2 scummvm-rg350-f19f92e396e348e095e51becc902cdb5ef62618b.zip |
GLK: FROTZ: Move Header to be an ancestor class to Mem
Diffstat (limited to 'engines')
-rw-r--r-- | engines/gargoyle/frotz/err.cpp | 3 | ||||
-rw-r--r-- | engines/gargoyle/frotz/frotz.cpp | 5 | ||||
-rw-r--r-- | engines/gargoyle/frotz/frotz.h | 5 | ||||
-rw-r--r-- | engines/gargoyle/frotz/frotz_types.h | 73 | ||||
-rw-r--r-- | engines/gargoyle/frotz/mem.h | 91 |
5 files changed, 104 insertions, 73 deletions
diff --git a/engines/gargoyle/frotz/err.cpp b/engines/gargoyle/frotz/err.cpp index b25b75c0fc..f9a3ce9580 100644 --- a/engines/gargoyle/frotz/err.cpp +++ b/engines/gargoyle/frotz/err.cpp @@ -85,7 +85,8 @@ void Errors::runtimeError(int errNum) { if ((g_vm->_options._err_report_mode == ERR_REPORT_ALWAYS) || (g_vm->_options._err_report_mode == ERR_REPORT_ONCE && wasfirst)) { - long pc = g_vm->getPC(); + long pc; + GET_PC(pc); printString("Warning: "); printString(ERR_MESSAGES[errNum - 1]); printString(" (PC = "); diff --git a/engines/gargoyle/frotz/frotz.cpp b/engines/gargoyle/frotz/frotz.cpp index d5cdaf33ad..64b9f54449 100644 --- a/engines/gargoyle/frotz/frotz.cpp +++ b/engines/gargoyle/frotz/frotz.cpp @@ -57,10 +57,5 @@ Common::Error Frotz::saveGameState(int slot, const Common::String &desc) { return Common::kNoError; } -uint Frotz::getPC() const { - // TODO - return 0; -} - } // End of namespace Scott } // End of namespace Gargoyle diff --git a/engines/gargoyle/frotz/frotz.h b/engines/gargoyle/frotz/frotz.h index e1fb36c7b4..4dd583449b 100644 --- a/engines/gargoyle/frotz/frotz.h +++ b/engines/gargoyle/frotz/frotz.h @@ -101,11 +101,6 @@ public: * Save the game */ virtual Common::Error saveGameState(int slot, const Common::String &desc) override; - - /** - * Get the current PC - */ - uint getPC() const; }; extern Frotz *g_vm; diff --git a/engines/gargoyle/frotz/frotz_types.h b/engines/gargoyle/frotz/frotz_types.h index 505d656ba8..3c7312c1bc 100644 --- a/engines/gargoyle/frotz/frotz_types.h +++ b/engines/gargoyle/frotz/frotz_types.h @@ -32,6 +32,18 @@ namespace Frotz { #define MAX_UNDO_SLOTS 500 #define STACK_SIZE 20 +#define lo(v) (v & 0xff) +#define hi(v) (v >> 8) + +#define SET_WORD(addr,v) WRITE_BE_UINT16(addr,v) +#define LOW_WORD(addr,v) READ_BE_UINT16(addr,v) +#define HIGH_WORD(addr,v) READ_BE_UINT16(addr,v) +#define HIGH_LONG(addr,v) READ_BE_UINT32(addr,v) +#define CODE_WORD(v) v = g_vm->_mem.readWord() +#define CODE_IDX_WORD(v,i) v = g_vm->_mem.readWord(i) +#define GET_PC(v) v = g_vm->_mem.getPC() +#define SET_PC(v) g_vm->_mem.setPC(v); + /* There are four error reporting modes: never report errors; * report only the first time a given error type occurs; * report every time an error occurs; @@ -134,67 +146,6 @@ struct UserOptions { } }; -/** - * Story file header data - */ -struct Header { - zbyte _version; - zbyte _config; - zword _release; - zword _resident_size; - zword _start_pc; - zword _dictionary; - zword _objects; - zword _globals; - zword _dynamic_size; - zword _flags; - zbyte _serial[6]; - zword _abbreviations; - zword _file_size; - zword _checksum; - zbyte _interpreter_number; - zbyte _interpreter_version; - zbyte _screen_rows; - zbyte _screen_cols; - zword _screen_width; - zword _screen_height; - zbyte _font_height = 1; - zbyte _font_width = 1; - zword _functions_offset; - zword _strings_offset; - zbyte _default_background; - zbyte _default_foreground; - zword _terminating_keys; - zword _line_width; - zbyte _standard_high; - zbyte _standard_low; - zword _alphabet; - zword _extension_table; - zbyte _user_name[8]; - - zword _hx_table_size; - zword _hx_mouse_x; - zword _hx_mouse_y; - zword _hx_unicode_table; - zword _hx_flags; - zword _hx_fore_colour; - zword _hx_back_colour; - - Header() : _version(0), _config(0), _release(0), _resident_size(0), _start_pc(0), - _dictionary(0), _objects(0), _globals(0), _dynamic_size(0), _flags(0), - _abbreviations(0), _file_size(0), _checksum(0), _interpreter_number(0), - _interpreter_version(0), _screen_rows(0), _screen_cols(0), _screen_width(0), - _screen_height(0), _font_height(1), _font_width(1), _functions_offset(0), - _strings_offset(0), _default_background(0), _default_foreground(0), - _terminating_keys(0), _line_width(0), _standard_high(1), _standard_low(1), - _alphabet(0), _extension_table(0), - _hx_table_size(0), _hx_mouse_x(0), _hx_mouse_y(0), _hx_unicode_table(0), - _hx_flags(0), _hx_fore_colour(0), _hx_back_colour(0) { - Common::fill(&_serial[0], &_serial[6], '\0'); - Common::fill(&_user_name[0], &_user_name[8], '\0'); - } -}; - } // End of namespace Frotz } // End of namespace Gargoyle diff --git a/engines/gargoyle/frotz/mem.h b/engines/gargoyle/frotz/mem.h index 8882a582c4..68c7b85ece 100644 --- a/engines/gargoyle/frotz/mem.h +++ b/engines/gargoyle/frotz/mem.h @@ -28,7 +28,69 @@ namespace Gargoyle { namespace Frotz { -class Mem { + +/** + * Story file header data + */ +struct Header { + zbyte h_version; + zbyte h_config; + zword h_release; + zword h_resident_size; + zword h_start_pc; + zword h_dictionary; + zword h_objects; + zword h_globals; + zword h_dynamic_size; + zword h_flags; + zbyte h_serial[6]; + zword h_abbreviations; + zword h_file_size; + zword h_checksum; + zbyte h_interpreter_number; + zbyte h_interpreter_version; + zbyte h_screen_rows; + zbyte h_screen_cols; + zword h_screen_width; + zword h_screen_height; + zbyte h_font_height = 1; + zbyte h_font_width = 1; + zword h_functions_offset; + zword h_strings_offset; + zbyte h_default_background; + zbyte h_default_foreground; + zword h_terminating_keys; + zword h_line_width; + zbyte h_standard_high; + zbyte h_standard_low; + zword h_alphabet; + zword h_extension_table; + zbyte h_user_name[8]; + + zword hx_table_size; + zword hx_mouse_x; + zword hx_mouse_y; + zword hx_unicode_table; + zword hx_flags; + zword hx_fore_colour; + zword hx_back_colour; + + Header() : h_version(0), h_config(0), h_release(0), h_resident_size(0), h_start_pc(0), + h_dictionary(0), h_objects(0), h_globals(0), h_dynamic_size(0), h_flags(0), + h_abbreviations(0), h_file_size(0), h_checksum(0), h_interpreter_number(0), + h_interpreter_version(0), h_screen_rows(0), h_screen_cols(0), h_screen_width(0), + h_screen_height(0), h_font_height(1), h_font_width(1), h_functions_offset(0), + h_strings_offset(0), h_default_background(0), h_default_foreground(0), + h_terminating_keys(0), h_line_width(0), h_standard_high(1), h_standard_low(1), + h_alphabet(0), h_extension_table(0), + hx_table_size(0), hx_mouse_x(0), hx_mouse_y(0), hx_unicode_table(0), + hx_flags(0), hx_fore_colour(0), hx_back_colour(0) { + Common::fill(&h_serial[0], &h_serial[6], '\0'); + Common::fill(&h_user_name[0], &h_user_name[8], '\0'); + } +}; + +class Mem : public Header { struct StoryEntry { Story _storyId; zword _release; @@ -38,6 +100,8 @@ class Mem { private: Common::SeekableReadStream *story_fp; uint blorb_ofs, blorb_len; + byte *pcp; + byte *zmp; private: /** * Handles setting the story file, parsing it if it's a Blorb file @@ -53,6 +117,31 @@ public: * Initialize */ void initialize(); + + /** + * Read a word + */ + zword readWord() { + pcp += 2; + return READ_BE_UINT16(pcp - 2); + } + + /** + * Read a word at a given index relative to pcp + */ + zword readWord(size_t ofs) { + return READ_BE_UINT16(pcp + ofs); + } + + /** + * Get the PC + */ + uint getPC() const { return pcp - zmp; } + + /** + * Set the PC + */ + void setPC(uint ofs) { pcp = zmp + ofs; } }; } // End of namespace Frotz |