[Scummvm-cvs-logs] SF.net SVN: scummvm: [21396] scummvm/trunk/engines/kyra

eriktorbjorn at users.sourceforge.net eriktorbjorn at users.sourceforge.net
Tue Mar 21 09:18:11 CET 2006


Revision: 21396
Author:   eriktorbjorn
Date:     2006-03-21 09:17:24 -0800 (Tue, 21 Mar 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=21396&view=rev

Log Message:
-----------
Implemented "sound triggers" so that the music does not stop shortly after
entering the castle. I hope this is a fair approximation of how the original
worked. Of course, this led to a couple of more renamings:

_unk5              -> _soundTrigger
updateCallback54() -> update_setSoundTrigger()
snd_setUnk5()      -> snd_getSoundTrigger()      (yes, "get")

At the moment, the only known sound triggers are the ones in the castle. If an
unknown trigger is set, the debugging messages will be really, really noisy. I
don't know if I should consider this a bug or an extremely annoying feature.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/kyra.cpp
    scummvm/trunk/engines/kyra/sound.h
    scummvm/trunk/engines/kyra/sound_adlib.cpp
Modified: scummvm/trunk/engines/kyra/kyra.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra.cpp	2006-03-21 13:48:51 UTC (rev 21395)
+++ scummvm/trunk/engines/kyra/kyra.cpp	2006-03-21 17:17:24 UTC (rev 21396)
@@ -711,6 +711,8 @@
 		_handleInput = true;
 		delay((frameTime + _gameSpeed) - _system->getMillis(), true, true);
 		_handleInput = false;
+
+		_sound->process();
 	}
 }
 

Modified: scummvm/trunk/engines/kyra/sound.h
===================================================================
--- scummvm/trunk/engines/kyra/sound.h	2006-03-21 13:48:51 UTC (rev 21395)
+++ scummvm/trunk/engines/kyra/sound.h	2006-03-21 17:17:24 UTC (rev 21396)
@@ -45,19 +45,20 @@
 	virtual ~Sound();
 
 	virtual bool init() = 0;
-	
+	virtual void process() {}
+
 	virtual void setVolume(int volume) = 0;
 	virtual int getVolume() = 0;
-	
+
 	virtual void loadMusicFile(const char *file) = 0;
-	
+
 	virtual void playTrack(uint8 track) = 0;
 	virtual void haltTrack() = 0;
-	
+
 	virtual void playSoundEffect(uint8 track) = 0;
-	
+
 	virtual void beginFadeOut() = 0;
-	
+
 	void voicePlay(const char *file);
 	void voiceUnload() {}
 	bool voiceIsPlaying();
@@ -70,12 +71,12 @@
 	AudioStream *_currentVocFile;
 	Audio::SoundHandle _vocHandle;
 	Common::File _compressHandle;
-	
+
 	struct SpeechCodecs {
 		const char *fileext;
 		AudioStream *(*streamFunc)(Common::File*, uint32);
 	};
-	
+
 	static const SpeechCodecs _supportedCodes[];
 };
 
@@ -87,6 +88,7 @@
 	~SoundAdlibPC();
 
 	bool init();
+	void process();
 
 	void setVolume(int volume);
 	int getVolume();
@@ -114,11 +116,16 @@
 
 	uint8 _sfxPriority;
 	uint8 _sfxFourthByteOfSong;
+
+	int _numSoundTriggers;
+	const int *_soundTriggers;
+
+	static const int _kyra1NumSoundTriggers;
+	static const int _kyra1SoundTriggers[];
 };
 
 class SoundMidiPC : public MidiDriver, public Sound {
 public:
-
 	SoundMidiPC(MidiDriver *driver, Audio::Mixer *mixer, KyraEngine *engine);
 	~SoundMidiPC();
 
@@ -128,10 +135,10 @@
 	int getVolume() { return _volume; }
 
 	void loadMusicFile(const char *file);
-	
+
 	void playTrack(uint8 track);
 	void haltTrack();
-	
+
 	void playSoundEffect(uint8 track);
 
 	void beginFadeOut();
@@ -148,9 +155,9 @@
 	//Channel allocation functions
 	MidiChannel *allocateChannel()		{ return 0; }
 	MidiChannel *getPercussionChannel()	{ return 0; }
-	
+
 	void setPassThrough(bool b)	{ _passThrough = b; }
-	
+
 	void hasNativeMT32(bool nativeMT32) { _nativeMT32 = nativeMT32; }
 	bool isMT32() { return _nativeMT32; }
 
@@ -159,7 +166,7 @@
 	void stopMusic();
 	void loadSoundEffectFile(const char *file);
 	void loadSoundEffectFile(uint8 *data, uint32 size);
-	
+
 	void stopSoundEffect();
 
 	static void onTimer(void *data);

Modified: scummvm/trunk/engines/kyra/sound_adlib.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_adlib.cpp	2006-03-21 13:48:51 UTC (rev 21395)
+++ scummvm/trunk/engines/kyra/sound_adlib.cpp	2006-03-21 17:17:24 UTC (rev 21396)
@@ -95,7 +95,7 @@
 	int snd_unkOpcode3(va_list &list);
 	int snd_readByte(va_list &list);
 	int snd_writeByte(va_list &list);
-	int snd_setUnk5(va_list &list);
+	int snd_getSoundTrigger(va_list &list);
 	int snd_unkOpcode4(va_list &list);
 	int snd_dummy(va_list &list);
 	int snd_getNullvar4(va_list &list);
@@ -106,7 +106,6 @@
 	// These variables have not yet been named, but some of them are partly
 	// known nevertheless:
 	//
-	// unk4  - Unknown. Related to sound timing?
 	// unk11 - Unknown. Used for updating random durations.
 	// unk16 - Sound-related. Possibly some sort of pitch bend.
 	// unk18 - Sound-effect. Used for secondaryEffect1()
@@ -286,14 +285,13 @@
 	int updateCallback51(uint8 *&dataptr, Channel &channel, uint8 value);
 	int updateCallback52(uint8 *&dataptr, Channel &channel, uint8 value);
 	int updateCallback53(uint8 *&dataptr, Channel &channel, uint8 value);
-	int updateCallback54(uint8 *&dataptr, Channel &channel, uint8 value);
+	int update_setSoundTrigger(uint8 *&dataptr, Channel &channel, uint8 value);
 	int update_setTempoReset(uint8 *&dataptr, Channel &channel, uint8 value);
 	int updateCallback56(uint8 *&dataptr, Channel &channel, uint8 value);
 private:
 	// These variables have not yet been named, but some of them are partly
 	// known nevertheless:
 	//
-	// _unk5           - Currently unused, except for updateCallback54()
 	// _unkValue1      - Unknown. Used for updating _unkValue2
 	// _unkValue2      - Unknown. Used for updating _unkValue4
 	// _unkValue3      - Unknown. Used for updating _unkValue2
@@ -330,7 +328,7 @@
 	int8 _flagTrigger;
 	int _curChannel;
 	uint8 _rhythmSection;
-	uint8 _unk5;
+	uint8 _soundTrigger;
 	int _soundsPlaying;
 
 	uint16 _rnd;
@@ -402,6 +400,7 @@
 	_rnd = 0x1234;
 
 	_tempo = 0;
+	_soundTrigger = 0;
 
 	_unkValue3 = 0xFF;
 	_unkValue1 = _unkValue2 = _unkValue4 = _unkValue5 = 0;
@@ -495,8 +494,7 @@
 		}
 	}
 
-	_soundIdTable[_soundsPlaying] = songId;
-	++_soundsPlaying;
+	_soundIdTable[_soundsPlaying++] = songId;
 	_soundsPlaying &= 0x0F;
 
 	return 0;
@@ -548,9 +546,8 @@
 	return oldValue;
 }
 
-int AdlibDriver::snd_setUnk5(va_list &list) {
-	warning("unimplemented snd_setUnk5");
-	return 0;
+int AdlibDriver::snd_getSoundTrigger(va_list &list) {
+	return _soundTrigger;
 }
 
 int AdlibDriver::snd_unkOpcode4(va_list &list) {
@@ -1793,8 +1790,8 @@
 	return 0;
 }
 
-int AdlibDriver::updateCallback54(uint8 *&dataptr, Channel &channel, uint8 value) {
-	_unk5 = value;
+int AdlibDriver::update_setSoundTrigger(uint8 *&dataptr, Channel &channel, uint8 value) {
+	_soundTrigger = value;
 	return 0;
 }
 
@@ -1824,7 +1821,7 @@
 	COMMAND(snd_unkOpcode3),
 	COMMAND(snd_readByte),
 	COMMAND(snd_writeByte),
-	COMMAND(snd_setUnk5),
+	COMMAND(snd_getSoundTrigger),
 	COMMAND(snd_unkOpcode4),
 	COMMAND(snd_dummy),
 	COMMAND(snd_getNullvar4),
@@ -1940,7 +1937,7 @@
 	COMMAND(updateCallback51),
 	COMMAND(updateCallback52),
 	COMMAND(updateCallback53),
-	COMMAND(updateCallback54),
+	COMMAND(update_setSoundTrigger),
 
 	// 72
 	COMMAND(update_setTempoReset),
@@ -2123,6 +2120,15 @@
 
 #pragma mark -
 
+// At the time of writing, the only known case where Kyra 1 uses sound triggers
+// is in the castle, to cycle between three different songs.
+
+const int SoundAdlibPC::_kyra1SoundTriggers[] = {
+	0, 4, 5, 3
+};
+
+const int SoundAdlibPC::_kyra1NumSoundTriggers = ARRAYSIZE(SoundAdlibPC::_kyra1SoundTriggers);
+
 SoundAdlibPC::SoundAdlibPC(Audio::Mixer *mixer, KyraEngine *engine)
 	: Sound(engine, mixer), _driver(0), _trackEntries(), _soundDataPtr(0) {
 	memset(_trackEntries, 0, sizeof(_trackEntries));
@@ -2131,6 +2137,9 @@
 
 	_sfxPlayingSound = -1;
 	_soundFileLoaded = "";
+
+	_soundTriggers = _kyra1SoundTriggers;
+	_numSoundTriggers = _kyra1NumSoundTriggers;
 }
 
 SoundAdlibPC::~SoundAdlibPC() {
@@ -2144,6 +2153,21 @@
 	return true;
 }
 
+void SoundAdlibPC::process() {
+	uint8 trigger = _driver->callback(11);
+
+	if (trigger < _numSoundTriggers) {
+		int soundId = _soundTriggers[trigger];
+
+		if (soundId) {
+			playTrack(soundId);
+		}
+	} else {
+		warning("Unknown sound trigger %d", trigger);
+		// TODO: At this point, we really want to clear the trigger...
+	}
+}
+
 void SoundAdlibPC::setVolume(int volume) {
 }
 


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