diff options
author | Nicola Mettifogo | 2007-08-13 23:58:17 +0000 |
---|---|---|
committer | Nicola Mettifogo | 2007-08-13 23:58:17 +0000 |
commit | 3c43ebd49f08c5d41aca61576d1a08e2957c9eb6 (patch) | |
tree | ca89bb55170db328a92f62aed507b371c43273b2 /engines | |
parent | 681ae6ca8514d24a51e2c1e7ecbf8ac6fa633013 (diff) | |
download | scummvm-rg350-3c43ebd49f08c5d41aca61576d1a08e2957c9eb6.tar.gz scummvm-rg350-3c43ebd49f08c5d41aca61576d1a08e2957c9eb6.tar.bz2 scummvm-rg350-3c43ebd49f08c5d41aca61576d1a08e2957c9eb6.zip |
Added invalid opcode entries in slot 0 of opcode lists, and adjusted indices to avoid small decrements.
svn-id: r28603
Diffstat (limited to 'engines')
-rw-r--r-- | engines/parallaction/animation.cpp | 6 | ||||
-rw-r--r-- | engines/parallaction/commands.cpp | 12 | ||||
-rw-r--r-- | engines/parallaction/parallaction.cpp | 5 | ||||
-rw-r--r-- | engines/parallaction/parallaction.h | 5 |
4 files changed, 21 insertions, 7 deletions
diff --git a/engines/parallaction/animation.cpp b/engines/parallaction/animation.cpp index 790d9b7ade..7e51cb9826 100644 --- a/engines/parallaction/animation.cpp +++ b/engines/parallaction/animation.cpp @@ -574,6 +574,10 @@ DECLARE_INSTRUCTION_OPCODE(null) { } +DECLARE_INSTRUCTION_OPCODE(invalid) { + error("Can't execute invalid opcode %i", (*_instRunCtxt.inst)->_index); +} + DECLARE_INSTRUCTION_OPCODE(call) { callFunction((*_instRunCtxt.inst)->_opBase._index, 0); } @@ -637,7 +641,7 @@ void jobRunScripts(void *parm, Job *j) { _vm->_instRunCtxt.modCounter = modCounter; _vm->_instRunCtxt.suspend = false; - (_vm->*(_vm->_instructionOpcodes)[(*inst)->_index - 1])(); + (_vm->*(_vm->_instructionOpcodes)[(*inst)->_index])(); inst = _vm->_instRunCtxt.inst; // handles endloop correctly diff --git a/engines/parallaction/commands.cpp b/engines/parallaction/commands.cpp index 0465d8ec48..978cc6c3f8 100644 --- a/engines/parallaction/commands.cpp +++ b/engines/parallaction/commands.cpp @@ -114,8 +114,9 @@ DECLARE_COMMAND_PARSER(Move) { _cmdParseCtxt.nextToken++; } - - +DECLARE_COMMAND_PARSER(Invalid) { + error("Can't parse unknown command '%s'", _tokens[0]); +} void Parallaction::parseCommands(Script &script, CommandList& list) { @@ -130,7 +131,7 @@ void Parallaction::parseCommands(Script &script, CommandList& list) { _cmdParseCtxt.nextToken = 1; _cmdParseCtxt.cmd = cmd; - (this->*_commandParsers[cmd->_id - 1])(); + (this->*_commandParsers[cmd->_id])(); int _si = _cmdParseCtxt.nextToken; @@ -194,6 +195,9 @@ void Parallaction::parseCommands(Script &script, CommandList& list) { } } +DECLARE_COMMAND_OPCODE(invalid) { + error("Can't execute invalid command '%i'", _cmdRunCtxt.cmd->_id); +} DECLARE_COMMAND_OPCODE(set) { if (_cmdRunCtxt.cmd->u._flags & kFlagsGlobal) { @@ -345,7 +349,7 @@ void Parallaction::runCommands(CommandList& list, Zone *z) { _cmdRunCtxt.z = z; _cmdRunCtxt.cmd = cmd; - (this->*_commandOpcodes[cmd->_id - 1])(); + (this->*_commandOpcodes[cmd->_id])(); } debugC(1, kDebugLocation, "runCommands completed"); diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index 85d5bf027f..2a53eb11a2 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -851,7 +851,7 @@ int Table::lookup(const char* s) { void Parallaction::initOpcodes() { static const Opcode op0[] = { - INSTRUCTION_PARSER(defLocal), // unknown opcode -> local definition + INSTRUCTION_PARSER(defLocal), // invalid opcode -> local definition INSTRUCTION_PARSER(animation), // on INSTRUCTION_PARSER(animation), // off INSTRUCTION_PARSER(x), @@ -876,6 +876,7 @@ void Parallaction::initOpcodes() { static const Opcode op1[] = { + INSTRUCTION_OPCODE(invalid), INSTRUCTION_OPCODE(on), INSTRUCTION_OPCODE(off), INSTRUCTION_OPCODE(set), // x @@ -900,6 +901,7 @@ void Parallaction::initOpcodes() { _vm->_instructionOpcodes = op1; static const Opcode op2[] = { + COMMAND_PARSER(Invalid), COMMAND_PARSER(Flags), // set COMMAND_PARSER(Flags), // clear COMMAND_PARSER(Animation), // start @@ -921,6 +923,7 @@ void Parallaction::initOpcodes() { _commandParsers = op2; static const Opcode op3[] = { + COMMAND_OPCODE(invalid), COMMAND_OPCODE(set), COMMAND_OPCODE(clear), COMMAND_OPCODE(start), diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index 9251e144b8..3da097cfbd 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -336,6 +336,7 @@ public: int nextToken; } _cmdParseCtxt; + DECLARE_COMMAND_PARSER(Invalid); DECLARE_COMMAND_PARSER(Flags); DECLARE_COMMAND_PARSER(Animation); DECLARE_COMMAND_PARSER(Zone); @@ -352,6 +353,7 @@ public: Zone *z; } _cmdRunCtxt; + DECLARE_COMMAND_OPCODE(invalid); DECLARE_COMMAND_OPCODE(set); DECLARE_COMMAND_OPCODE(clear); DECLARE_COMMAND_OPCODE(start); @@ -377,6 +379,7 @@ public: LocalVariable *locals; } _instParseCtxt; + DECLARE_INSTRUCTION_PARSER(defLocal); DECLARE_INSTRUCTION_PARSER(animation); DECLARE_INSTRUCTION_PARSER(loop); DECLARE_INSTRUCTION_PARSER(x); @@ -390,7 +393,6 @@ public: DECLARE_INSTRUCTION_PARSER(call); DECLARE_INSTRUCTION_PARSER(sound); DECLARE_INSTRUCTION_PARSER(null); - DECLARE_INSTRUCTION_PARSER(defLocal); const Opcode *_instructionOpcodes; @@ -401,6 +403,7 @@ public: bool suspend; } _instRunCtxt; + DECLARE_INSTRUCTION_OPCODE(invalid); DECLARE_INSTRUCTION_OPCODE(on); DECLARE_INSTRUCTION_OPCODE(off); DECLARE_INSTRUCTION_OPCODE(loop); |