diff options
author | strangerke | 2011-02-20 10:37:41 +0100 |
---|---|---|
committer | strangerke | 2011-02-20 10:37:41 +0100 |
commit | c9223b9b9b65242ed41906f960c5d2017a8e1ea5 (patch) | |
tree | ca7e0a8134c23e975b162cdb1d0b903a1489f062 /engines | |
parent | a92528636193220d29dcc75e5b4899a1e80cfa5f (diff) | |
download | scummvm-rg350-c9223b9b9b65242ed41906f960c5d2017a8e1ea5.tar.gz scummvm-rg350-c9223b9b9b65242ed41906f960c5d2017a8e1ea5.tar.bz2 scummvm-rg350-c9223b9b9b65242ed41906f960c5d2017a8e1ea5.zip |
HUGO: Some more refactoring
Diffstat (limited to 'engines')
-rw-r--r-- | engines/hugo/file.cpp | 60 | ||||
-rw-r--r-- | engines/hugo/file.h | 9 | ||||
-rw-r--r-- | engines/hugo/game.h | 117 | ||||
-rw-r--r-- | engines/hugo/hugo.cpp | 3 | ||||
-rw-r--r-- | engines/hugo/hugo.h | 5 | ||||
-rw-r--r-- | engines/hugo/intro.cpp | 18 | ||||
-rw-r--r-- | engines/hugo/object.h | 11 | ||||
-rw-r--r-- | engines/hugo/object_v1d.cpp | 2 | ||||
-rw-r--r-- | engines/hugo/object_v1w.cpp | 2 | ||||
-rw-r--r-- | engines/hugo/object_v2d.cpp | 2 | ||||
-rw-r--r-- | engines/hugo/object_v3d.cpp | 2 | ||||
-rw-r--r-- | engines/hugo/parser.h | 31 | ||||
-rw-r--r-- | engines/hugo/parser_v1d.cpp | 2 | ||||
-rw-r--r-- | engines/hugo/parser_v1w.cpp | 2 | ||||
-rw-r--r-- | engines/hugo/parser_v2d.cpp | 2 | ||||
-rw-r--r-- | engines/hugo/parser_v3d.cpp | 4 | ||||
-rw-r--r-- | engines/hugo/schedule.cpp | 44 | ||||
-rw-r--r-- | engines/hugo/schedule.h | 70 |
18 files changed, 191 insertions, 195 deletions
diff --git a/engines/hugo/file.cpp b/engines/hugo/file.cpp index 2662a0e392..740513d7b2 100644 --- a/engines/hugo/file.cpp +++ b/engines/hugo/file.cpp @@ -401,15 +401,15 @@ bool FileManager::saveGame(const int16 slot, const Common::String &descrip) { _vm->_screen->savePal(out); // Save maze status - out->writeByte((_maze.enabledFl) ? 1 : 0); - out->writeByte(_maze.size); - out->writeSint16BE(_maze.x1); - out->writeSint16BE(_maze.y1); - out->writeSint16BE(_maze.x2); - out->writeSint16BE(_maze.y2); - out->writeSint16BE(_maze.x3); - out->writeSint16BE(_maze.x4); - out->writeByte(_maze.firstScreenIndex); + out->writeByte((_vm->_maze.enabledFl) ? 1 : 0); + out->writeByte(_vm->_maze.size); + out->writeSint16BE(_vm->_maze.x1); + out->writeSint16BE(_vm->_maze.y1); + out->writeSint16BE(_vm->_maze.x2); + out->writeSint16BE(_vm->_maze.y2); + out->writeSint16BE(_vm->_maze.x3); + out->writeSint16BE(_vm->_maze.x4); + out->writeByte(_vm->_maze.firstScreenIndex); out->finalize(); @@ -497,15 +497,15 @@ bool FileManager::restoreGame(const int16 slot) { _vm->_screen->restorePal(in); // Restore maze status - _maze.enabledFl = (in->readByte() == 1); - _maze.size = in->readByte(); - _maze.x1 = in->readSint16BE(); - _maze.y1 = in->readSint16BE(); - _maze.x2 = in->readSint16BE(); - _maze.y2 = in->readSint16BE(); - _maze.x3 = in->readSint16BE(); - _maze.x4 = in->readSint16BE(); - _maze.firstScreenIndex = in->readByte(); + _vm->_maze.enabledFl = (in->readByte() == 1); + _vm->_maze.size = in->readByte(); + _vm->_maze.x1 = in->readSint16BE(); + _vm->_maze.y1 = in->readSint16BE(); + _vm->_maze.x2 = in->readSint16BE(); + _vm->_maze.y2 = in->readSint16BE(); + _vm->_maze.x3 = in->readSint16BE(); + _vm->_maze.x4 = in->readSint16BE(); + _vm->_maze.firstScreenIndex = in->readByte(); delete in; return true; @@ -530,16 +530,16 @@ void FileManager::printBootText() { } // Allocate space for the text and print it - char *buf = (char *)malloc(_boot.exit_len + 1); + char *buf = (char *)malloc(_vm->_boot.exit_len + 1); if (buf) { // Skip over the boot structure (already read) and read exit text - ofp.seek((long)sizeof(_boot), SEEK_SET); - if (ofp.read(buf, _boot.exit_len) != (size_t)_boot.exit_len) + ofp.seek((long)sizeof(_vm->_boot), SEEK_SET); + if (ofp.read(buf, _vm->_boot.exit_len) != (size_t)_vm->_boot.exit_len) error("Error while reading startup file"); // Decrypt the exit text, using CRYPT substring int i; - for (i = 0; i < _boot.exit_len; i++) + for (i = 0; i < _vm->_boot.exit_len; i++) buf[i] ^= cypher[i % strlen(cypher)]; buf[i] = '\0'; @@ -569,19 +569,19 @@ void FileManager::readBootFile() { } } - if (ofp.size() < (int32)sizeof(_boot)) + if (ofp.size() < (int32)sizeof(_vm->_boot)) error("Corrupted startup file"); - _boot.checksum = ofp.readByte(); - _boot.registered = ofp.readByte(); - ofp.read(_boot.pbswitch, sizeof(_boot.pbswitch)); - ofp.read(_boot.distrib, sizeof(_boot.distrib)); - _boot.exit_len = ofp.readUint16LE(); + _vm->_boot.checksum = ofp.readByte(); + _vm->_boot.registered = ofp.readByte(); + ofp.read(_vm->_boot.pbswitch, sizeof(_vm->_boot.pbswitch)); + ofp.read(_vm->_boot.distrib, sizeof(_vm->_boot.distrib)); + _vm->_boot.exit_len = ofp.readUint16LE(); - byte *p = (byte *)&_boot; + byte *p = (byte *)&_vm->_boot; byte checksum = 0; - for (uint32 i = 0; i < sizeof(_boot); i++) { + for (uint32 i = 0; i < sizeof(_vm->_boot); i++) { checksum ^= p[i]; p[i] ^= cypher[i % strlen(cypher)]; } diff --git a/engines/hugo/file.h b/engines/hugo/file.h index 46dcabd108..77c6811df1 100644 --- a/engines/hugo/file.h +++ b/engines/hugo/file.h @@ -39,6 +39,12 @@ namespace Hugo { */ enum ovl_t {kOvlBoundary, kOvlOverlay, kOvlBase}; +struct uif_hdr_t { // UIF font/image look up + uint16 size; // Size of uif item + uint32 offset; // Offset of item in file +}; + + class FileManager { public: FileManager(HugoEngine *vm); @@ -76,6 +82,7 @@ protected: static const int kMaxSounds = 64; // Max number of sounds static const int kRepeatMask = 0xC0; // Top 2 bits mean a repeat code static const int kLengthMask = 0x3F; // Lower 6 bits are length + static const int kNumColors = 16; // Num colors to save in palette /** * Structure of scenery file lookup entry @@ -91,8 +98,6 @@ protected: uint32 ob_len; }; - static const int kNumColors = 16; // Num colors to save in palette - struct PCC_header_t { // Structure of PCX file header byte mfctr, vers, enc, bpx; uint16 x1, y1, x2, y2; // bounding box diff --git a/engines/hugo/game.h b/engines/hugo/game.h index bd62a4bc14..08e8deb001 100644 --- a/engines/hugo/game.h +++ b/engines/hugo/game.h @@ -86,64 +86,6 @@ enum path_t { kPathWander2 // Same as WANDER, except keeps cycling when stationary }; -/** - * Following defines the action types and action list - */ -enum action_t { // Parameters: - ANULL = 0xff, // Special NOP used to 'delete' events in DEL_EVENTS - ASCHEDULE = 0, // 0 - Ptr to action list to be rescheduled - START_OBJ, // 1 - Object number - INIT_OBJXY, // 2 - Object number, x,y - PROMPT, // 3 - index of prompt & response string, ptrs to action - // lists. First if response matches, 2nd if not. - BKGD_COLOR, // 4 - new background color - INIT_OBJVXY, // 5 - Object number, vx, vy - INIT_CARRY, // 6 - Object number, carried status - INIT_HF_COORD, // 7 - Object number (gets hero's 'feet' coordinates) - NEW_SCREEN, // 8 - New screen number - INIT_OBJSTATE, // 9 - Object number, new object state - INIT_PATH, // 10 - Object number, new path type - COND_R, // 11 - Conditional on object state - req state, 2 act_lists - TEXT, // 12 - Simple text box - SWAP_IMAGES, // 13 - Swap 2 object images - COND_SCR, // 14 - Conditional on current screen - AUTOPILOT, // 15 - Set object to home in on another (stationary) object - INIT_OBJ_SEQ, // 16 - Object number, sequence index to set curr_seq_p to - SET_STATE_BITS, // 17 - Objnum, mask to OR with obj states word - CLEAR_STATE_BITS, // 18 - Objnum, mask to ~AND with obj states word - TEST_STATE_BITS, // 19 - Objnum, mask to test obj states word - DEL_EVENTS, // 20 - Action type to delete all occurrences of - GAMEOVER, // 21 - Disable hero & commands. Game is over - INIT_HH_COORD, // 22 - Object number (gets hero's actual coordinates) - EXIT, // 23 - Exit game back to DOS - BONUS, // 24 - Get score bonus for an action - COND_BOX, // 25 - Conditional on object within bounding box - SOUND, // 26 - Set currently playing sound - ADD_SCORE, // 27 - Add object's value to current score - SUB_SCORE, // 28 - Subtract object's value from current score - COND_CARRY, // 29 - Conditional on carrying object - INIT_MAZE, // 30 - Start special maze hotspot processing - EXIT_MAZE, // 31 - Exit special maze processing - INIT_PRIORITY, // 32 - Initialize fbg field - INIT_SCREEN, // 33 - Initialise screen field of object - AGSCHEDULE, // 34 - Global schedule - lasts over new screen - REMAPPAL, // 35 - Remappe palette - palette index, color - COND_NOUN, // 36 - Conditional on noun appearing in line - SCREEN_STATE, // 37 - Set new screen state - used for comments - INIT_LIPS, // 38 - Position lips object for supplied object - INIT_STORY_MODE, // 39 - Set story mode TRUE/FALSE (user can't type) - WARN, // 40 - Same as TEXT but can't dismiss box by typing - COND_BONUS, // 41 - Conditional on bonus having been scored - TEXT_TAKE, // 42 - Issue text box with "take" info string - YESNO, // 43 - Prompt user for Yes or No - STOP_ROUTE, // 44 - Skip any route in progress (hero still walks) - COND_ROUTE, // 45 - Conditional on route in progress - INIT_JUMPEXIT, // 46 - Initialize status.jumpexit - INIT_VIEW, // 47 - Initialize viewx, viewy, dir - INIT_OBJ_FRAME, // 48 - Object number, seq,frame to set curr_seq_p to - OLD_SONG = 49 // Added by Strangerke - Set currently playing sound, old way: that is, using a string index instead of a reference in a file -}; - struct hugo_boot_t { // Common HUGO boot file char checksum; // Checksum for boot structure (not exit text) char registered; // TRUE if registered version, else FALSE @@ -152,11 +94,6 @@ struct hugo_boot_t { // Common HUGO boot file uint16 exit_len; // Length of exit text (next in file) } PACKED_STRUCT; -struct uif_hdr_t { // UIF font/image look up - uint16 size; // Size of uif item - uint32 offset; // Offset of item in file -}; - /** * Game specific type definitions */ @@ -164,14 +101,6 @@ typedef byte *image_pt; // ptr to an object image (s typedef byte *sound_pt; // ptr to sound (or music) data /** - * Following are points for achieving certain actions. - */ -struct point_t { - byte score; // The value of the point - bool scoredFl; // Whether scored yet -}; - -/** * Structure for initializing maze processing */ struct maze_t { @@ -183,20 +112,6 @@ struct maze_t { }; /** - * The following determines how a verb is acted on, for an object - */ -struct cmd { - uint16 verbIndex; // the verb - uint16 reqIndex; // ptr to list of required objects - uint16 textDataNoCarryIndex; // ptr to string if any of above not carried - byte reqState; // required state for verb to be done - byte newState; // new states if verb done - uint16 textDataWrongIndex; // ptr to string if wrong state - uint16 textDataDoneIndex; // ptr to string if verb done - uint16 actIndex; // Ptr to action list if verb done -}; - -/** * The following is a linked list of images in an animation sequence * The image data is in 8-bit DIB format, i.e. 1 byte = 1 pixel */ @@ -216,38 +131,6 @@ struct seqList_t { seq_t *seqPtr; // Ptr to sequence structure }; -/** - * Following is structure of verbs and nouns for 'background' objects - * These are objects that appear in the various screens, but nothing - * interesting ever happens with them. Rather than just be dumb and say - * "don't understand" we produce an interesting msg to keep user sane. - */ -struct background_t { - uint16 verbIndex; - uint16 nounIndex; - int commentIndex; // Index of comment produced on match - bool matchFl; // TRUE if noun must match when present - byte roomState; // "State" of room. Comments might differ. - byte bonusIndex; // Index of bonus score (0 = no bonus) -}; - -typedef background_t *objectList_t; - -struct target_t { // Secondary target for action - uint16 nounIndex; // Secondary object - uint16 verbIndex; // Action on secondary object -}; - -struct uses_t { // Define uses of certain objects - int16 objId; // Primary object - uint16 dataIndex; // String if no secondary object matches - target_t *targets; // List of secondary targets -}; - -// Global externs -extern maze_t _maze; // Maze control structure -extern hugo_boot_t _boot; // Boot info structure - #include "common/pack-start.h" // START STRUCT PACKING struct sound_hdr_t { // Sound file lookup entry uint16 size; // Size of sound data in bytes diff --git a/engines/hugo/hugo.cpp b/engines/hugo/hugo.cpp index 1976a6464c..a99e83e648 100644 --- a/engines/hugo/hugo.cpp +++ b/engines/hugo/hugo.cpp @@ -50,9 +50,6 @@ namespace Hugo { HugoEngine *HugoEngine::s_Engine = 0; -maze_t _maze; // Default to not in maze -hugo_boot_t _boot; // Boot info structure file - HugoEngine::HugoEngine(OSystem *syst, const HugoGameDescription *gd) : Engine(syst), _gameDescription(gd), _hero(0), _heroImage(0), _defltTunes(0), _numScreens(0), _tunesNbr(0), _soundSilence(0), _soundTest(0), _screenStates(0), _score(0), _maxscore(0), _lastTime(0), _curTime(0) diff --git a/engines/hugo/hugo.h b/engines/hugo/hugo.h index 239b20fab5..45d2dc4dd4 100644 --- a/engines/hugo/hugo.h +++ b/engines/hugo/hugo.h @@ -251,6 +251,9 @@ public: uint16 _take; uint16 _drop; + maze_t _maze; // Maze control structure + hugo_boot_t _boot; // Boot info structure + GUI::Debugger *getDebugger(); Common::RandomSource *_rnd; @@ -269,7 +272,7 @@ public: Common::Platform getPlatform() const; bool isPacked() const; - // Temporary, until the engine is fully objectified. + // Used by the qsort function static HugoEngine &get() { assert(s_Engine != 0); return *s_Engine; diff --git a/engines/hugo/intro.cpp b/engines/hugo/intro.cpp index d7b95f9d1f..689dfbfd7c 100644 --- a/engines/hugo/intro.cpp +++ b/engines/hugo/intro.cpp @@ -119,7 +119,7 @@ bool intro_v1d::introPlay() { error("Unable to load font TMSRB.FON, face 'Tms Rmn', size 8"); char buffer[80]; - if (_boot.registered) + if (_vm->_boot.registered) strcpy(buffer, "Registered Version"); else strcpy(buffer, "Shareware Version"); @@ -127,8 +127,8 @@ bool intro_v1d::introPlay() { font.drawString(&surf, buffer, 0, 163, 320, _TLIGHTMAGENTA, Graphics::kTextAlignCenter); font.drawString(&surf, _vm->getCopyrightString(), 0, 176, 320, _TLIGHTMAGENTA, Graphics::kTextAlignCenter); - if (scumm_stricmp(_boot.distrib, "David P. Gray")) { - sprintf(buffer, "Distributed by %s.", _boot.distrib); + if (scumm_stricmp(_vm->_boot.distrib, "David P. Gray")) { + sprintf(buffer, "Distributed by %s.", _vm->_boot.distrib); font.drawString(&surf, buffer, 0, 75, 320, _TMAGENTA, Graphics::kTextAlignCenter); } @@ -251,16 +251,16 @@ void intro_v2d::introInit() { if (!font.loadFromFON("TMSRB.FON", Graphics::WinFontDirEntry("Tms Rmn", 8))) error("Unable to load font TMSRB.FON, face 'Tms Rmn', size 8"); - if (_boot.registered) + if (_vm->_boot.registered) sprintf(buffer, "%s Registered Version", _vm->getCopyrightString()); else sprintf(buffer, "%s Shareware Version", _vm->getCopyrightString()); font.drawString(&surf, buffer, 0, 186, 320, _TLIGHTRED, Graphics::kTextAlignCenter); - if (scumm_stricmp(_boot.distrib, "David P. Gray")) { + if (scumm_stricmp(_vm->_boot.distrib, "David P. Gray")) { // TROMAN, size 10-5 - sprintf(buffer, "Distributed by %s.", _boot.distrib); + sprintf(buffer, "Distributed by %s.", _vm->_boot.distrib); font.drawString(&surf, buffer, 0, 1, 320, _TLIGHTRED, Graphics::kTextAlignCenter); } @@ -292,7 +292,7 @@ void intro_v3d::introInit() { surf.bytesPerPixel = 1; char buffer[128]; - if (_boot.registered) + if (_vm->_boot.registered) sprintf(buffer, "%s Registered Version", _vm->getCopyrightString()); else sprintf(buffer,"%s Shareware Version", _vm->getCopyrightString()); @@ -303,8 +303,8 @@ void intro_v3d::introInit() { font.drawString(&surf, buffer, 0, 190, 320, _TBROWN, Graphics::kTextAlignCenter); - if (scumm_stricmp(_boot.distrib, "David P. Gray")) { - sprintf(buffer, "Distributed by %s.", _boot.distrib); + if (scumm_stricmp(_vm->_boot.distrib, "David P. Gray")) { + sprintf(buffer, "Distributed by %s.", _vm->_boot.distrib); font.drawString(&surf, buffer, 0, 0, 320, _TBROWN, Graphics::kTextAlignCenter); } diff --git a/engines/hugo/object.h b/engines/hugo/object.h index 842bbe1e62..41ea776840 100644 --- a/engines/hugo/object.h +++ b/engines/hugo/object.h @@ -37,6 +37,17 @@ namespace Hugo { +struct target_t { // Secondary target for action + uint16 nounIndex; // Secondary object + uint16 verbIndex; // Action on secondary object +}; + +struct uses_t { // Define uses of certain objects + int16 objId; // Primary object + uint16 dataIndex; // String if no secondary object matches + target_t *targets; // List of secondary targets +}; + class ObjectHandler { public: ObjectHandler(HugoEngine *vm); diff --git a/engines/hugo/object_v1d.cpp b/engines/hugo/object_v1d.cpp index d46ef890bc..a8edb45746 100644 --- a/engines/hugo/object_v1d.cpp +++ b/engines/hugo/object_v1d.cpp @@ -334,7 +334,7 @@ void ObjectHandler_v1d::moveObjects() { } // If maze mode is enabled, do special maze processing - if (_maze.enabledFl) { + if (_vm->_maze.enabledFl) { seq_t *currImage = _vm->_hero->currImagePtr;// Get ptr to current image // hero coordinates int x1 = _vm->_hero->x + currImage->x1; // Left edge of object diff --git a/engines/hugo/object_v1w.cpp b/engines/hugo/object_v1w.cpp index 321bb293f0..f3ba793a3b 100644 --- a/engines/hugo/object_v1w.cpp +++ b/engines/hugo/object_v1w.cpp @@ -344,7 +344,7 @@ void ObjectHandler_v1w::moveObjects() { } // If maze mode is enabled, do special maze processing - if (_maze.enabledFl) { + if (_vm->_maze.enabledFl) { seq_t *currImage = _vm->_hero->currImagePtr; // Get ptr to current image // hero coordinates int x1 = _vm->_hero->x + currImage->x1; // Left edge of object diff --git a/engines/hugo/object_v2d.cpp b/engines/hugo/object_v2d.cpp index 0bb207411e..b3c49262ad 100644 --- a/engines/hugo/object_v2d.cpp +++ b/engines/hugo/object_v2d.cpp @@ -347,7 +347,7 @@ void ObjectHandler_v2d::moveObjects() { } // If maze mode is enabled, do special maze processing - if (_maze.enabledFl) { + if (_vm->_maze.enabledFl) { seq_t *currImage = _vm->_hero->currImagePtr; // Get ptr to current image // hero coordinates int x1 = _vm->_hero->x + currImage->x1; // Left edge of object diff --git a/engines/hugo/object_v3d.cpp b/engines/hugo/object_v3d.cpp index 8c9efba1d0..2c6fc5d99d 100644 --- a/engines/hugo/object_v3d.cpp +++ b/engines/hugo/object_v3d.cpp @@ -229,7 +229,7 @@ void ObjectHandler_v3d::moveObjects() { } // If maze mode is enabled, do special maze processing - if (_maze.enabledFl) { + if (_vm->_maze.enabledFl) { seq_t *currImage = _vm->_hero->currImagePtr;// Get ptr to current image // hero coordinates int x1 = _vm->_hero->x + currImage->x1; // Left edge of object diff --git a/engines/hugo/parser.h b/engines/hugo/parser.h index 33851d6a2c..dd9244ba93 100644 --- a/engines/hugo/parser.h +++ b/engines/hugo/parser.h @@ -42,6 +42,37 @@ enum seqTextParser { kCmtAny5, kTBExit_1d, kTBEh_1d, kTBEh_2d, kTBNoUse_2d }; +/** + * The following determines how a verb is acted on, for an object + */ +struct cmd { + uint16 verbIndex; // the verb + uint16 reqIndex; // ptr to list of required objects + uint16 textDataNoCarryIndex; // ptr to string if any of above not carried + byte reqState; // required state for verb to be done + byte newState; // new states if verb done + uint16 textDataWrongIndex; // ptr to string if wrong state + uint16 textDataDoneIndex; // ptr to string if verb done + uint16 actIndex; // Ptr to action list if verb done +}; + +/** + * Following is structure of verbs and nouns for 'background' objects + * These are objects that appear in the various screens, but nothing + * interesting ever happens with them. Rather than just be dumb and say + * "don't understand" we produce an interesting msg to keep user sane. + */ +struct background_t { + uint16 verbIndex; + uint16 nounIndex; + int commentIndex; // Index of comment produced on match + bool matchFl; // TRUE if noun must match when present + byte roomState; // "State" of room. Comments might differ. + byte bonusIndex; // Index of bonus score (0 = no bonus) +}; + +typedef background_t *objectList_t; + class Parser { public: Parser(HugoEngine *vm); diff --git a/engines/hugo/parser_v1d.cpp b/engines/hugo/parser_v1d.cpp index 007924904f..424ca66b38 100644 --- a/engines/hugo/parser_v1d.cpp +++ b/engines/hugo/parser_v1d.cpp @@ -286,7 +286,7 @@ void Parser_v1d::dropObject(object_t *obj) { bool Parser_v1d::isCatchallVerb_v1(bool testNounFl, const char *noun, const char *verb, objectList_t obj) const { debugC(1, kDebugParser, "isCatchallVerb(%d, %s, %s, object_list_t obj)", (testNounFl) ? 1 : 0, noun, verb); - if (_maze.enabledFl) + if (_vm->_maze.enabledFl) return false; if (testNounFl && !noun) diff --git a/engines/hugo/parser_v1w.cpp b/engines/hugo/parser_v1w.cpp index 4b55f7977a..5d901e8ffe 100644 --- a/engines/hugo/parser_v1w.cpp +++ b/engines/hugo/parser_v1w.cpp @@ -191,7 +191,7 @@ void Parser_v1w::lineHandler() { // Nothing matches. Report recognition success to user. const char *verb = findVerb(); const char *noun = findNoun(); - if (verb == _vm->_text->getVerb(_vm->_look, 0) && _maze.enabledFl) { + if (verb == _vm->_text->getVerb(_vm->_look, 0) && _vm->_maze.enabledFl) { Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBMaze)); _vm->_object->showTakeables(); } else if (verb && noun) { // A combination I didn't think of diff --git a/engines/hugo/parser_v2d.cpp b/engines/hugo/parser_v2d.cpp index d87ae59416..580d78100d 100644 --- a/engines/hugo/parser_v2d.cpp +++ b/engines/hugo/parser_v2d.cpp @@ -178,7 +178,7 @@ void Parser_v2d::lineHandler() { && !isCatchallVerb_v1(false, noun, verb, _catchallList)) { if (*farComment != '\0') { // An object matched but not near enough Utils::Box(kBoxAny, "%s", farComment); - } else if (_maze.enabledFl && (verb == _vm->_text->getVerb(_vm->_look, 0))) { + } else if (_vm->_maze.enabledFl && (verb == _vm->_text->getVerb(_vm->_look, 0))) { Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBMaze)); _vm->_object->showTakeables(); } else if (verb && noun) { // A combination I didn't think of diff --git a/engines/hugo/parser_v3d.cpp b/engines/hugo/parser_v3d.cpp index 3c1eefe732..b3d0125d20 100644 --- a/engines/hugo/parser_v3d.cpp +++ b/engines/hugo/parser_v3d.cpp @@ -416,7 +416,7 @@ void Parser_v3d::dropObject(object_t *obj) { bool Parser_v3d::isCatchallVerb_v3(objectList_t obj) const { debugC(1, kDebugParser, "isCatchallVerb(object_list_t obj)"); - if (_maze.enabledFl) + if (_vm->_maze.enabledFl) return false; for (int i = 0; obj[i].verbIndex != 0; i++) { @@ -444,7 +444,7 @@ bool Parser_v3d::isCatchallVerb_v3(objectList_t obj) const { bool Parser_v3d::isBackgroundWord_v3(objectList_t obj) const { debugC(1, kDebugParser, "isBackgroundWord(object_list_t obj)"); - if (_maze.enabledFl) + if (_vm->_maze.enabledFl) return false; for (int i = 0; obj[i].verbIndex != 0; i++) { diff --git a/engines/hugo/schedule.cpp b/engines/hugo/schedule.cpp index f0f29150e5..5843c2317e 100644 --- a/engines/hugo/schedule.cpp +++ b/engines/hugo/schedule.cpp @@ -657,32 +657,32 @@ void Scheduler::screenActions(const int screenNum) { void Scheduler::processMaze(const int x1, const int x2, const int y1, const int y2) { debugC(1, kDebugSchedule, "processMaze"); - if (x1 < _maze.x1) { + if (x1 < _vm->_maze.x1) { // Exit west _actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p - 1; - _actListArr[_alNewscrIndex][0].a2.x = _maze.x2 - kShiftSize - (x2 - x1); + _actListArr[_alNewscrIndex][0].a2.x = _vm->_maze.x2 - kShiftSize - (x2 - x1); _actListArr[_alNewscrIndex][0].a2.y = _vm->_hero->y; _vm->_route->resetRoute(); insertActionList(_alNewscrIndex); - } else if (x2 > _maze.x2) { + } else if (x2 > _vm->_maze.x2) { // Exit east _actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p + 1; - _actListArr[_alNewscrIndex][0].a2.x = _maze.x1 + kShiftSize; + _actListArr[_alNewscrIndex][0].a2.x = _vm->_maze.x1 + kShiftSize; _actListArr[_alNewscrIndex][0].a2.y = _vm->_hero->y; _vm->_route->resetRoute(); insertActionList(_alNewscrIndex); - } else if (y1 < _maze.y1 - kShiftSize) { + } else if (y1 < _vm->_maze.y1 - kShiftSize) { // Exit north - _actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p - _maze.size; - _actListArr[_alNewscrIndex][0].a2.x = _maze.x3; - _actListArr[_alNewscrIndex][0].a2.y = _maze.y2 - kShiftSize - (y2 - y1); + _actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p - _vm->_maze.size; + _actListArr[_alNewscrIndex][0].a2.x = _vm->_maze.x3; + _actListArr[_alNewscrIndex][0].a2.y = _vm->_maze.y2 - kShiftSize - (y2 - y1); _vm->_route->resetRoute(); insertActionList(_alNewscrIndex); - } else if (y2 > _maze.y2 - kShiftSize / 2) { + } else if (y2 > _vm->_maze.y2 - kShiftSize / 2) { // Exit south - _actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p + _maze.size; - _actListArr[_alNewscrIndex][0].a2.x = _maze.x4; - _actListArr[_alNewscrIndex][0].a2.y = _maze.y1 + kShiftSize; + _actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p + _vm->_maze.size; + _actListArr[_alNewscrIndex][0].a2.x = _vm->_maze.x4; + _actListArr[_alNewscrIndex][0].a2.y = _vm->_maze.y1 + kShiftSize; _vm->_route->resetRoute(); insertActionList(_alNewscrIndex); } @@ -1059,18 +1059,18 @@ event_t *Scheduler::doAction(event_t *curEvent) { insertActionList(action->a29.actFailIndex); break; case INIT_MAZE: // act30: Enable and init maze structure - _maze.enabledFl = true; - _maze.size = action->a30.mazeSize; - _maze.x1 = action->a30.x1; - _maze.y1 = action->a30.y1; - _maze.x2 = action->a30.x2; - _maze.y2 = action->a30.y2; - _maze.x3 = action->a30.x3; - _maze.x4 = action->a30.x4; - _maze.firstScreenIndex = action->a30.firstScreenIndex; + _vm->_maze.enabledFl = true; + _vm->_maze.size = action->a30.mazeSize; + _vm->_maze.x1 = action->a30.x1; + _vm->_maze.y1 = action->a30.y1; + _vm->_maze.x2 = action->a30.x2; + _vm->_maze.y2 = action->a30.y2; + _vm->_maze.x3 = action->a30.x3; + _vm->_maze.x4 = action->a30.x4; + _vm->_maze.firstScreenIndex = action->a30.firstScreenIndex; break; case EXIT_MAZE: // act31: Disable maze mode - _maze.enabledFl = false; + _vm->_maze.enabledFl = false; break; case INIT_PRIORITY: _vm->_object->_objects[action->a32.objIndex].priority = action->a32.priority; diff --git a/engines/hugo/schedule.h b/engines/hugo/schedule.h index c7a6003ddf..953e9affea 100644 --- a/engines/hugo/schedule.h +++ b/engines/hugo/schedule.h @@ -37,6 +37,64 @@ namespace Hugo { +/** + * Following defines the action types and action list + */ +enum action_t { // Parameters: + ANULL = 0xff, // Special NOP used to 'delete' events in DEL_EVENTS + ASCHEDULE = 0, // 0 - Ptr to action list to be rescheduled + START_OBJ, // 1 - Object number + INIT_OBJXY, // 2 - Object number, x,y + PROMPT, // 3 - index of prompt & response string, ptrs to action + // lists. First if response matches, 2nd if not. + BKGD_COLOR, // 4 - new background color + INIT_OBJVXY, // 5 - Object number, vx, vy + INIT_CARRY, // 6 - Object number, carried status + INIT_HF_COORD, // 7 - Object number (gets hero's 'feet' coordinates) + NEW_SCREEN, // 8 - New screen number + INIT_OBJSTATE, // 9 - Object number, new object state + INIT_PATH, // 10 - Object number, new path type + COND_R, // 11 - Conditional on object state - req state, 2 act_lists + TEXT, // 12 - Simple text box + SWAP_IMAGES, // 13 - Swap 2 object images + COND_SCR, // 14 - Conditional on current screen + AUTOPILOT, // 15 - Set object to home in on another (stationary) object + INIT_OBJ_SEQ, // 16 - Object number, sequence index to set curr_seq_p to + SET_STATE_BITS, // 17 - Objnum, mask to OR with obj states word + CLEAR_STATE_BITS, // 18 - Objnum, mask to ~AND with obj states word + TEST_STATE_BITS, // 19 - Objnum, mask to test obj states word + DEL_EVENTS, // 20 - Action type to delete all occurrences of + GAMEOVER, // 21 - Disable hero & commands. Game is over + INIT_HH_COORD, // 22 - Object number (gets hero's actual coordinates) + EXIT, // 23 - Exit game back to DOS + BONUS, // 24 - Get score bonus for an action + COND_BOX, // 25 - Conditional on object within bounding box + SOUND, // 26 - Set currently playing sound + ADD_SCORE, // 27 - Add object's value to current score + SUB_SCORE, // 28 - Subtract object's value from current score + COND_CARRY, // 29 - Conditional on carrying object + INIT_MAZE, // 30 - Start special maze hotspot processing + EXIT_MAZE, // 31 - Exit special maze processing + INIT_PRIORITY, // 32 - Initialize fbg field + INIT_SCREEN, // 33 - Initialise screen field of object + AGSCHEDULE, // 34 - Global schedule - lasts over new screen + REMAPPAL, // 35 - Remappe palette - palette index, color + COND_NOUN, // 36 - Conditional on noun appearing in line + SCREEN_STATE, // 37 - Set new screen state - used for comments + INIT_LIPS, // 38 - Position lips object for supplied object + INIT_STORY_MODE, // 39 - Set story mode TRUE/FALSE (user can't type) + WARN, // 40 - Same as TEXT but can't dismiss box by typing + COND_BONUS, // 41 - Conditional on bonus having been scored + TEXT_TAKE, // 42 - Issue text box with "take" info string + YESNO, // 43 - Prompt user for Yes or No + STOP_ROUTE, // 44 - Skip any route in progress (hero still walks) + COND_ROUTE, // 45 - Conditional on route in progress + INIT_JUMPEXIT, // 46 - Initialize status.jumpexit + INIT_VIEW, // 47 - Initialize viewx, viewy, dir + INIT_OBJ_FRAME, // 48 - Object number, seq,frame to set curr_seq_p to + OLD_SONG = 49 // Added by Strangerke - Set currently playing sound, old way: that is, using a string index instead of a reference in a file +}; + struct act0 { // Type 0 - Schedule action_t actType; // The type of action int timer; // Time to set off the action @@ -450,6 +508,14 @@ struct event_t { struct event_t *nextEvent; // Chain to next event }; +/** + * Following are points for achieving certain actions. + */ +struct point_t { + byte score; // The value of the point + bool scoredFl; // Whether scored yet +}; + class Scheduler { public: Scheduler(HugoEngine *vm); @@ -471,13 +537,11 @@ public: void newScreen(const int screenIndex); void processBonus(const int bonusIndex); void processMaze(const int x1, const int x2, const int y1, const int y2); - void readAct(Common::ReadStream &in, act &curAct); void restoreSchedulerData(Common::ReadStream *in); void restoreScreen(const int screenIndex); void saveSchedulerData(Common::WriteStream *out); void waitForRefresh(); - void findAction(act* action, int16* index, int16* subElem); protected: HugoEngine *_vm; static const int kFilenameLength = 12; // Max length of a DOS file name @@ -519,7 +583,9 @@ protected: void delEventType(const action_t actTypeDel); void delQueue(event_t *curEvent); + void findAction(act* action, int16* index, int16* subElem); void insertAction(act *action); + void readAct(Common::ReadStream &in, act &curAct); void restoreActions(Common::ReadStream *f); void restoreEvents(Common::ReadStream *f); void restorePoints(Common::ReadStream *in); |