diff options
| -rw-r--r-- | engines/parallaction/exec_br.cpp | 12 | ||||
| -rw-r--r-- | engines/parallaction/exec_ns.cpp | 27 | ||||
| -rw-r--r-- | engines/parallaction/objects.cpp | 2 | ||||
| -rw-r--r-- | engines/parallaction/objects.h | 5 | ||||
| -rw-r--r-- | engines/parallaction/parallaction.cpp | 1 | ||||
| -rw-r--r-- | engines/parallaction/parallaction.h | 6 | ||||
| -rw-r--r-- | engines/parallaction/parallaction_br.cpp | 1 | ||||
| -rw-r--r-- | engines/parallaction/parser_br.cpp | 2 | ||||
| -rw-r--r-- | engines/parallaction/parser_ns.cpp | 22 | 
9 files changed, 42 insertions, 36 deletions
| diff --git a/engines/parallaction/exec_br.cpp b/engines/parallaction/exec_br.cpp index 567d5ecf79..325fb97f67 100644 --- a/engines/parallaction/exec_br.cpp +++ b/engines/parallaction/exec_br.cpp @@ -316,8 +316,8 @@ DECLARE_INSTRUCTION_OPCODE(set) {  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(stop) {  }  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;  } diff --git a/engines/parallaction/exec_ns.cpp b/engines/parallaction/exec_ns.cpp index bfe65d4054..3ddc9fde06 100644 --- a/engines/parallaction/exec_ns.cpp +++ b/engines/parallaction/exec_ns.cpp @@ -76,14 +76,14 @@ DECLARE_INSTRUCTION_OPCODE(off) {  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(move) {  }  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 @@ void Parallaction_ns::runScripts() {  	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 @@ void Parallaction_ns::runScripts() {  		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 @@ void Parallaction_ns::runScripts() {  			inst++;  		} -		a->_program->_ip = ++inst; +		(*it)->_ip = ++inst;  label1:  		if (a->_flags & kFlagsCharacter) diff --git a/engines/parallaction/objects.cpp b/engines/parallaction/objects.cpp index 19b3196167..b821e36a79 100644 --- a/engines/parallaction/objects.cpp +++ b/engines/parallaction/objects.cpp @@ -44,14 +44,12 @@ Command::~Command() {  Animation::Animation() {  	gfxobj = NULL; -	_program = NULL;  	_scriptName = 0;  	_frame = 0;  	_z = 0;  }  Animation::~Animation() { -	delete _program;  	free(_scriptName);  } diff --git a/engines/parallaction/objects.h b/engines/parallaction/objects.h index f841e4be1e..543e8def37 100644 --- a/engines/parallaction/objects.h +++ b/engines/parallaction/objects.h @@ -365,6 +365,8 @@ struct Instruction {  struct Program { +	Animation		*_anim; +  	LocalVariable	*_locals;  	uint16			_loopCounter; @@ -382,12 +384,11 @@ struct Program {  	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; diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index 37981312fb..ac916f8d8b 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -715,6 +715,7 @@ void Parallaction::freeLocation() {  	_gfx->clearGfxObjects();  	freeBackground(); +	_programs.clear();  	freeZones();  	freeAnimations(); diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index 712902d103..6d5f319a29 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -325,7 +325,8 @@ public:  	OpcodeSet	_instructionOpcodes;  	struct { -		Animation	*a; +		Animation	*anim; +		Program		*program;  		InstructionList::iterator inst;  		uint16		modCounter;  		bool		suspend; @@ -404,6 +405,7 @@ public:  	ZoneList		_zones;  	AnimationList	_animations; +	ProgramList		_programs;  	Font		*_labelFont;  	Font		*_menuFont; @@ -787,7 +789,7 @@ protected:  	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); diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp index f9a04a6f41..65fe52b6f3 100644 --- a/engines/parallaction/parallaction_br.cpp +++ b/engines/parallaction/parallaction_br.cpp @@ -208,6 +208,7 @@ void Parallaction_br::changeLocation(char *location) {  	clearSubtitles();  	freeBackground();  	_gfx->clearGfxObjects(); +	_programs.clear();  	freeZones();  	freeAnimations();  //	free(_location._comment); diff --git a/engines/parallaction/parser_br.cpp b/engines/parallaction/parser_br.cpp index 7f53ee2918..b9a7093819 100644 --- a/engines/parallaction/parser_br.cpp +++ b/engines/parallaction/parser_br.cpp @@ -949,7 +949,7 @@ void Parallaction_br::parseLocation(const char* filename) {  	AnimationList::iterator it = _animations.begin();  	for ( ; it != _animations.end(); it++) { -		if (((*it)->_scriptName) && ((*it)->_program == 0)) { +		if ((*it)->_scriptName) {  			loadProgram(*it, (*it)->_scriptName);  		}  	} diff --git a/engines/parallaction/parser_ns.cpp b/engines/parallaction/parser_ns.cpp index bff9107297..b5fdfc3502 100644 --- a/engines/parallaction/parser_ns.cpp +++ b/engines/parallaction/parser_ns.cpp @@ -196,7 +196,7 @@ Animation *Parallaction_ns::parseAnimation(Script& script, AnimationList &list,  	return a;  } -void Parallaction_ns::parseInstruction(Animation *a, LocalVariable *locals) { +void Parallaction_ns::parseInstruction(Program *program) {  	Instruction *inst = new Instruction; @@ -208,15 +208,15 @@ void Parallaction_ns::parseInstruction(Animation *a, LocalVariable *locals) {  		_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 @@ void Parallaction_ns::loadProgram(Animation *a, const char *filename) {  	debugC(1, kDebugParser, "loadProgram(Animation: %s, script: %s)", a->_name, filename);  	Script *script = _disk->loadScript(filename); - -	a->_program = new Program; +	Program *program = new Program; +	program->_anim = a;  	_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 @@ void Parallaction_ns::parseLocation(const char *filename) {  	// 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);  		}  	} | 
