Added invalid opcode entries in slot 0 of opcode lists, and adjusted indices to avoid small decrements.

svn-id: r28603
This commit is contained in:
Nicola Mettifogo 2007-08-13 23:58:17 +00:00
parent 681ae6ca85
commit 3c43ebd49f
4 changed files with 21 additions and 7 deletions

View File

@ -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

View File

@ -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");

View File

@ -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),

View File

@ -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);