[Scummvm-cvs-logs] SF.net SVN: scummvm:[46983] scummvm/trunk/engines/sci/sfx

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Mon Jan 4 20:39:53 CET 2010


Revision: 46983
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46983&view=rev
Author:   thebluegr
Date:     2010-01-04 19:39:33 +0000 (Mon, 04 Jan 2010)

Log Message:
-----------
Code optimization: removed unneeded string comparisons when executing a sound command (including cmdUpdateCues, which is executed very often)

Modified Paths:
--------------
    scummvm/trunk/engines/sci/sfx/soundcmd.cpp
    scummvm/trunk/engines/sci/sfx/soundcmd.h

Modified: scummvm/trunk/engines/sci/sfx/soundcmd.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/soundcmd.cpp	2010-01-04 18:33:31 UTC (rev 46982)
+++ scummvm/trunk/engines/sci/sfx/soundcmd.cpp	2010-01-04 19:39:33 UTC (rev 46983)
@@ -154,6 +154,7 @@
 		SOUNDCOMMAND(cmdFadeSound);
 		SOUNDCOMMAND(cmdGetPolyphony);
 		SOUNDCOMMAND(cmdStopAllSounds);
+		_cmdUpdateCuesIndex = -1;
 		break;
 	case SCI_VERSION_1_EARLY:
 		SOUNDCOMMAND(cmdMasterVolume);
@@ -171,6 +172,7 @@
 		SOUNDCOMMAND(cmdSendMidi);
 		SOUNDCOMMAND(cmdReverb);
 		SOUNDCOMMAND(cmdSetSoundHold);
+		_cmdUpdateCuesIndex = 11;
 		break;
 	case SCI_VERSION_1_LATE:
 		SOUNDCOMMAND(cmdMasterVolume);
@@ -194,6 +196,7 @@
 		SOUNDCOMMAND(cmdSendMidi);
 		SOUNDCOMMAND(cmdReverb);
 		SOUNDCOMMAND(cmdUpdateSound);
+		_cmdUpdateCuesIndex = 17;
 		break;
 	default:
 		warning("Sound command parser: unknown sound version %d", _soundVersion);
@@ -212,13 +215,6 @@
 	_argc = argc;
 	_argv = argv;
 
-	// cmdMuteSound and cmdMasterVolume do not operate on an object, but need the number of
-	// arguments passed. We load this in the value
-	if (!strcmp(_soundCommands[command]->desc, "cmdMuteSound") ||
-		!strcmp(_soundCommands[command]->desc, "cmdMasterVolume")) {
-		value = argc - 1;	// minus the command
-	}
-
 	if (argc == 6) {	// cmdSendMidi
 		byte channel = argv[2].toUint16() & 0xf;
 		byte midiCmd = argv[3].toUint16() & 0xff;
@@ -230,7 +226,7 @@
 	}
 
 	if (command < _soundCommands.size()) {
-		if (strcmp(_soundCommands[command]->desc, "cmdUpdateCues")) {
+		if (command != _cmdUpdateCuesIndex) {
 			//printf("%s, object %04x:%04x\n", _soundCommands[command]->desc, PRINT_REG(obj));	// debug
 			debugC(2, kDebugLevelSound, "%s, object %04x:%04x", _soundCommands[command]->desc, PRINT_REG(obj));
 		}
@@ -600,7 +596,7 @@
 
 void SoundCommandParser::cmdMuteSound(reg_t obj, int16 value) {
 #ifndef USE_OLD_MUSIC_FUNCTIONS
-	if (value > 0)
+	if (_argc > 1)	// the first parameter is the sound command
 		_music->soundSetSoundOn(obj.toUint16());
 	_acc = make_reg(0, _music->soundGetSoundOn());
 #endif
@@ -614,7 +610,7 @@
 	_acc = make_reg(0, _state->sfx_getVolume());
 #else
 	debugC(2, kDebugLevelSound, "cmdMasterVolume: %d", value);
-	if (value > 0)
+	if (_argc > 1)	// the first parameter is the sound command
 		_music->soundSetMasterVolume(obj.toSint16());
 	_acc = make_reg(0, _music->soundGetMasterVolume());
 #endif

Modified: scummvm/trunk/engines/sci/sfx/soundcmd.h
===================================================================
--- scummvm/trunk/engines/sci/sfx/soundcmd.h	2010-01-04 18:33:31 UTC (rev 46982)
+++ scummvm/trunk/engines/sci/sfx/soundcmd.h	2010-01-04 19:39:33 UTC (rev 46983)
@@ -87,6 +87,7 @@
 	reg_t *_argv;	// for cmdFadeSound
 	uint32 _midiCommand;	// for cmdSendMidi
 	reg_t _acc;
+	int _cmdUpdateCuesIndex;
 
 	void cmdInitSound(reg_t obj, int16 value);
 	void cmdPlaySound(reg_t obj, int16 value);


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