diff options
| author | Bastien Bouclet | 2010-11-29 21:00:05 +0000 | 
|---|---|---|
| committer | Bastien Bouclet | 2010-11-29 21:00:05 +0000 | 
| commit | 149eed5c3296175d122cc7f44db75fe352fae004 (patch) | |
| tree | fe5f628faf18476f2f8d0beae877ab213b389856 | |
| parent | bfd272a46ebae1198a489d113d0f50b9418ac202 (diff) | |
| download | scummvm-rg350-149eed5c3296175d122cc7f44db75fe352fae004.tar.gz scummvm-rg350-149eed5c3296175d122cc7f44db75fe352fae004.tar.bz2 scummvm-rg350-149eed5c3296175d122cc7f44db75fe352fae004.zip | |
MOHAWK: Persistent scripts cleanup
- Rename InitOpcodes / PersistentOpcodes to Persistent Scripts for consistency
- Get rid of the global var used to tell if the sound receiver script is running
svn-id: r54633
| -rw-r--r-- | engines/mohawk/console.cpp | 2 | ||||
| -rw-r--r-- | engines/mohawk/myst.cpp | 4 | ||||
| -rw-r--r-- | engines/mohawk/myst_scripts.h | 4 | ||||
| -rw-r--r-- | engines/mohawk/myst_scripts_myst.cpp | 4 | ||||
| -rw-r--r-- | engines/mohawk/myst_scripts_myst.h | 4 | ||||
| -rw-r--r-- | engines/mohawk/myst_scripts_selenitic.cpp | 56 | ||||
| -rw-r--r-- | engines/mohawk/myst_scripts_selenitic.h | 10 | 
7 files changed, 38 insertions, 46 deletions
| diff --git a/engines/mohawk/console.cpp b/engines/mohawk/console.cpp index e6eab0b495..b81d9c4c0e 100644 --- a/engines/mohawk/console.cpp +++ b/engines/mohawk/console.cpp @@ -267,7 +267,7 @@ bool MystConsole::Cmd_DisableInitOpcodes(int argc, const char **argv) {  		return true;  	} -	_vm->_scriptParser->disableInitOpcodes(); +	_vm->_scriptParser->disablePersistentScripts();  	return true;  } diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp index 275f3bf3f3..21774e7967 100644 --- a/engines/mohawk/myst.cpp +++ b/engines/mohawk/myst.cpp @@ -285,7 +285,7 @@ Common::Error MohawkEngine_Myst::run() {  	while (!shouldQuit()) {  		// Update any background videos  		_needsUpdate = _video->updateBackgroundMovies(); -		_scriptParser->runPersistentOpcodes(); +		_scriptParser->runPersistentScripts();  		// Run animations...  		for (uint16 i = 0; i < _resources.size(); i++) @@ -419,7 +419,7 @@ void MohawkEngine_Myst::drawCardBackground() {  void MohawkEngine_Myst::changeToCard(uint16 card, bool updateScreen) {  	debug(2, "changeToCard(%d)", card); -	_scriptParser->disableInitOpcodes(); +	_scriptParser->disablePersistentScripts();  	_video->stopVideos(); diff --git a/engines/mohawk/myst_scripts.h b/engines/mohawk/myst_scripts.h index c0d2ce6a70..0a741cec11 100644 --- a/engines/mohawk/myst_scripts.h +++ b/engines/mohawk/myst_scripts.h @@ -69,8 +69,8 @@ public:  	const char *getOpcodeDesc(uint16 op);  	MystScript readScript(Common::SeekableReadStream *stream, MystScriptType type); -	virtual void disableInitOpcodes() = 0; -	virtual void runPersistentOpcodes() = 0; +	virtual void disablePersistentScripts() = 0; +	virtual void runPersistentScripts() = 0;  	virtual uint16 getVar(uint16 var);  	virtual void toggleVar(uint16 var); diff --git a/engines/mohawk/myst_scripts_myst.cpp b/engines/mohawk/myst_scripts_myst.cpp index 3020d26d15..1b3d4c9c0f 100644 --- a/engines/mohawk/myst_scripts_myst.cpp +++ b/engines/mohawk/myst_scripts_myst.cpp @@ -204,7 +204,7 @@ void MystScriptParser_Myst::setupOpcodes() {  	_opcodeCount = ARRAYSIZE(myst_opcodes);  } -void MystScriptParser_Myst::disableInitOpcodes() { +void MystScriptParser_Myst::disablePersistentScripts() {  	opcode_200_disable();  	opcode_201_disable();  	opcode_202_disable(); @@ -218,7 +218,7 @@ void MystScriptParser_Myst::disableInitOpcodes() {  	opcode_212_disable();  } -void MystScriptParser_Myst::runPersistentOpcodes() { +void MystScriptParser_Myst::runPersistentScripts() {  	opcode_200_run();  	opcode_201_run();  	opcode_202_run(); diff --git a/engines/mohawk/myst_scripts_myst.h b/engines/mohawk/myst_scripts_myst.h index c35e40b143..3702e94954 100644 --- a/engines/mohawk/myst_scripts_myst.h +++ b/engines/mohawk/myst_scripts_myst.h @@ -42,8 +42,8 @@ public:  	MystScriptParser_Myst(MohawkEngine_Myst *vm);  	~MystScriptParser_Myst(); -	void disableInitOpcodes(); -	void runPersistentOpcodes(); +	void disablePersistentScripts(); +	void runPersistentScripts();  private:  	void setupOpcodes(); diff --git a/engines/mohawk/myst_scripts_selenitic.cpp b/engines/mohawk/myst_scripts_selenitic.cpp index 9e765b17bb..2eb79c20a2 100644 --- a/engines/mohawk/myst_scripts_selenitic.cpp +++ b/engines/mohawk/myst_scripts_selenitic.cpp @@ -138,12 +138,13 @@ void MystScriptParser_Selenitic::setupOpcodes() {  	_opcodeCount = ARRAYSIZE(myst_opcodes);  } -void MystScriptParser_Selenitic::disableInitOpcodes() { -	o_203_soundReceiver_disable(); +void MystScriptParser_Selenitic::disablePersistentScripts() { +	_sound_receiver_running = false;  } -void MystScriptParser_Selenitic::runPersistentOpcodes() { -	o_203_soundReceiver_run(); +void MystScriptParser_Selenitic::runPersistentScripts() { +	if (_sound_receiver_running) +		o_203_soundReceiver_run();  }  uint16 MystScriptParser_Selenitic::getVar(uint16 var) { @@ -815,33 +816,27 @@ void MystScriptParser_Selenitic::opcode_202(uint16 op, uint16 var, uint16 argc,  		unknown(op, var, argc, argv);  } -static struct { -	bool enabled; -} g_opcode203Parameters; -  void MystScriptParser_Selenitic::o_203_soundReceiver_run(void) { -	if (g_opcode203Parameters.enabled) { -		if (_sound_receiver_start_time) { -			if (_sound_receiver_direction) { -				uint32 current_time = _vm->_system->getMillis(); - -				if (_sound_receiver_speed == 50) { -					if (current_time > _sound_receiver_start_time + 500) { -						sound_receiver_increase_speed(); -					} -				} else { -					if (current_time > _sound_receiver_start_time + 1000) { -						sound_receiver_increase_speed(); -					} -				} +	if (_sound_receiver_start_time) { +		if (_sound_receiver_direction) { +			uint32 current_time = _vm->_system->getMillis(); -				if (current_time > _sound_receiver_start_time + 100) { -					sound_receiver_update(); +			if (_sound_receiver_speed == 50) { +				if (current_time > _sound_receiver_start_time + 500) { +					sound_receiver_increase_speed(); +				} +			} else { +				if (current_time > _sound_receiver_start_time + 1000) { +					sound_receiver_increase_speed();  				} +			} -			} else if (!_sound_receiver_sigma_pressed) { -				sound_receiver_update_sound(); +			if (current_time > _sound_receiver_start_time + 100) { +				sound_receiver_update();  			} + +		} else if (!_sound_receiver_sigma_pressed) { +			sound_receiver_update_sound();  		}  	}  } @@ -943,16 +938,13 @@ void MystScriptParser_Selenitic::sound_receiver_solution(uint16 source, uint16 &  	}  } -void MystScriptParser_Selenitic::o_203_soundReceiver_disable(void) { -	g_opcode203Parameters.enabled = false; -} -  void MystScriptParser_Selenitic::o_203_soundReceiver_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +	uint16 *selenitic_vars = _vm->_saveLoad->_v->selenitic_vars; +  	debugC(kDebugScript, "Opcode %d: Sound receiver init", op);  	// Used for Card 1245 (Sound Receiver) -	g_opcode203Parameters.enabled = true; -	uint16 *selenitic_vars = _vm->_saveLoad->_v->selenitic_vars; +	_sound_receiver_running = true;  	_sound_receiver_right_button = static_cast<MystResourceType8 *>(_vm->_resources[0]);  	_sound_receiver_left_button = static_cast<MystResourceType8 *>(_vm->_resources[1]); diff --git a/engines/mohawk/myst_scripts_selenitic.h b/engines/mohawk/myst_scripts_selenitic.h index 05c0233d45..21ae923638 100644 --- a/engines/mohawk/myst_scripts_selenitic.h +++ b/engines/mohawk/myst_scripts_selenitic.h @@ -43,8 +43,8 @@ public:  	MystScriptParser_Selenitic(MohawkEngine_Myst *vm);  	~MystScriptParser_Selenitic(); -	void disableInitOpcodes(); -	void runPersistentOpcodes(); +	void disablePersistentScripts(); +	void runPersistentScripts();  private:  	void setupOpcodes(); @@ -52,9 +52,6 @@ private:  	void toggleVar(uint16 var);  	bool setVarValue(uint16 var, uint16 value); -	void o_203_soundReceiver_run(); -	void o_203_soundReceiver_disable(); -  	DECLARE_OPCODE(opcode_100);  	DECLARE_OPCODE(opcode_101);  	DECLARE_OPCODE(o_102_soundReceiverSigma); @@ -77,6 +74,9 @@ private:  	DECLARE_OPCODE(opcode_205);  	DECLARE_OPCODE(opcode_206); +	void o_203_soundReceiver_run(); + +	bool _sound_receiver_running;  	bool _sound_receiver_sigma_pressed; // 6  	MystResourceType8 *_sound_receiver_sources[5]; // 92 -> 108  	MystResourceType8 *_sound_receiver_current_source; // 112 | 
