aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicola Mettifogo2007-08-13 23:49:38 +0000
committerNicola Mettifogo2007-08-13 23:49:38 +0000
commit681ae6ca8514d24a51e2c1e7ecbf8ac6fa633013 (patch)
tree190a70282baa7b7d16bf2e57833bfbdba7abd123
parent0f489597aa63ebd4460506f7231d7c2bca0c8639 (diff)
downloadscummvm-rg350-681ae6ca8514d24a51e2c1e7ecbf8ac6fa633013.tar.gz
scummvm-rg350-681ae6ca8514d24a51e2c1e7ecbf8ac6fa633013.tar.bz2
scummvm-rg350-681ae6ca8514d24a51e2c1e7ecbf8ac6fa633013.zip
Moved opcode initialization to new routine.
svn-id: r28602
-rw-r--r--engines/parallaction/animation.cpp48
-rw-r--r--engines/parallaction/commands.cpp43
-rw-r--r--engines/parallaction/parallaction.cpp97
-rw-r--r--engines/parallaction/parallaction.h2
4 files changed, 99 insertions, 91 deletions
diff --git a/engines/parallaction/animation.cpp b/engines/parallaction/animation.cpp
index 43d1042f2a..790d9b7ade 100644
--- a/engines/parallaction/animation.cpp
+++ b/engines/parallaction/animation.cpp
@@ -419,30 +419,6 @@ DECLARE_INSTRUCTION_PARSER(defLocal) {
void Parallaction::parseScriptLine(Instruction *inst, Animation *a, LocalVariable *locals) {
// printf("parseScriptLine()\n");
- static const Opcode opcodes[] = {
- INSTRUCTION_PARSER(defLocal), // unknown opcode -> local definition
- INSTRUCTION_PARSER(animation), // on
- INSTRUCTION_PARSER(animation), // off
- INSTRUCTION_PARSER(x),
- INSTRUCTION_PARSER(y),
- INSTRUCTION_PARSER(z),
- INSTRUCTION_PARSER(f),
- INSTRUCTION_PARSER(loop),
- INSTRUCTION_PARSER(null), // endloop
- INSTRUCTION_PARSER(null), // show
- INSTRUCTION_PARSER(inc),
- INSTRUCTION_PARSER(inc), // dec
- INSTRUCTION_PARSER(set),
- INSTRUCTION_PARSER(put),
- INSTRUCTION_PARSER(call),
- INSTRUCTION_PARSER(null), // wait
- INSTRUCTION_PARSER(animation), // start
- INSTRUCTION_PARSER(sound),
- INSTRUCTION_PARSER(move)
- };
-
- _instructionParsers = opcodes;
-
if (_tokens[0][1] == '.') {
_tokens[0][1] = '\0';
a = findAnimation(&_tokens[0][2]);
@@ -643,30 +619,6 @@ void jobRunScripts(void *parm, Job *j) {
static uint16 modCounter = 0;
- static const Parallaction::Opcode opcodes[] = {
- INSTRUCTION_OPCODE(on),
- INSTRUCTION_OPCODE(off),
- INSTRUCTION_OPCODE(set), // x
- INSTRUCTION_OPCODE(set), // y
- INSTRUCTION_OPCODE(set), // z
- INSTRUCTION_OPCODE(set), // f
- INSTRUCTION_OPCODE(loop),
- INSTRUCTION_OPCODE(endloop),
- INSTRUCTION_OPCODE(null),
- INSTRUCTION_OPCODE(inc),
- INSTRUCTION_OPCODE(inc), // dec
- INSTRUCTION_OPCODE(set),
- INSTRUCTION_OPCODE(put),
- INSTRUCTION_OPCODE(call),
- INSTRUCTION_OPCODE(wait),
- INSTRUCTION_OPCODE(start),
- INSTRUCTION_OPCODE(sound),
- INSTRUCTION_OPCODE(move),
- INSTRUCTION_OPCODE(end)
- };
-
- _vm->_instructionOpcodes = opcodes;
-
for (AnimationList::iterator it = _vm->_animations.begin(); it != _vm->_animations.end(); it++) {
Animation *a = *it;
diff --git a/engines/parallaction/commands.cpp b/engines/parallaction/commands.cpp
index ba5b89e7e5..0465d8ec48 100644
--- a/engines/parallaction/commands.cpp
+++ b/engines/parallaction/commands.cpp
@@ -119,28 +119,6 @@ DECLARE_COMMAND_PARSER(Move) {
void Parallaction::parseCommands(Script &script, CommandList& list) {
- static const Opcode parsers[] = {
- COMMAND_PARSER(Flags), // set
- COMMAND_PARSER(Flags), // clear
- COMMAND_PARSER(Animation), // start
- COMMAND_PARSER(Zone), // speak
- COMMAND_PARSER(Zone), // get
- COMMAND_PARSER(Location), // location
- COMMAND_PARSER(Zone), // open
- COMMAND_PARSER(Zone), // close
- COMMAND_PARSER(Zone), // on
- COMMAND_PARSER(Zone), // off
- COMMAND_PARSER(Call), // call
- COMMAND_PARSER(Flags), // toggle
- COMMAND_PARSER(Drop), // drop
- COMMAND_PARSER(Null), // quit
- COMMAND_PARSER(Move), // move
- COMMAND_PARSER(Animation) // stop
- };
-
- _commandParsers = parsers;
-
-
fillBuffers(script, true);
while (scumm_stricmp(_tokens[0], "ENDCOMMANDS") && scumm_stricmp(_tokens[0], "ENDZONE")) {
@@ -346,27 +324,6 @@ DECLARE_COMMAND_OPCODE(stop) {
void Parallaction::runCommands(CommandList& list, Zone *z) {
debugC(1, kDebugLocation, "runCommands");
- static const Opcode opcodes[] = {
- COMMAND_OPCODE(set),
- COMMAND_OPCODE(clear),
- COMMAND_OPCODE(start),
- COMMAND_OPCODE(speak),
- COMMAND_OPCODE(get),
- COMMAND_OPCODE(location),
- COMMAND_OPCODE(open),
- COMMAND_OPCODE(close),
- COMMAND_OPCODE(on),
- COMMAND_OPCODE(off),
- COMMAND_OPCODE(call),
- COMMAND_OPCODE(toggle),
- COMMAND_OPCODE(drop),
- COMMAND_OPCODE(quit),
- COMMAND_OPCODE(move),
- COMMAND_OPCODE(stop)
- };
-
- _commandOpcodes = opcodes;
-
CommandList::iterator it = list.begin();
for ( ; it != list.end(); it++) {
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index 1261086d2f..85d5bf027f 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -177,6 +177,8 @@ int Parallaction::init() {
memset(_locationNames, 0, 120*32);
+ initOpcodes();
+
initInventory(); // needs to be pushed into subclass
_animations.push_front(&_char._ani);
@@ -846,4 +848,99 @@ int Table::lookup(const char* s) {
return notFound;
}
+void Parallaction::initOpcodes() {
+
+ static const Opcode op0[] = {
+ INSTRUCTION_PARSER(defLocal), // unknown opcode -> local definition
+ INSTRUCTION_PARSER(animation), // on
+ INSTRUCTION_PARSER(animation), // off
+ INSTRUCTION_PARSER(x),
+ INSTRUCTION_PARSER(y),
+ INSTRUCTION_PARSER(z),
+ INSTRUCTION_PARSER(f),
+ INSTRUCTION_PARSER(loop),
+ INSTRUCTION_PARSER(null), // endloop
+ INSTRUCTION_PARSER(null), // show
+ INSTRUCTION_PARSER(inc),
+ INSTRUCTION_PARSER(inc), // dec
+ INSTRUCTION_PARSER(set),
+ INSTRUCTION_PARSER(put),
+ INSTRUCTION_PARSER(call),
+ INSTRUCTION_PARSER(null), // wait
+ INSTRUCTION_PARSER(animation), // start
+ INSTRUCTION_PARSER(sound),
+ INSTRUCTION_PARSER(move)
+ };
+
+ _instructionParsers = op0;
+
+
+ static const Opcode op1[] = {
+ INSTRUCTION_OPCODE(on),
+ INSTRUCTION_OPCODE(off),
+ INSTRUCTION_OPCODE(set), // x
+ INSTRUCTION_OPCODE(set), // y
+ INSTRUCTION_OPCODE(set), // z
+ INSTRUCTION_OPCODE(set), // f
+ INSTRUCTION_OPCODE(loop),
+ INSTRUCTION_OPCODE(endloop),
+ INSTRUCTION_OPCODE(null),
+ INSTRUCTION_OPCODE(inc),
+ INSTRUCTION_OPCODE(inc), // dec
+ INSTRUCTION_OPCODE(set),
+ INSTRUCTION_OPCODE(put),
+ INSTRUCTION_OPCODE(call),
+ INSTRUCTION_OPCODE(wait),
+ INSTRUCTION_OPCODE(start),
+ INSTRUCTION_OPCODE(sound),
+ INSTRUCTION_OPCODE(move),
+ INSTRUCTION_OPCODE(end)
+ };
+
+ _vm->_instructionOpcodes = op1;
+
+ static const Opcode op2[] = {
+ COMMAND_PARSER(Flags), // set
+ COMMAND_PARSER(Flags), // clear
+ COMMAND_PARSER(Animation), // start
+ COMMAND_PARSER(Zone), // speak
+ COMMAND_PARSER(Zone), // get
+ COMMAND_PARSER(Location), // location
+ COMMAND_PARSER(Zone), // open
+ COMMAND_PARSER(Zone), // close
+ COMMAND_PARSER(Zone), // on
+ COMMAND_PARSER(Zone), // off
+ COMMAND_PARSER(Call), // call
+ COMMAND_PARSER(Flags), // toggle
+ COMMAND_PARSER(Drop), // drop
+ COMMAND_PARSER(Null), // quit
+ COMMAND_PARSER(Move), // move
+ COMMAND_PARSER(Animation) // stop
+ };
+
+ _commandParsers = op2;
+
+ static const Opcode op3[] = {
+ COMMAND_OPCODE(set),
+ COMMAND_OPCODE(clear),
+ COMMAND_OPCODE(start),
+ COMMAND_OPCODE(speak),
+ COMMAND_OPCODE(get),
+ COMMAND_OPCODE(location),
+ COMMAND_OPCODE(open),
+ COMMAND_OPCODE(close),
+ COMMAND_OPCODE(on),
+ COMMAND_OPCODE(off),
+ COMMAND_OPCODE(call),
+ COMMAND_OPCODE(toggle),
+ COMMAND_OPCODE(drop),
+ COMMAND_OPCODE(quit),
+ COMMAND_OPCODE(move),
+ COMMAND_OPCODE(stop)
+ };
+
+ _commandOpcodes = op3;
+
+}
+
} // namespace Parallaction
diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h
index d491e1f807..9251e144b8 100644
--- a/engines/parallaction/parallaction.h
+++ b/engines/parallaction/parallaction.h
@@ -326,6 +326,8 @@ public:
void waitTime(uint32 t);
+ void initOpcodes();
+
typedef void (Parallaction::*Opcode)();
const Opcode *_commandParsers;