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

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Sun Feb 3 15:58:16 CET 2008


Revision: 30768
          http://scummvm.svn.sourceforge.net/scummvm/?rev=30768&view=rev
Author:   peres001
Date:     2008-02-03 06:58:16 -0800 (Sun, 03 Feb 2008)

Log Message:
-----------
Programs are now handled in their own list, instead of being accessed via the referring Animation.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/exec_br.cpp
    scummvm/trunk/engines/parallaction/exec_ns.cpp
    scummvm/trunk/engines/parallaction/objects.cpp
    scummvm/trunk/engines/parallaction/objects.h
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/parallaction/parallaction.h
    scummvm/trunk/engines/parallaction/parallaction_br.cpp
    scummvm/trunk/engines/parallaction/parser_br.cpp
    scummvm/trunk/engines/parallaction/parser_ns.cpp

Modified: scummvm/trunk/engines/parallaction/exec_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_br.cpp	2008-02-03 13:31:32 UTC (rev 30767)
+++ scummvm/trunk/engines/parallaction/exec_br.cpp	2008-02-03 14:58:16 UTC (rev 30768)
@@ -316,8 +316,8 @@
 DECLARE_INSTRUCTION_OPCODE(loop) {
 	Instruction *inst = *_instRunCtxt.inst;
 
-	_instRunCtxt.a->_program->_loopCounter = inst->_opB.getRValue();
-	_instRunCtxt.a->_program->_loopStart = _instRunCtxt.inst;
+	_instRunCtxt.program->_loopCounter = inst->_opB.getRValue();
+	_instRunCtxt.program->_loopStart = _instRunCtxt.inst;
 }
 
 
@@ -444,11 +444,11 @@
 }
 
 DECLARE_INSTRUCTION_OPCODE(endscript) {
-	if ((_instRunCtxt.a->_flags & kFlagsLooping) == 0) {
-		_instRunCtxt.a->_flags &= ~kFlagsActing;
-		runCommands(_instRunCtxt.a->_commands, _instRunCtxt.a);
+	if ((_instRunCtxt.anim->_flags & kFlagsLooping) == 0) {
+		_instRunCtxt.anim->_flags &= ~kFlagsActing;
+		runCommands(_instRunCtxt.anim->_commands, _instRunCtxt.anim);
 	}
-	_instRunCtxt.a->_program->_ip = _instRunCtxt.a->_program->_instructions.begin();
+	_instRunCtxt.program->_ip = _instRunCtxt.program->_instructions.begin();
 
 	_instRunCtxt.suspend = true;
 }

Modified: scummvm/trunk/engines/parallaction/exec_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_ns.cpp	2008-02-03 13:31:32 UTC (rev 30767)
+++ scummvm/trunk/engines/parallaction/exec_ns.cpp	2008-02-03 14:58:16 UTC (rev 30768)
@@ -76,14 +76,14 @@
 DECLARE_INSTRUCTION_OPCODE(loop) {
 	Instruction *inst = *_instRunCtxt.inst;
 
-	_instRunCtxt.a->_program->_loopCounter = inst->_opB.getRValue();
-	_instRunCtxt.a->_program->_loopStart = _instRunCtxt.inst;
+	_instRunCtxt.program->_loopCounter = inst->_opB.getRValue();
+	_instRunCtxt.program->_loopStart = _instRunCtxt.inst;
 }
 
 
 DECLARE_INSTRUCTION_OPCODE(endloop) {
-	if (--_instRunCtxt.a->_program->_loopCounter > 0) {
-		_instRunCtxt.inst = _instRunCtxt.a->_program->_loopStart;
+	if (--_instRunCtxt.program->_loopCounter > 0) {
+		_instRunCtxt.inst = _instRunCtxt.program->_loopStart;
 	}
 }
 
@@ -177,11 +177,11 @@
 }
 
 DECLARE_INSTRUCTION_OPCODE(endscript) {
-	if ((_instRunCtxt.a->_flags & kFlagsLooping) == 0) {
-		_instRunCtxt.a->_flags &= ~kFlagsActing;
-		runCommands(_instRunCtxt.a->_commands, _instRunCtxt.a);
+	if ((_instRunCtxt.anim->_flags & kFlagsLooping) == 0) {
+		_instRunCtxt.anim->_flags &= ~kFlagsActing;
+		runCommands(_instRunCtxt.anim->_commands, _instRunCtxt.anim);
 	}
-	_instRunCtxt.a->_program->_ip = _instRunCtxt.a->_program->_instructions.begin();
+	_instRunCtxt.program->_ip = _instRunCtxt.program->_instructions.begin();
 
 	_instRunCtxt.suspend = true;
 }
@@ -373,9 +373,9 @@
 
 	static uint16 modCounter = 0;
 
-	for (AnimationList::iterator it = _animations.begin(); it != _animations.end(); it++) {
+	for (ProgramList::iterator it = _programs.begin(); it != _programs.end(); it++) {
 
-		Animation *a = *it;
+		Animation *a = (*it)->_anim;
 
 		if (a->_flags & kFlagsCharacter)
 			a->_z = a->_top + a->height();
@@ -383,13 +383,14 @@
 		if ((a->_flags & kFlagsActing) == 0)
 			continue;
 
-		InstructionList::iterator inst = a->_program->_ip;
+		InstructionList::iterator inst = (*it)->_ip;
 		while (((*inst)->_index != INST_SHOW) && (a->_flags & kFlagsActing)) {
 
 			debugC(9, kDebugExec, "Animation: %s, instruction: %s", a->_name, _instructionNamesRes[(*inst)->_index - 1]);
 
 			_instRunCtxt.inst = inst;
-			_instRunCtxt.a = a;
+			_instRunCtxt.anim = a;
+			_instRunCtxt.program = *it;
 			_instRunCtxt.modCounter = modCounter;
 			_instRunCtxt.suspend = false;
 
@@ -403,7 +404,7 @@
 			inst++;
 		}
 
-		a->_program->_ip = ++inst;
+		(*it)->_ip = ++inst;
 
 label1:
 		if (a->_flags & kFlagsCharacter)

Modified: scummvm/trunk/engines/parallaction/objects.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/objects.cpp	2008-02-03 13:31:32 UTC (rev 30767)
+++ scummvm/trunk/engines/parallaction/objects.cpp	2008-02-03 14:58:16 UTC (rev 30768)
@@ -44,14 +44,12 @@
 
 Animation::Animation() {
 	gfxobj = NULL;
-	_program = NULL;
 	_scriptName = 0;
 	_frame = 0;
 	_z = 0;
 }
 
 Animation::~Animation() {
-	delete _program;
 	free(_scriptName);
 }
 

Modified: scummvm/trunk/engines/parallaction/objects.h
===================================================================
--- scummvm/trunk/engines/parallaction/objects.h	2008-02-03 13:31:32 UTC (rev 30767)
+++ scummvm/trunk/engines/parallaction/objects.h	2008-02-03 14:58:16 UTC (rev 30768)
@@ -365,6 +365,8 @@
 
 
 struct Program {
+	Animation		*_anim;
+
 	LocalVariable	*_locals;
 
 	uint16			_loopCounter;
@@ -382,12 +384,11 @@
 	int16		addLocal(const char *name, int16 value = 0, int16 min = -10000, int16 max = 10000);
 };
 
+typedef ManagedList<Program*> ProgramList;
 
-
 struct Animation : public Zone {
 
 	Common::Point	_oldPos;
-	Program 	*_program;
 	GfxObj		*gfxobj;
 	char		*_scriptName;
 	int16		_frame;

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2008-02-03 13:31:32 UTC (rev 30767)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2008-02-03 14:58:16 UTC (rev 30768)
@@ -715,6 +715,7 @@
 	_gfx->clearGfxObjects();
 	freeBackground();
 
+	_programs.clear();
 	freeZones();
 	freeAnimations();
 

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2008-02-03 13:31:32 UTC (rev 30767)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2008-02-03 14:58:16 UTC (rev 30768)
@@ -325,7 +325,8 @@
 	OpcodeSet	_instructionOpcodes;
 
 	struct {
-		Animation	*a;
+		Animation	*anim;
+		Program		*program;
 		InstructionList::iterator inst;
 		uint16		modCounter;
 		bool		suspend;
@@ -404,6 +405,7 @@
 
 	ZoneList		_zones;
 	AnimationList	_animations;
+	ProgramList		_programs;
 
 	Font		*_labelFont;
 	Font		*_menuFont;
@@ -787,7 +789,7 @@
 	DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(null);
 	DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(endscript);
 
-	void		parseInstruction(Animation *a, LocalVariable *locals);
+	void		parseInstruction(Program *program);
 	void		loadProgram(Animation *a, const char *filename);
 	void		parseLValue(ScriptVar &var, const char *str);
 	virtual void	parseRValue(ScriptVar &var, const char *str);

Modified: scummvm/trunk/engines/parallaction/parallaction_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_br.cpp	2008-02-03 13:31:32 UTC (rev 30767)
+++ scummvm/trunk/engines/parallaction/parallaction_br.cpp	2008-02-03 14:58:16 UTC (rev 30768)
@@ -208,6 +208,7 @@
 	clearSubtitles();
 	freeBackground();
 	_gfx->clearGfxObjects();
+	_programs.clear();
 	freeZones();
 	freeAnimations();
 //	free(_location._comment);

Modified: scummvm/trunk/engines/parallaction/parser_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parser_br.cpp	2008-02-03 13:31:32 UTC (rev 30767)
+++ scummvm/trunk/engines/parallaction/parser_br.cpp	2008-02-03 14:58:16 UTC (rev 30768)
@@ -949,7 +949,7 @@
 
 	AnimationList::iterator it = _animations.begin();
 	for ( ; it != _animations.end(); it++) {
-		if (((*it)->_scriptName) && ((*it)->_program == 0)) {
+		if ((*it)->_scriptName) {
 			loadProgram(*it, (*it)->_scriptName);
 		}
 	}

Modified: scummvm/trunk/engines/parallaction/parser_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parser_ns.cpp	2008-02-03 13:31:32 UTC (rev 30767)
+++ scummvm/trunk/engines/parallaction/parser_ns.cpp	2008-02-03 14:58:16 UTC (rev 30768)
@@ -196,7 +196,7 @@
 	return a;
 }
 
-void Parallaction_ns::parseInstruction(Animation *a, LocalVariable *locals) {
+void Parallaction_ns::parseInstruction(Program *program) {
 
 	Instruction *inst = new Instruction;
 
@@ -208,15 +208,15 @@
 		_tokens[1][1] = '\0';
 		_instParseCtxt.a = findAnimation(&_tokens[1][2]);
 	} else
-		_instParseCtxt.a = a;
+		_instParseCtxt.a = program->_anim;
 
 	inst->_index = _instructionNames->lookup(_tokens[0]);
 	_instParseCtxt.inst = inst;
-	_instParseCtxt.locals = locals;
+	_instParseCtxt.locals = program->_locals;
 
 	(*(_instructionParsers[inst->_index]))();
 
-	a->_program->_instructions.push_back(inst);
+	program->_instructions.push_back(inst);
 
 	return;
 }
@@ -225,22 +225,24 @@
 	debugC(1, kDebugParser, "loadProgram(Animation: %s, script: %s)", a->_name, filename);
 
 	Script *script = _disk->loadScript(filename);
+	Program *program = new Program;
+	program->_anim = a;
 
-	a->_program = new Program;
-
 	_instParseCtxt.openIf = NULL;
 	_instParseCtxt.end = false;
-	_instParseCtxt.program = a->_program;
+	_instParseCtxt.program = program;
 
 	do {
 		script->readLineToken();
-		parseInstruction(a, a->_program->_locals);
+		parseInstruction(program);
 	} while (!_instParseCtxt.end);
 
-	a->_program->_ip = a->_program->_instructions.begin();
+	program->_ip = program->_instructions.begin();
 
 	delete script;
 
+	_programs.push_back(program);
+
 	debugC(1, kDebugParser, "loadProgram() done");
 
 	return;
@@ -998,7 +1000,7 @@
 	// this loads animation scripts
 	AnimationList::iterator it = _animations.begin();
 	for ( ; it != _animations.end(); it++) {
-		if (((*it)->_scriptName) && ((*it)->_program == 0)) {
+		if ((*it)->_scriptName) {
 			loadProgram(*it, (*it)->_scriptName);
 		}
 	}


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