[Scummvm-cvs-logs] SF.net SVN: scummvm: [28602] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Tue Aug 14 01:49:38 CEST 2007


Revision: 28602
          http://scummvm.svn.sourceforge.net/scummvm/?rev=28602&view=rev
Author:   peres001
Date:     2007-08-13 16:49:38 -0700 (Mon, 13 Aug 2007)

Log Message:
-----------
Moved opcode initialization to new routine.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/animation.cpp
    scummvm/trunk/engines/parallaction/commands.cpp
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/parallaction/parallaction.h

Modified: scummvm/trunk/engines/parallaction/animation.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/animation.cpp	2007-08-13 23:44:13 UTC (rev 28601)
+++ scummvm/trunk/engines/parallaction/animation.cpp	2007-08-13 23:49:38 UTC (rev 28602)
@@ -419,30 +419,6 @@
 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 @@
 
 	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;

Modified: scummvm/trunk/engines/parallaction/commands.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/commands.cpp	2007-08-13 23:44:13 UTC (rev 28601)
+++ scummvm/trunk/engines/parallaction/commands.cpp	2007-08-13 23:49:38 UTC (rev 28602)
@@ -119,28 +119,6 @@
 
 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 @@
 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++) {
 

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2007-08-13 23:44:13 UTC (rev 28601)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2007-08-13 23:49:38 UTC (rev 28602)
@@ -177,6 +177,8 @@
 
 	memset(_locationNames, 0, 120*32);
 
+	initOpcodes();
+
 	initInventory();	// needs to be pushed into subclass
 
 	_animations.push_front(&_char._ani);
@@ -846,4 +848,99 @@
 	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

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2007-08-13 23:44:13 UTC (rev 28601)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2007-08-13 23:49:38 UTC (rev 28602)
@@ -326,6 +326,8 @@
 
 	void 		waitTime(uint32 t);
 
+	void initOpcodes();
+
 	typedef void (Parallaction::*Opcode)();
 	const Opcode	*_commandParsers;
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list