[Scummvm-cvs-logs] SF.net SVN: scummvm:[41716] scummvm/branches/gsoc2009-mods

nolange at users.sourceforge.net nolange at users.sourceforge.net
Sat Jun 20 23:04:57 CEST 2009


Revision: 41716
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41716&view=rev
Author:   nolange
Date:     2009-06-20 21:04:57 +0000 (Sat, 20 Jun 2009)

Log Message:
-----------
fixed portamento-effect.
Added stopping of sfx, seems like Monkey Island is pretty messy when it comes to handling sfx though.
Those two changes fix the "mansion burglary"

Modified Paths:
--------------
    scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.h
    scummvm/branches/gsoc2009-mods/sound/mods/tfmx.cpp
    scummvm/branches/gsoc2009-mods/sound/mods/tfmx.h

Modified: scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.cpp	2009-06-20 16:36:26 UTC (rev 41715)
+++ scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.cpp	2009-06-20 21:04:57 UTC (rev 41716)
@@ -33,7 +33,7 @@
 namespace Scumm {
 
 Player_V4A::Player_V4A(ScummEngine *scumm, Audio::Mixer *mixer)
-	: _vm(scumm), _mixer(mixer), _musicId(), _tfmxPlay(0), _tfmxSfx(0), _musicHandle(), _sfxHandle() {
+	: _vm(scumm), _mixer(mixer), _musicId(), _sfxSlots(), _tfmxPlay(0), _tfmxSfx(0), _musicHandle(), _sfxHandle() {
 	init();
 }
 
@@ -72,21 +72,31 @@
 }
 
 void Player_V4A::setMusicVolume(int vol) {
-	debug("player_v4a: setMusicVolume %i", vol);
+	debug(5, "player_v4a: setMusicVolume %i", vol);
 }
 
 void Player_V4A::stopAllSounds() {
-	if (_musicId)
-		stopSound(_musicId);
+	debug(5, "player_v4a: stopAllSounds");
+	if (_tfmxPlay)
+		_tfmxPlay->stopSong();
+	_musicId = 0;
+	if (_tfmxSfx)
+		_tfmxSfx->stopSong();
+	clearSfxSlots();
 }
 
 void Player_V4A::stopSound(int nr) {
+	debug(5, "player_v4a: stopSound %d", nr);
 	if (nr == _musicId) {
 		_tfmxPlay->stopSong();
-		//_mixer->stopHandle(_musicHandle);
 		_musicId = 0;
-	} else
-		warning("player_v4a: stop Sound %d", nr);
+	} else {
+		const int chan = getSfxChan(nr);
+		if (chan != -1) {
+			setSfxSlot(chan, 0);
+			_tfmxSfx->stopMacroEffect(chan);
+		}
+	}
 }
 
 void Player_V4A::startSound(int nr) {
@@ -106,7 +116,7 @@
 
 	const int val = ptr[9];
 	if (val < 0 || val >= ARRAYSIZE(monkeyCommands)) {
-		debug(3, "Tfmx: illegal Songnumber %i", val);
+		warning("player_v4a: illegal Songnumber %i", val);
 		return;
 	}
 
@@ -114,21 +124,27 @@
 		return;
 
 	int index = monkeyCommands[val];
+	const byte type = ptr[6];
 	if (index < 0) {
 		// SoundFX
 		index = -index - 1;
-		debug(5, "player_v4a: play custom %i", index);
+		debug(3, "player_v4a: play %d: custom %i - %02X", nr, index, type);
 
 		if (_tfmxSfx->getSongIndex() < 0)
 			_tfmxSfx->doSong(0x18);
-		_tfmxSfx->doSfx(index);
+		const int chan = _tfmxSfx->doSfx(index);
+		if (chan >= 0 && chan < ARRAYSIZE(_sfxSlots))
+			setSfxSlot(chan, nr, type);
+		else
+			warning("player_v4a: custom %i is not of required type", index);
 
 		if (!_mixer->isSoundHandleActive(_sfxHandle))
 			_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, _tfmxSfx, -1, Audio::Mixer::kMaxChannelVolume, 0, false, true);
 	} else {
 		// Song
-		debug(5, "player_v4a: play song %i", index);
-		assert(_tfmxPlay);
+		debug(3, "player_v4a: play %d: song %i - %02X", nr, index, type);
+		if (ptr[6] != 0x7F)
+			warning("player_v4a: Song has wrong type");
 
 		_tfmxPlay->doSong(index);
 		_musicId = nr;

Modified: scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.h
===================================================================
--- scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.h	2009-06-20 16:36:26 UTC (rev 41715)
+++ scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.h	2009-06-20 21:04:57 UTC (rev 41716)
@@ -62,7 +62,31 @@
 	Audio::SoundHandle _sfxHandle;
 
 	int _musicId;
+	
+	struct SfxChan {
+		int id;
+		byte type;
+	} _sfxSlots[4];
 
+	int getSfxChan(int id) const {
+		for (int i = 0; i < ARRAYSIZE(_sfxSlots); ++i)
+			if (_sfxSlots[i].id == id)
+				return i;
+		return -1;
+	}
+
+	void setSfxSlot(int channel, int id, byte type = 0) {
+		_sfxSlots[channel].id = id;
+		_sfxSlots[channel].type = type;
+	}
+
+	void clearSfxSlots() {
+		for (int i = 0; i < ARRAYSIZE(_sfxSlots); ++i){
+			_sfxSlots[i].id = 0;
+			_sfxSlots[i].type = 0;
+		}
+	}
+
 	bool init();
 };
 

Modified: scummvm/branches/gsoc2009-mods/sound/mods/tfmx.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/sound/mods/tfmx.cpp	2009-06-20 16:36:26 UTC (rev 41715)
+++ scummvm/branches/gsoc2009-mods/sound/mods/tfmx.cpp	2009-06-20 21:04:57 UTC (rev 41716)
@@ -139,19 +139,19 @@
 	}
 
 	// portamento
-	if (channel.portaDelta && !(--channel.portaCount)) {
+	if (channel.portaDelta && --channel.portaCount == 0) {
 		channel.portaCount = channel.portaSkip;
 
 		bool resetPorta = true;
-		uint16 period = channel.refPeriod;
-		const uint16 portaVal = channel.portaValue;
+		uint16 period = channel.refPeriod; // d1
+		uint16 portaVal = channel.portaValue; // d0
 
 		if (period > portaVal) {
-			period = ((uint32)period * (uint16)((1 << 8) - channel.portaDelta)) >> 8;
+			portaVal = ((uint32)portaVal * (uint16)((1 << 8) + channel.portaDelta)) >> 8;
 			resetPorta = (period <= portaVal);
 
 		} else if (period < portaVal) {
-			period = ((uint32)period * (uint16)((1 << 8) + channel.portaDelta)) >> 8;
+			portaVal = ((uint32)portaVal * (uint16)((1 << 8) - channel.portaDelta)) >> 8;
 			resetPorta = (period >= portaVal);
 		}
 
@@ -159,7 +159,7 @@
 			channel.portaDelta = 0;
 			channel.portaValue = channel.refPeriod & 0x7FF;
 		} else {
-			channel.period = period & 0x7FF;
+			channel.period = channel.portaValue = portaVal & 0x7FF;
 			//Paula::setChannelPeriod(channel.paulaChannel, channel.period);
 		}
 	}
@@ -903,8 +903,10 @@
 void Tfmx::stopSong(bool stopAudio) {
 	Common::StackLock lock(_mutex);
 	_playerCtx.song = -1;
-	if (stopAudio)
+	if (stopAudio) {
 		stopMacroChannels();
+		stopPaula();
+	}
 }
 
 void Tfmx::doSong(int songPos, bool stopAudio) {
@@ -912,8 +914,10 @@
 	Common::StackLock lock(_mutex);
 
 	stopPatternChannels();
-	if (stopAudio)
+	if (stopAudio) {
 		stopMacroChannels();
+		stopPaula();
+	}
 
 	_playerCtx.song = (int8)songPos;
 
@@ -939,7 +943,7 @@
 	startPaula();
 }
 
-void Tfmx::doSfx(int sfxIndex) {
+int Tfmx::doSfx(int sfxIndex, bool unlockChannel) {
 	assert(0 <= sfxIndex && sfxIndex < 128);
 	Common::StackLock lock(_mutex);
 
@@ -955,15 +959,21 @@
 		const byte priority = sfxEntry[5] & 0x7F;
 
 		ChannelContext &channel = _channelCtx[channelNo];
+		if (unlockChannel)
+			unlockMacroChannel(channel);
+
 		const int16 sfxLocktime = channel.sfxLockTime;
 		if (priority >= channel.customMacroPrio || sfxLocktime < 0) {
 			if (sfxIndex != channel.customMacroIndex || sfxLocktime < 0 || (sfxEntry[5] < 0x80)) {
 				channel.customMacro = READ_UINT32(sfxEntry); // intentionally not "endian-correct"
 				channel.customMacroPrio = priority;
 				channel.customMacroIndex = (uint8)sfxIndex;
+				debug(3, "Tfmx: running Macro %08X on channel %i - priority: %02X", TO_BE_32(channel.customMacro), channelNo, priority);
+				return channelNo;
 			}
 		}
 	}
+	return -1;
 }
 
 }

Modified: scummvm/branches/gsoc2009-mods/sound/mods/tfmx.h
===================================================================
--- scummvm/branches/gsoc2009-mods/sound/mods/tfmx.h	2009-06-20 16:36:26 UTC (rev 41715)
+++ scummvm/branches/gsoc2009-mods/sound/mods/tfmx.h	2009-06-20 21:04:57 UTC (rev 41716)
@@ -48,12 +48,19 @@
 	void interrupt();
 	void stopSong(bool stopAudio = true);
 	void doSong(int songPos, bool stopAudio = false);
-	void doSfx(int sfxIndex);
+	int doSfx(int sfxIndex, bool unlockChannel = false);
 	void doMacro(int note, int macro, int relVol = 0, int finetune = 0, int channelNo = 0);
 	bool load(Common::SeekableReadStream &musicData, Common::SeekableReadStream &sampleData);
 	int getTicks() {return _playerCtx.tickCount;}
 	int getSongIndex() {return _playerCtx.song;}
-	uint16 getSignal(int index) {return _playerCtx.signal[index];}
+	uint16 getSignal(int index) {return (index < ARRAYSIZE(_playerCtx.signal)) ? _playerCtx.signal[index] : 0xFFFF;}
+	void stopMacroEffect(int channel) {
+		assert(0 <= channel && channel < kNumVoices);
+		Common::StackLock lock(_mutex);
+		unlockMacroChannel(_channelCtx[channel]);
+		clearMacroProgramm(_channelCtx[channel]);
+		Paula::disableChannel(_channelCtx[channel].paulaChannel);
+	}
 
 // Note: everythings public so the debug-Routines work.
 // private:
@@ -270,7 +277,7 @@
 		channel.refPeriod = ((uint32)noteInt * finetune >> 8);
 		if (!channel.portaDelta) {
 			channel.period = channel.refPeriod;
-			Paula::setChannelPeriod(channel.paulaChannel, channel.period);
+			//Paula::setChannelPeriod(channel.paulaChannel, channel.period);
 		}
 	}
 


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