diff options
author | dreammaster | 2019-06-09 22:03:26 +0100 |
---|---|---|
committer | Paul Gilbert | 2019-06-09 15:00:46 -0700 |
commit | 0074810cb4d9761ef2b3fd4f9350a73faf4da331 (patch) | |
tree | 90eb50d21119745c9ed80a4c721d38e75bf76f09 /engines/glk | |
parent | b01e711d65e6ef85df90eecde64a857b389a8dbd (diff) | |
download | scummvm-rg350-0074810cb4d9761ef2b3fd4f9350a73faf4da331.tar.gz scummvm-rg350-0074810cb4d9761ef2b3fd4f9350a73faf4da331.tar.bz2 scummvm-rg350-0074810cb4d9761ef2b3fd4f9350a73faf4da331.zip |
GLK: ADVSYS: Formatting fixes
Diffstat (limited to 'engines/glk')
-rw-r--r-- | engines/glk/advsys/advsys.cpp | 2 | ||||
-rw-r--r-- | engines/glk/advsys/advsys.h | 4 | ||||
-rw-r--r-- | engines/glk/advsys/game.cpp | 26 | ||||
-rw-r--r-- | engines/glk/advsys/game.h | 94 | ||||
-rw-r--r-- | engines/glk/advsys/vm.cpp | 4 | ||||
-rw-r--r-- | engines/glk/advsys/vm.h | 130 |
6 files changed, 133 insertions, 127 deletions
diff --git a/engines/glk/advsys/advsys.cpp b/engines/glk/advsys/advsys.cpp index c1d1f9e38e..b745222ea1 100644 --- a/engines/glk/advsys/advsys.cpp +++ b/engines/glk/advsys/advsys.cpp @@ -97,7 +97,7 @@ Common::Error AdvSys::loadGameData(strid_t save) { return Common::kNoError; } -Common::Error AdvSys::saveGameData(strid_t save, const Common::String& desc) { +Common::Error AdvSys::saveGameData(strid_t save, const Common::String &desc) { return Common::kNoError; } diff --git a/engines/glk/advsys/advsys.h b/engines/glk/advsys/advsys.h index 9aa1305415..a6e9a5b075 100644 --- a/engines/glk/advsys/advsys.h +++ b/engines/glk/advsys/advsys.h @@ -64,7 +64,9 @@ public: /** * Returns the running interpreter type */ - virtual InterpreterType getInterpreterType() const override { return INTERPRETER_ADVSYS; } + virtual InterpreterType getInterpreterType() const override { + return INTERPRETER_ADVSYS; + } /** * Load a savegame from the passed stream diff --git a/engines/glk/advsys/game.cpp b/engines/glk/advsys/game.cpp index 22b1d11476..17a4104404 100644 --- a/engines/glk/advsys/game.cpp +++ b/engines/glk/advsys/game.cpp @@ -47,10 +47,10 @@ bool Header::init(Common::ReadStream &s) { Common::MemoryReadStream ms(data, HEADER_SIZE, DisposeAfterUse::NO); // Validate the header - _valid = !strncmp((const char*)data + 2, "ADVSYS", 6); + _valid = !strncmp((const char *)data + 2, "ADVSYS", 6); if (!_valid) return false; - + _size = ms.readUint16LE(); ms.skip(6); _headerVersion = ms.readUint16LE(); @@ -103,7 +103,7 @@ bool Game::init(Common::SeekableReadStream &s) { s.seek(0); if (!Header::init(s)) return false; - + if (_headerVersion < 101 || _headerVersion > MAX_VERSION) error("Wrong version number"); @@ -136,7 +136,7 @@ bool Game::init(Common::SeekableReadStream &s) { return true; } -void Game::restart(Common::SeekableReadStream& s) { +void Game::restart(Common::SeekableReadStream &s) { s.seek(_residentOffset + _saveAreaOffset); s.read(_saveArea, _saveSize); decrypt(_saveArea, _saveSize); @@ -151,11 +151,11 @@ bool Game::shouldRestart() { return result; } -void Game::saveGameData(Common::WriteStream& ws) { +void Game::saveGameData(Common::WriteStream &ws) { ws.write(_saveArea, _saveSize); } -void Game::loadGameData(Common::ReadStream& rs) { +void Game::loadGameData(Common::ReadStream &rs) { rs.read(_saveArea, _saveSize); } @@ -166,18 +166,18 @@ int Game::findWord(const Common::String &word) const { // Iterate over the dictionary for the word for (int idx = 1; idx <= _wordCount; ++idx) { int wordOffset = READ_LE_UINT16(_wordTable + idx * 2); - if (w == (const char*)_residentBase + wordOffset + 2) + if (w == (const char *)_residentBase + wordOffset + 2) return READ_LE_UINT16(_residentBase + wordOffset); } return NIL; } -bool Game::match(int obj, int noun, int* adjectives) { +bool Game::match(int obj, int noun, int *adjectives) { if (!hasNoun(obj, noun)) return false; - for (int* adjPtr = adjectives; *adjPtr; ++adjPtr) { + for (int *adjPtr = adjectives; *adjPtr; ++adjPtr) { if (!hasAdjective(obj, *adjPtr)) return false; } @@ -185,7 +185,7 @@ bool Game::match(int obj, int noun, int* adjectives) { return true; } -int Game::checkVerb(int* verbs) { +int Game::checkVerb(int *verbs) { // Iterate through the actions for (int idx = 1; idx <= _actionCount; ++idx) { if (hasVerb(idx, verbs)) @@ -195,7 +195,7 @@ int Game::checkVerb(int* verbs) { return NIL; } -int Game::findAction(int* verbs, int preposition, int flag) { +int Game::findAction(int *verbs, int preposition, int flag) { // Iterate through the actions for (int idx = 1; idx <= _actionCount; ++idx) { if ((preposition && !hasPreposition(idx, preposition)) || !hasVerb(idx, verbs)) @@ -284,13 +284,13 @@ bool Game::hasAdjective(int obj, int adjective) const { return false; } -bool Game::hasVerb(int act, int* verbs) const { +bool Game::hasVerb(int act, int *verbs) const { // Get the list of verbs int link = getActionField(act, A_VERBS); // Look for the verb for (; link; link = readWord(link + L_NEXT)) { - int* verb = verbs; + int *verb = verbs; int word = readWord(link + L_DATA); for (; *verb && word; link = readWord(link + L_NEXT)) { diff --git a/engines/glk/advsys/game.h b/engines/glk/advsys/game.h index 5ffb31b20e..a5c7f41f55 100644 --- a/engines/glk/advsys/game.h +++ b/engines/glk/advsys/game.h @@ -59,12 +59,12 @@ enum ObjectField { * Built-in variables */ enum Variable { - V_ACTOR = 1, ///< Actor noun phrase number - V_ACTION = 2, ///< Action from phrase - V_DOBJECT = 3, ///< First direct object noun phrase number - V_NDOBJECTS = 4, ///< Number of direct object noun phrases - V_IOBJECT = 5, ///< Indirect object noun phrase number - V_OCOUNT = 6 ///< Total object count + V_ACTOR = 1, ///< Actor noun phrase number + V_ACTION = 2, ///< Action from phrase + V_DOBJECT = 3, ///< First direct object noun phrase number + V_NDOBJECTS = 4, ///< Number of direct object noun phrases + V_IOBJECT = 5, ///< Indirect object noun phrase number + V_OCOUNT = 6 ///< Total object count }; /** @@ -75,7 +75,7 @@ public: /** * Decrypt a data block */ - static void decrypt(byte* data, size_t size); + static void decrypt(byte *data, size_t size); }; /** @@ -83,27 +83,27 @@ public: */ class Header : public Decrypter { public: - bool _valid; ///< Signals whether header is valid - size_t _size; ///< Resident size in bytes - uint _headerVersion; ///< Header structure version - Common::String _name; ///< Adventure name - uint _version; ///< Adventure version - uint _wordTableOffset; ///< Word table offset - uint _wordTypeTableOffset; ///< Word type table offset - uint _objectTableOffset; ///< Object table offset - uint _actionTableOffset; ///< Action table offset - uint _variableTableOffset; ///< Variable table offset - uint _dataSpaceOffset; ///< Data space offset - uint _codeSpaceOffset; ///< Code space offset - uint _dataBlockOffset; ///< First data block offset - uint _messageBlockOffset; ///< First message block offset - uint _initCodeOffset; ///< Initialization code offset - uint _updateCodeOffset; ///< Update code offset - uint _beforeOffset; ///< Code offset before verb handler - uint _afterOffset; ///< Code offset after verb handler - uint _errorHandlerOffset; ///< Error handler code offset - uint _saveAreaOffset; ///< Save area offset - uint _saveSize; ///< Save area size + bool _valid; ///< Signals whether header is valid + size_t _size; ///< Resident size in bytes + uint _headerVersion; ///< Header structure version + Common::String _name; ///< Adventure name + uint _version; ///< Adventure version + uint _wordTableOffset; ///< Word table offset + uint _wordTypeTableOffset; ///< Word type table offset + uint _objectTableOffset; ///< Object table offset + uint _actionTableOffset; ///< Action table offset + uint _variableTableOffset; ///< Variable table offset + uint _dataSpaceOffset; ///< Data space offset + uint _codeSpaceOffset; ///< Code space offset + uint _dataBlockOffset; ///< First data block offset + uint _messageBlockOffset; ///< First message block offset + uint _initCodeOffset; ///< Initialization code offset + uint _updateCodeOffset; ///< Update code offset + uint _beforeOffset; ///< Code offset before verb handler + uint _afterOffset; ///< Code offset after verb handler + uint _errorHandlerOffset; ///< Error handler code offset + uint _saveAreaOffset; ///< Save area offset + uint _saveSize; ///< Save area size public: /** * Constructor @@ -153,7 +153,7 @@ private: /** * Returns true if an action has a given verb */ - bool hasVerb(int act, int* verbs) const; + bool hasVerb(int act, int *verbs) const; /** * Returns true if an action is in a given list @@ -174,15 +174,15 @@ public: int _actionCount; int _variableCount; - byte* _residentBase; - byte* _wordTable; - byte* _wordTypeTable; - byte* _objectTable; - byte* _actionTable; - byte* _variableTable; - byte* _saveArea; - byte* _dataSpace; - byte* _codeSpace; + byte *_residentBase; + byte *_wordTable; + byte *_wordTypeTable; + byte *_objectTable; + byte *_actionTable; + byte *_variableTable; + byte *_saveArea; + byte *_dataSpace; + byte *_codeSpace; public: /** * Constructor @@ -200,7 +200,7 @@ public: /** * Restore savegame data from the game to it's initial state */ - void restart(Common::SeekableReadStream& s); + void restart(Common::SeekableReadStream &s); /** * Returns true if the game is restarting, and resets the flag @@ -210,37 +210,39 @@ public: /** * Save the game data to a savegame */ - void saveGameData(Common::WriteStream& ws); + void saveGameData(Common::WriteStream &ws); /** * Restore the game data from a savegame */ - void loadGameData(Common::ReadStream& rs); + void loadGameData(Common::ReadStream &rs); /** * Find a word in the dictionary */ - int findWord(const Common::String& word) const; + int findWord(const Common::String &word) const; /** * Return a word's type */ - int getWordType(int word) const { return _wordTypeTable[word]; } + int getWordType(int word) const { + return _wordTypeTable[word]; + } /** * Match an object against a name and list of adjectives */ - bool match(int obj, int noun, int* adjectives); + bool match(int obj, int noun, int *adjectives); /** * Check to see if this is a valid verb */ - int checkVerb(int* verbs); + int checkVerb(int *verbs); /** * Find an action matching a given description */ - int findAction(int* verbs, int preposition, int flag); + int findAction(int *verbs, int preposition, int flag); /** * Get an object property diff --git a/engines/glk/advsys/vm.cpp b/engines/glk/advsys/vm.cpp index 46d2133dd0..754a86a530 100644 --- a/engines/glk/advsys/vm.cpp +++ b/engines/glk/advsys/vm.cpp @@ -83,7 +83,7 @@ OpcodeMethod VM::_METHODS[0x34] = { }; VM::VM(OSystem *syst, const GlkGameDescription &gameDesc) : GlkInterface(syst, gameDesc), Game(), - _pc(0), _status(IN_PROGRESS) { + _pc(0), _status(IN_PROGRESS) { } ExecutionResult VM::execute(int offset) { @@ -94,7 +94,7 @@ ExecutionResult VM::execute(int offset) { _stack.clear(); // Iterate through the script - for (_status = IN_PROGRESS; !shouldQuit() && _status == IN_PROGRESS; ) + for (_status = IN_PROGRESS; !shouldQuit() && _status == IN_PROGRESS;) executeOpcode(); return _status; diff --git a/engines/glk/advsys/vm.h b/engines/glk/advsys/vm.h index 84cd313961..e1b217fd31 100644 --- a/engines/glk/advsys/vm.h +++ b/engines/glk/advsys/vm.h @@ -24,7 +24,7 @@ #define GLK_ADVSYS_VM #include "glk/advsys/glk_interface.h" -#include "glk/advsys/game.h" +#include "glk/advsys/game.h" #include "common/array.h" namespace Glk { @@ -34,73 +34,73 @@ namespace AdvSys { * Execution result states */ enum ExecutionResult { - IN_PROGRESS = 0, ///< Default state whilst script is in progress - FINISH = 1, ///< Script was finished - CHAIN = 2, ///< Another script is being chained to - ABORT = 3 ///< Script was aborted + IN_PROGRESS = 0, ///< Default state whilst script is in progress + FINISH = 1, ///< Script was finished + CHAIN = 2, ///< Another script is being chained to + ABORT = 3 ///< Script was aborted }; /** * Opcode list */ enum Opcode { - OP_BRT = 0x01, ///< Branch on true - OP_BRF = 0x02, ///< Branch on false - OP_BR = 0x03, ///< Branch unconditionally - OP_T = 0x04, ///< Load top of stack with t - OP_NIL = 0x05, ///< Load top of stack with nil - OP_PUSH = 0x06, ///< Push nil onto stack - OP_NOT = 0x07, ///< Logical negate top of stack - OP_ADD = 0x08, ///< Add two numeric expressions - OP_SUB = 0x09, ///< Subtract two numeric expressions - OP_MUL = 0x0A, ///< Multiply two numeric expressions - OP_DIV = 0x0B, ///< Divide two numeric expressions - OP_REM = 0x0C, ///< Remainder of two numeric expressions - OP_BAND = 0x0D, ///< Bitwise and of two numeric expressions - OP_BOR = 0x0E, ///< Bitwise or of two numeric expressions - OP_BNOT = 0x0F, ///< Bitwise not - OP_LT = 0x10, ///< Less than - OP_EQ = 0x11, ///< Equal to - OP_GT = 0x12, ///< Greater than - OP_LIT = 0x13, ///< Load literal - OP_VAR = 0x14, ///< Load a variable value - OP_GETP = 0x15, ///< Get the value of an object property - OP_SETP = 0x16, ///< Set the value of an object property - OP_SET = 0x17, ///< Set the value of a variable - OP_PRINT = 0x18, ///< Print messages - OP_TERPRI = 0x19, ///< Terminate the print line - OP_PNUMBER = 0x1A, ///< Print a number - OP_FINISH = 0x1B, ///< Finish handling this command - OP_CHAIN = 0x1C, ///< Chain to the next handler - OP_ABORT = 0x1D, ///< Abort this command - OP_EXIT = 0x1E, ///< Exit the game - OP_RETURN = 0x1F, ///< Return from function - OP_CALL = 0x20, ///< Call subroutine - OP_SVAR = 0x21, ///< Short load a variable - OP_SSET = 0x22, ///< Short set a variable - OP_SPLIT = 0x23, ///< Short load a positive literal - OP_SNLIT = 0x24, ///< Short load a negative literal - OP_YORN = 0x25, ///< Yes or No predicate - OP_SAVE = 0x26, ///< Save data structures - OP_RESTORE = 0x27, ///< Restore data structures - OP_ARG = 0x28, ///< Load an argument value - OP_ASET = 0x29, ///< Set an argument value - OP_TMP = 0x2A, ///< Load a temporary variable value - OP_TSET = 0x2B, ///< Set a temporary variable - OP_TSPACE = 0x2C, ///< Allocate temporary variable space - OP_CLASS = 0x2D, ///< Get the class of an object - OP_MATCH = 0x2E, ///< Match a noun phrase with an object - OP_PNOUN = 0x2F, ///< Print a noun phrase - OP_RESTART = 0x30, ///< Restart the current game - OP_RAND = 0x31, ///< Generate a random number - OP_RNDMIZE = 0x32, ///< Seed the random number generator - OP_SEND = 0x33, ///< Send a message to an object - OP_VOWEL = 0x34, ///< Check for vowel beginning string + OP_BRT = 0x01, ///< Branch on true + OP_BRF = 0x02, ///< Branch on false + OP_BR = 0x03, ///< Branch unconditionally + OP_T = 0x04, ///< Load top of stack with t + OP_NIL = 0x05, ///< Load top of stack with nil + OP_PUSH = 0x06, ///< Push nil onto stack + OP_NOT = 0x07, ///< Logical negate top of stack + OP_ADD = 0x08, ///< Add two numeric expressions + OP_SUB = 0x09, ///< Subtract two numeric expressions + OP_MUL = 0x0A, ///< Multiply two numeric expressions + OP_DIV = 0x0B, ///< Divide two numeric expressions + OP_REM = 0x0C, ///< Remainder of two numeric expressions + OP_BAND = 0x0D, ///< Bitwise and of two numeric expressions + OP_BOR = 0x0E, ///< Bitwise or of two numeric expressions + OP_BNOT = 0x0F, ///< Bitwise not + OP_LT = 0x10, ///< Less than + OP_EQ = 0x11, ///< Equal to + OP_GT = 0x12, ///< Greater than + OP_LIT = 0x13, ///< Load literal + OP_VAR = 0x14, ///< Load a variable value + OP_GETP = 0x15, ///< Get the value of an object property + OP_SETP = 0x16, ///< Set the value of an object property + OP_SET = 0x17, ///< Set the value of a variable + OP_PRINT = 0x18, ///< Print messages + OP_TERPRI = 0x19, ///< Terminate the print line + OP_PNUMBER = 0x1A, ///< Print a number + OP_FINISH = 0x1B, ///< Finish handling this command + OP_CHAIN = 0x1C, ///< Chain to the next handler + OP_ABORT = 0x1D, ///< Abort this command + OP_EXIT = 0x1E, ///< Exit the game + OP_RETURN = 0x1F, ///< Return from function + OP_CALL = 0x20, ///< Call subroutine + OP_SVAR = 0x21, ///< Short load a variable + OP_SSET = 0x22, ///< Short set a variable + OP_SPLIT = 0x23, ///< Short load a positive literal + OP_SNLIT = 0x24, ///< Short load a negative literal + OP_YORN = 0x25, ///< Yes or No predicate + OP_SAVE = 0x26, ///< Save data structures + OP_RESTORE = 0x27, ///< Restore data structures + OP_ARG = 0x28, ///< Load an argument value + OP_ASET = 0x29, ///< Set an argument value + OP_TMP = 0x2A, ///< Load a temporary variable value + OP_TSET = 0x2B, ///< Set a temporary variable + OP_TSPACE = 0x2C, ///< Allocate temporary variable space + OP_CLASS = 0x2D, ///< Get the class of an object + OP_MATCH = 0x2E, ///< Match a noun phrase with an object + OP_PNOUN = 0x2F, ///< Print a noun phrase + OP_RESTART = 0x30, ///< Restart the current game + OP_RAND = 0x31, ///< Generate a random number + OP_RNDMIZE = 0x32, ///< Seed the random number generator + OP_SEND = 0x33, ///< Send a message to an object + OP_VOWEL = 0x34, ///< Check for vowel beginning string - OP_XVAR = 0x40, ///< Extra short load a variable - OP_XSET = 0x60, ///< Extra short set a variable - OP_XPLIT = 0x80, ///< Extra short load a positive literal - OP_XNLIT = 0xC0 ///< Extra short load a negative literal + OP_XVAR = 0x40, ///< Extra short load a variable + OP_XSET = 0x60, ///< Extra short set a variable + OP_XPLIT = 0x80, ///< Extra short load a positive literal + OP_XNLIT = 0xC0 ///< Extra short load a negative literal }; class VM; @@ -115,7 +115,9 @@ class VM : public GlkInterface, public Game { /** * Push a value onto the stack */ - void push(int v) { push_back(v); } + void push(int v) { + push_back(v); + } /** * Pop a value from the stack @@ -211,8 +213,8 @@ public: /** * Exeecute a script - * @param offset Script offset - * @returns Script result code + * @param offset Script offset + * @returns Script result code */ ExecutionResult execute(int offset); }; |