From ada80dedc0d39d76a2cd3c3b4af6c3219738d0bf Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 18 Nov 2018 11:29:41 -0800 Subject: GLK: FROTZ: Further merging together of configuration into a new config.cpp file --- engines/glk/frotz/config.cpp | 196 +++++++++++++++++++++++++++++++ engines/glk/frotz/config.h | 228 ++++++++++++++++++++++++++++++++++++ engines/glk/frotz/frotz.cpp | 34 +----- engines/glk/frotz/frotz_types.h | 75 ------------ engines/glk/frotz/glk_interface.cpp | 2 +- engines/glk/frotz/header.cpp | 112 ------------------ engines/glk/frotz/header.h | 159 ------------------------- engines/glk/frotz/mem.h | 2 +- engines/glk/frotz/processor.cpp | 10 +- engines/glk/module.mk | 2 +- 10 files changed, 434 insertions(+), 386 deletions(-) create mode 100644 engines/glk/frotz/config.cpp create mode 100644 engines/glk/frotz/config.h delete mode 100644 engines/glk/frotz/header.cpp delete mode 100644 engines/glk/frotz/header.h (limited to 'engines/glk') diff --git a/engines/glk/frotz/config.cpp b/engines/glk/frotz/config.cpp new file mode 100644 index 0000000000..0461e251c5 --- /dev/null +++ b/engines/glk/frotz/config.cpp @@ -0,0 +1,196 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "glk/frotz/config.h" +#include "common/config-manager.h" +#include "common/textconsole.h" + +namespace Glk { +namespace Frotz { + +const Header::StoryEntry Header::RECORDS[25] = { + { SHERLOCK, 21, "871214" }, + { SHERLOCK, 26, "880127" }, + { BEYOND_ZORK, 47, "870915" }, + { BEYOND_ZORK, 49, "870917" }, + { BEYOND_ZORK, 51, "870923" }, + { BEYOND_ZORK, 57, "871221" }, + { ZORK_ZERO, 296, "881019" }, + { ZORK_ZERO, 366, "890323" }, + { ZORK_ZERO, 383, "890602" }, + { ZORK_ZERO, 393, "890714" }, + { SHOGUN, 292, "890314" }, + { SHOGUN, 295, "890321" }, + { SHOGUN, 311, "890510" }, + { SHOGUN, 322, "890706" }, + { ARTHUR, 54, "890606" }, + { ARTHUR, 63, "890622" }, + { ARTHUR, 74, "890714" }, + { JOURNEY, 26, "890316" }, + { JOURNEY, 30, "890322" }, + { JOURNEY, 77, "890616" }, + { JOURNEY, 83, "890706" }, + { LURKING_HORROR, 203, "870506" }, + { LURKING_HORROR, 219, "870912" }, + { LURKING_HORROR, 221, "870918" }, + { UNKNOWN, 0, "------" } +}; + +static uint getConfigBool(const Common::String &profileName, bool defaultVal = false) { + return ConfMan.hasKey(profileName) ? ConfMan.getBool(profileName) : defaultVal; +} + +static uint getConfigInt(const Common::String &profileName, uint defaultVal, uint maxVal) { + uint val = ConfMan.hasKey(profileName) ? ConfMan.getInt(profileName) : defaultVal; + if (val > maxVal) + error("Invalid value for configuration value %s", profileName.c_str()); + + return val; +} + +Header::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_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), _storyId(UNKNOWN) { + Common::fill(&h_serial[0], &h_serial[6], '\0'); + Common::fill(&h_user_name[0], &h_user_name[8], '\0'); + + h_interpreter_number = getConfigInt("interpreter_number", INTERP_AMIGA, INTERP_TANDY); + + + if (ConfMan.hasKey("username")) { + Common::String username = ConfMan.get("username"); + strncpy((char *)h_user_name, username.c_str(), 7); + } +} + +void Header::loadHeader(Common::SeekableReadStream &f) { + h_version = f.readByte(); + h_config = f.readByte(); + + if (h_version < V1 || h_version > V8) + error("Unknown Z-code version"); + + if (h_version == V6) + error("Cannot play Z-code version 6"); + + if (h_version == V3 && (h_config & CONFIG_BYTE_SWAPPED)) + error("Byte swapped story file"); + + h_release = f.readUint16BE(); + h_resident_size = f.readUint16BE(); + h_start_pc = f.readUint16BE(); + h_dictionary = f.readUint16BE(); + h_objects = f.readUint16BE(); + h_globals = f.readUint16BE(); + h_dynamic_size = f.readUint16BE(); + h_flags = f.readUint16BE(); + f.read(h_serial, 6); + + /* Auto-detect buggy story files that need special fixes */ + _storyId = UNKNOWN; + + for (int i = 0; RECORDS[i]._storyId != UNKNOWN; ++i) { + if (h_release == RECORDS[i]._release) { + if (!strncmp((const char *)h_serial, RECORDS[i]._serial, 6)) { + _storyId = RECORDS[i]._storyId; + break; + } + } + } + + h_abbreviations = f.readUint16BE(); + h_file_size = f.readUint16BE(); + h_checksum = f.readUint16BE(); + + f.seek(H_FUNCTIONS_OFFSET); + h_functions_offset = f.readUint16BE(); + h_strings_offset = f.readUint16BE(); + f.seek(H_TERMINATING_KEYS); + h_terminating_keys = f.readUint16BE(); + f.seek(H_ALPHABET); + h_alphabet = f.readUint16BE(); + h_extension_table = f.readUint16BE(); + + + // Zork Zero Macintosh doesn't have the graphics flag set + if (_storyId == ZORK_ZERO && h_release == 296) + h_flags |= GRAPHICS_FLAG; +} + +/*--------------------------------------------------------------------------*/ + +UserOptions::UserOptions() : _undo_slots(MAX_UNDO_SLOTS), _sound(true) { + _err_report_mode = getConfigInt("err_report_mode", ERR_REPORT_ONCE, ERR_REPORT_FATAL); + _ignore_errors = getConfigBool("ignore_errors"); + _expand_abbreviations = getConfigBool("expand_abbreviations"); + _quetzal = getConfigBool("quetzal", true); + _tandyBit = getConfigBool("tandy_bit"); + _piracy = getConfigBool("piracy"); + _script_cols = getConfigInt("wrap_script_lines", 80, 999); + _left_margin = getConfigInt("left_margin", 0, 999); + _right_margin = getConfigInt("right_margin", 0, 999); + + // Debugging flags + _attribute_assignment = getConfigBool("attribute_assignment"); + _attribute_testing = getConfigBool("attribute_testing"); + _object_locating = getConfigBool("object_locating"); + _object_movement = getConfigBool("object_movement"); +} + +#ifdef REMOVE_ME +if (ConfMan.hasKey("attribute_assignment") && ConfMan.getBool("attribute_assignment")) +_attribute_assignment = true; +if (ConfMan.hasKey("attribute_testing") && ConfMan.getBool("attribute_testing")) +_attribute_testing = true; +if (ConfMan.hasKey("object_movement") && ConfMan.getBool("object_movement")) +_object_movement = true; +if (ConfMan.hasKey("object_locating") && ConfMan.getBool("object_locating")) +_object_locating = true; +if (ConfMan.hasKey("piracy") && ConfMan.getBool("piracy")) +_piracy = true; +if (ConfMan.hasKey("random_seed")) +_random.setSeed(ConfMan.getInt("random_seed")); +if (ConfMan.hasKey("script_cols")) +_script_cols = ConfMan.getInt("script_cols"); +if (ConfMan.hasKey("tandy_bit") && ConfMan.getBool("tandy_bit")) +_user_tandy_bit = true; +if (ConfMan.hasKey("undo_slots")) +_undo_slots = ConfMan.getInt("undo_slots"); +if (ConfMan.hasKey("expand_abbreviations") && ConfMan.getBool("expand_abbreviations")) +_expand_abbreviations = true; +if (ConfMan.hasKey("err_report_mode")) { + _err_report_mode = ConfMan.getInt("err_report_mode"); + if ((_err_report_mode < ERR_REPORT_NEVER) || (_err_report_mode > ERR_REPORT_FATAL)) + _err_report_mode = ERR_DEFAULT_REPORT_MODE; +} + +#endif + +} // End of namespace Scott +} // End of namespace Glk diff --git a/engines/glk/frotz/config.h b/engines/glk/frotz/config.h new file mode 100644 index 0000000000..a210ba29a0 --- /dev/null +++ b/engines/glk/frotz/config.h @@ -0,0 +1,228 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef GLK_FROTZ_CONFIG +#define GLK_FROTZ_CONFIG + +#include "glk/frotz/frotz_types.h" + +namespace Glk { +namespace Frotz { + +/** + * Configuration flags + */ +enum ConfigFlag { + CONFIG_BYTE_SWAPPED = 0x01, ///< Story file is byte swapped - V3 + CONFIG_TIME = 0x02, ///< Status line displays time - V3 + CONFIG_TWODISKS = 0x04, ///< Story file occupied two disks - V3 + CONFIG_TANDY = 0x08, ///< Tandy licensed game - V3 + CONFIG_NOSTATUSLINE = 0x10, ///< Interpr can't support status lines - V3 + CONFIG_SPLITSCREEN = 0x20, ///< Interpr supports split screen mode - V3 + CONFIG_PROPORTIONAL = 0x40, ///< Interpr uses proportional font - V3 + + CONFIG_COLOUR = 0x01, ///< Interpr supports colour - V5+ + CONFIG_PICTURES = 0x02, ///< Interpr supports pictures - V6 + CONFIG_BOLDFACE = 0x04, ///< Interpr supports boldface style - V4+ + CONFIG_EMPHASIS = 0x08, ///< Interpr supports emphasis style - V4+ + CONFIG_FIXED = 0x10, ///< Interpr supports fixed width style - V4+ + CONFIG_SOUND = 0x20, ///< Interpr supports sound - V6 + CONFIG_TIMEDINPUT = 0x80, ///< Interpr supports timed input - V4+ + + SCRIPTING_FLAG = 0x0001, ///< Outputting to transscription file - V1+ + FIXED_FONT_FLAG = 0x0002, ///< Use fixed width font - V3+ + REFRESH_FLAG = 0x0004, ///< Refresh the screen - V6 + GRAPHICS_FLAG = 0x0008, ///< Game wants to use graphics - V5+ + OLD_SOUND_FLAG = 0x0010, ///< Game wants to use sound effects - V3 + UNDO_FLAG = 0x0010, ///< Game wants to use UNDO feature - V5+ + MOUSE_FLAG = 0x0020, ///< Game wants to use a mouse - V5+ + COLOUR_FLAG = 0x0040, ///< Game wants to use colours - V5+ + SOUND_FLAG = 0x0080, ///< Game wants to use sound effects - V5+ + MENU_FLAG = 0x0100 ///< Game wants to use menus - V6 +}; + +/** + * 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; + * or treat all errors as fatal errors, killing the interpreter. + * I strongly recommend "report once" as the default. But you can compile in a + * different default by changing the definition of ERR_DEFAULT_REPORT_MODE. + */ +enum ErrorReport { + ERR_REPORT_NEVER = 0, + ERR_REPORT_ONCE = 1, + ERR_REPORT_ALWAYS = 2, + ERR_REPORT_FATAL = 3, + + ERR_DEFAULT_REPORT_MODE = ERR_REPORT_NEVER +}; + +/** + * Enumeration of the game header byte indexes + */ +enum HeaderByte { + H_VERSION = 0, + H_CONFIG = 1, + H_RELEASE = 2, + H_RESIDENT_SIZE = 4, + H_START_PC = 6, + H_DICTIONARY = 8, + H_OBJECTS = 10, + H_GLOBALS = 12, + H_DYNAMIC_SIZE = 14, + H_FLAGS = 16, + H_SERIAL = 18, + H_ABBREVIATIONS = 24, + H_FILE_SIZE = 26, + H_CHECKSUM = 28, + H_INTERPRETER_NUMBER = 30, + H_INTERPRETER_VERSION = 31, + H_SCREEN_ROWS = 32, + H_SCREEN_COLS = 33, + H_SCREEN_WIDTH = 34, + H_SCREEN_HEIGHT = 36, + H_FONT_HEIGHT = 38, ///< this is the font width in V5 + H_FONT_WIDTH = 39, ///< this is the font height in V5 + H_FUNCTIONS_OFFSET = 40, + H_STRINGS_OFFSET = 42, + H_DEFAULT_BACKGROUND = 44, + H_DEFAULT_FOREGROUND = 45, + H_TERMINATING_KEYS = 46, + H_LINE_WIDTH = 48, + H_STANDARD_HIGH = 50, + H_STANDARD_LOW = 51, + H_ALPHABET = 52, + H_EXTENSION_TABLE = 54, + H_USER_NAME = 56 +}; + +/** + * Header extension fields + */ +enum { + HX_TABLE_SIZE = 0, + HX_MOUSE_X = 1, + HX_MOUSE_Y = 2, + HX_UNICODE_TABLE = 3, + HX_FLAGS = 4, + HX_FORE_COLOUR = 5, + HX_BACK_COLOUR = 6 +}; + +/** + * User options + */ +struct UserOptions { + bool _attribute_assignment; + bool _attribute_testing; + bool _object_locating; + bool _object_movement; + bool _expand_abbreviations; + bool _ignore_errors; + bool _piracy; + bool _quetzal; + bool _sound; + bool _tandyBit; + int _left_margin; + int _right_margin; + int _undo_slots; + int _script_cols; + int _err_report_mode; + + /** + * Constructor + */ + UserOptions(); +}; + +/** + * Story file header data + */ +struct Header { +private: + struct StoryEntry { + Story _storyId; + zword _release; + char _serial[7]; + }; + static const StoryEntry RECORDS[25]; +public: + 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; + zbyte h_font_width; + 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; + + Story _storyId; + + /** + * Constructor + */ + Header(); + + /** + * Load the header + */ + void loadHeader(Common::SeekableReadStream &f); +}; + +} // End of namespace Frotz +} // End of namespace Glk + +#endif diff --git a/engines/glk/frotz/frotz.cpp b/engines/glk/frotz/frotz.cpp index 344aa92b12..58287900d9 100644 --- a/engines/glk/frotz/frotz.cpp +++ b/engines/glk/frotz/frotz.cpp @@ -47,36 +47,6 @@ void Frotz::runGame(Common::SeekableReadStream *gameFile) { } void Frotz::initialize() { - if (ConfMan.hasKey("attribute_assignment") && ConfMan.getBool("attribute_assignment")) - _attribute_assignment = true; - if (ConfMan.hasKey("attribute_testing") && ConfMan.getBool("attribute_testing")) - _attribute_testing = true; - if (ConfMan.hasKey("ignore_errors") && ConfMan.getBool("ignore_errors")) - _ignore_errors = true; - if (ConfMan.hasKey("object_movement") && ConfMan.getBool("object_movement")) - _object_movement = true; - if (ConfMan.hasKey("object_locating") && ConfMan.getBool("object_locating")) - _object_locating = true; - if (ConfMan.hasKey("piracy") && ConfMan.getBool("piracy")) - _piracy = true; - if (ConfMan.hasKey("save_quetzal") && ConfMan.getBool("save_quetzal")) - _save_quetzal = true; - if (ConfMan.hasKey("random_seed")) - _random.setSeed(ConfMan.getInt("random_seed")); - if (ConfMan.hasKey("script_cols")) - _script_cols = ConfMan.getInt("script_cols"); - if (ConfMan.hasKey("tandy_bit") && ConfMan.getBool("tandy_bit")) - _user_tandy_bit = true; - if (ConfMan.hasKey("undo_slots")) - _undo_slots = ConfMan.getInt("undo_slots"); - if (ConfMan.hasKey("expand_abbreviations") && ConfMan.getBool("expand_abbreviations")) - _expand_abbreviations = true; - if (ConfMan.hasKey("err_report_mode")) { - _err_report_mode = ConfMan.getInt("err_report_mode"); - if ((_err_report_mode < ERR_REPORT_NEVER) || (_err_report_mode > ERR_REPORT_FATAL)) - _err_report_mode = ERR_DEFAULT_REPORT_MODE; - } - // Call process initialization Processor::initialize(); @@ -97,7 +67,7 @@ Common::Error Frotz::saveGameData(strid_t file) { if ((gfp = frotzopenprompt(FILE_SAVE)) == nullptr) goto finished; - if (_save_quetzal) { + if (_quetzal) { success = save_quetzal(gfp, story_fp, blorb_ofs); } else { @@ -164,7 +134,7 @@ Common::Error Frotz::loadGameData(strid_t file) { if ((gfp = frotzopenprompt(FILE_RESTORE)) == nullptr) goto finished; - if (_save_quetzal) { + if (_quetzal) { success = restore_quetzal (gfp, story_fp, blorb_ofs); } else { diff --git a/engines/glk/frotz/frotz_types.h b/engines/glk/frotz/frotz_types.h index e68f55e147..bf3067fd04 100644 --- a/engines/glk/frotz/frotz_types.h +++ b/engines/glk/frotz/frotz_types.h @@ -35,22 +35,6 @@ namespace Frotz { #define lo(v) (v & 0xff) #define hi(v) (v >> 8) -/* 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; - * or treat all errors as fatal errors, killing the interpreter. - * I strongly recommend "report once" as the default. But you can compile in a - * different default by changing the definition of ERR_DEFAULT_REPORT_MODE. - */ -enum ErrorReport { - ERR_REPORT_NEVER = 0, - ERR_REPORT_ONCE = 1, - ERR_REPORT_ALWAYS = 2, - ERR_REPORT_FATAL = 3, - - ERR_DEFAULT_REPORT_MODE = ERR_REPORT_NEVER -}; - /** * Character codes */ @@ -116,35 +100,6 @@ enum Version { V9 = 9 }; -enum ConfigFlag { - CONFIG_BYTE_SWAPPED = 0x01, ///< Story file is byte swapped - V3 - CONFIG_TIME = 0x02, ///< Status line displays time - V3 - CONFIG_TWODISKS = 0x04, ///< Story file occupied two disks - V3 - CONFIG_TANDY = 0x08, ///< Tandy licensed game - V3 - CONFIG_NOSTATUSLINE = 0x10, ///< Interpr can't support status lines - V3 - CONFIG_SPLITSCREEN = 0x20, ///< Interpr supports split screen mode - V3 - CONFIG_PROPORTIONAL = 0x40, ///< Interpr uses proportional font - V3 - - CONFIG_COLOUR = 0x01, ///< Interpr supports colour - V5+ - CONFIG_PICTURES = 0x02, ///< Interpr supports pictures - V6 - CONFIG_BOLDFACE = 0x04, ///< Interpr supports boldface style - V4+ - CONFIG_EMPHASIS = 0x08, ///< Interpr supports emphasis style - V4+ - CONFIG_FIXED = 0x10, ///< Interpr supports fixed width style - V4+ - CONFIG_SOUND = 0x20, ///< Interpr supports sound - V6 - CONFIG_TIMEDINPUT = 0x80, ///< Interpr supports timed input - V4+ - - SCRIPTING_FLAG = 0x0001, ///< Outputting to transscription file - V1+ - FIXED_FONT_FLAG = 0x0002, ///< Use fixed width font - V3+ - REFRESH_FLAG = 0x0004, ///< Refresh the screen - V6 - GRAPHICS_FLAG = 0x0008, ///< Game wants to use graphics - V5+ - OLD_SOUND_FLAG = 0x0010, ///< Game wants to use sound effects - V3 - UNDO_FLAG = 0x0010, ///< Game wants to use UNDO feature - V5+ - MOUSE_FLAG = 0x0020, ///< Game wants to use a mouse - V5+ - COLOUR_FLAG = 0x0040, ///< Game wants to use colours - V5+ - SOUND_FLAG = 0x0080, ///< Game wants to use sound effects - V5+ - MENU_FLAG = 0x0100 ///< Game wants to use menus - V6 -}; - enum { TRANSPARENT_FLAG = 0x0001 ///< Game wants to use transparency - V6 }; @@ -249,36 +204,6 @@ typedef byte zbyte; typedef uint zchar; typedef uint16 zword; -/** - * User options - */ -struct UserOptions { - int _attribute_assignment; - int _attribute_testing; - int _context_lines; - int _object_locating; - int _object_movement; - int _left_margin; - int _right_margin; - bool _ignore_errors; - bool _piracy; - int _undo_slots; - int _expand_abbreviations; - int _script_cols; - bool _save_quetzal; - int _err_report_mode; - bool _sound; - bool _user_tandy_bit; - - UserOptions() : _attribute_assignment(0), _attribute_testing(0), - _context_lines(0), _object_locating(0), _object_movement(0), - _left_margin(0), _right_margin(0), _ignore_errors(false), _piracy(false), - _undo_slots(MAX_UNDO_SLOTS), _expand_abbreviations(0), _script_cols(80), - _save_quetzal(true), _err_report_mode(ERR_DEFAULT_REPORT_MODE), _sound(true), - _user_tandy_bit(false) { - } -}; - #define MAX_NESTING 16 struct Redirect { zword _xSize; diff --git a/engines/glk/frotz/glk_interface.cpp b/engines/glk/frotz/glk_interface.cpp index 292409ff7a..477891ad70 100644 --- a/engines/glk/frotz/glk_interface.cpp +++ b/engines/glk/frotz/glk_interface.cpp @@ -110,7 +110,7 @@ void GlkInterface::initialize() { * Icky magic bit setting */ - if (h_version == V3 && _user_tandy_bit) + if (h_version == V3 && _tandyBit) h_config |= CONFIG_TANDY; if (h_version == V3 && gos_upper) diff --git a/engines/glk/frotz/header.cpp b/engines/glk/frotz/header.cpp deleted file mode 100644 index f7ebb5ec00..0000000000 --- a/engines/glk/frotz/header.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "glk/frotz/header.h" -#include "common/textconsole.h" - -namespace Glk { -namespace Frotz { - -const Header::StoryEntry Header::RECORDS[25] = { - { SHERLOCK, 21, "871214" }, - { SHERLOCK, 26, "880127" }, - { BEYOND_ZORK, 47, "870915" }, - { BEYOND_ZORK, 49, "870917" }, - { BEYOND_ZORK, 51, "870923" }, - { BEYOND_ZORK, 57, "871221" }, - { ZORK_ZERO, 296, "881019" }, - { ZORK_ZERO, 366, "890323" }, - { ZORK_ZERO, 383, "890602" }, - { ZORK_ZERO, 393, "890714" }, - { SHOGUN, 292, "890314" }, - { SHOGUN, 295, "890321" }, - { SHOGUN, 311, "890510" }, - { SHOGUN, 322, "890706" }, - { ARTHUR, 54, "890606" }, - { ARTHUR, 63, "890622" }, - { ARTHUR, 74, "890714" }, - { JOURNEY, 26, "890316" }, - { JOURNEY, 30, "890322" }, - { JOURNEY, 77, "890616" }, - { JOURNEY, 83, "890706" }, - { LURKING_HORROR, 203, "870506" }, - { LURKING_HORROR, 219, "870912" }, - { LURKING_HORROR, 221, "870918" }, - { UNKNOWN, 0, "------" } -}; - -void Header::loadHeader(Common::SeekableReadStream &f) { - h_version = f.readByte(); - h_config = f.readByte(); - - if (h_version < V1 || h_version > V8) - error("Unknown Z-code version"); - - if (h_version == V6) - error("Cannot play Z-code version 6"); - - if (h_version == V3 && (h_config & CONFIG_BYTE_SWAPPED)) - error("Byte swapped story file"); - - h_release = f.readUint16BE(); - h_resident_size = f.readUint16BE(); - h_start_pc = f.readUint16BE(); - h_dictionary = f.readUint16BE(); - h_objects = f.readUint16BE(); - h_globals = f.readUint16BE(); - h_dynamic_size = f.readUint16BE(); - h_flags = f.readUint16BE(); - f.read(h_serial, 6); - - /* Auto-detect buggy story files that need special fixes */ - _storyId = UNKNOWN; - - for (int i = 0; RECORDS[i]._storyId != UNKNOWN; ++i) { - if (h_release == RECORDS[i]._release) { - if (!strncmp((const char *)h_serial, RECORDS[i]._serial, 6)) { - _storyId = RECORDS[i]._storyId; - break; - } - } - } - - h_abbreviations = f.readUint16BE(); - h_file_size = f.readUint16BE(); - h_checksum = f.readUint16BE(); - - f.seek(H_FUNCTIONS_OFFSET); - h_functions_offset = f.readUint16BE(); - h_strings_offset = f.readUint16BE(); - f.seek(H_TERMINATING_KEYS); - h_terminating_keys = f.readUint16BE(); - f.seek(H_ALPHABET); - h_alphabet = f.readUint16BE(); - h_extension_table = f.readUint16BE(); - - - // Zork Zero Macintosh doesn't have the graphics flag set - if (_storyId == ZORK_ZERO && h_release == 296) - h_flags |= GRAPHICS_FLAG; -} - -} // End of namespace Scott -} // End of namespace Glk diff --git a/engines/glk/frotz/header.h b/engines/glk/frotz/header.h deleted file mode 100644 index cf7ab64f4f..0000000000 --- a/engines/glk/frotz/header.h +++ /dev/null @@ -1,159 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef GLK_FROTZ_HEADER -#define GLK_FROTZ_HEADER - -#include "glk/frotz/frotz_types.h" - -namespace Glk { -namespace Frotz { - -enum HeaderByte { - H_VERSION = 0, - H_CONFIG = 1, - H_RELEASE = 2, - H_RESIDENT_SIZE = 4, - H_START_PC = 6, - H_DICTIONARY = 8, - H_OBJECTS = 10, - H_GLOBALS = 12, - H_DYNAMIC_SIZE = 14, - H_FLAGS = 16, - H_SERIAL = 18, - H_ABBREVIATIONS = 24, - H_FILE_SIZE = 26, - H_CHECKSUM = 28, - H_INTERPRETER_NUMBER = 30, - H_INTERPRETER_VERSION = 31, - H_SCREEN_ROWS = 32, - H_SCREEN_COLS = 33, - H_SCREEN_WIDTH = 34, - H_SCREEN_HEIGHT = 36, - H_FONT_HEIGHT = 38, ///< this is the font width in V5 - H_FONT_WIDTH = 39, ///< this is the font height in V5 - H_FUNCTIONS_OFFSET = 40, - H_STRINGS_OFFSET = 42, - H_DEFAULT_BACKGROUND = 44, - H_DEFAULT_FOREGROUND = 45, - H_TERMINATING_KEYS = 46, - H_LINE_WIDTH = 48, - H_STANDARD_HIGH = 50, - H_STANDARD_LOW = 51, - H_ALPHABET = 52, - H_EXTENSION_TABLE = 54, - H_USER_NAME = 56 -}; - -enum { - HX_TABLE_SIZE = 0, - HX_MOUSE_X = 1, - HX_MOUSE_Y = 2, - HX_UNICODE_TABLE = 3, - HX_FLAGS = 4, - HX_FORE_COLOUR = 5, - HX_BACK_COLOUR = 6 -}; - -/** - * Story file header data - */ -struct Header { -private: - struct StoryEntry { - Story _storyId; - zword _release; - char _serial[7]; - }; - static const StoryEntry RECORDS[25]; -public: - 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; - zbyte h_font_width; - 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; - - Story _storyId; - - /** - * Constructor - */ - 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), _storyId(UNKNOWN) { - Common::fill(&h_serial[0], &h_serial[6], '\0'); - Common::fill(&h_user_name[0], &h_user_name[8], '\0'); - } - - /** - * Load the header - */ - void loadHeader(Common::SeekableReadStream &f); -}; - -} // End of namespace Frotz -} // End of namespace Glk - -#endif diff --git a/engines/glk/frotz/mem.h b/engines/glk/frotz/mem.h index 3b1b81b21f..d973890605 100644 --- a/engines/glk/frotz/mem.h +++ b/engines/glk/frotz/mem.h @@ -24,7 +24,7 @@ #define GLK_FROTZ_MEM #include "glk/frotz/frotz_types.h" -#include "glk/frotz/header.h" +#include "glk/frotz/config.h" namespace Glk { namespace Frotz { diff --git a/engines/glk/frotz/processor.cpp b/engines/glk/frotz/processor.cpp index 343299e27c..09eb82b509 100644 --- a/engines/glk/frotz/processor.cpp +++ b/engines/glk/frotz/processor.cpp @@ -304,7 +304,7 @@ void Processor::call(zword routine, int argc, zword *args, int ct) { *--_sp = (zword)(pc >> 9); *--_sp = (zword)(pc & 0x1ff); *--_sp = (zword)(_fp - _stack - 1); - *--_sp = (zword)(argc | (ct << (_save_quetzal ? 12 : 8))); + *--_sp = (zword)(argc | (ct << (_quetzal ? 12 : 8))); _fp = _sp; _frameCount++; @@ -337,7 +337,7 @@ void Processor::call(zword routine, int argc, zword *args, int ct) { if (_sp - _stack < count) runtimeError(ERR_STK_OVF); - if (_save_quetzal) + if (_quetzal) _fp[0] |= (zword)count << 8; // Save local var count for Quetzal. value = 0; @@ -363,7 +363,7 @@ void Processor::ret(zword value) { _sp = _fp; - ct = *_sp++ >> (_save_quetzal ? 12 : 8); + ct = *_sp++ >> (_quetzal ? 12 : 8); _frameCount--; _fp = _stack + 1 + *_sp++; pc = *_sp++; @@ -496,11 +496,11 @@ void Processor::__illegal__() { } void Processor::z_catch() { - store(_save_quetzal ? _frameCount : (zword)(_fp - _stack)); + store(_quetzal ? _frameCount : (zword)(_fp - _stack)); } void Processor::z_throw() { - if (_save_quetzal) { + if (_quetzal) { if (zargs[1] > _frameCount) runtimeError(ERR_BAD_FRAME); diff --git a/engines/glk/module.mk b/engines/glk/module.mk index 10cef3220b..eedab577a7 100644 --- a/engines/glk/module.mk +++ b/engines/glk/module.mk @@ -21,10 +21,10 @@ MODULE_OBJS := \ window_pair.o \ window_text_buffer.o \ window_text_grid.o \ + frotz/config.o \ frotz/detection.o \ frotz/frotz.o \ frotz/glk_interface.o \ - frotz/header.o \ frotz/mem.o \ frotz/processor.o \ frotz/processor_buffer.o \ -- cgit v1.2.3