[Scummvm-cvs-logs] SF.net SVN: scummvm: [25585] scummvm/trunk/engines/gob

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Wed Feb 14 17:36:18 CET 2007


Revision: 25585
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25585&view=rev
Author:   drmccoy
Date:     2007-02-14 08:36:17 -0800 (Wed, 14 Feb 2007)

Log Message:
-----------
- Changed the square wave generator / speaker emulation, hopefully fixing the walking sound issue (#1621086)
- Fixed some misplaced actor glitches in Bargon

Modified Paths:
--------------
    scummvm/trunk/engines/gob/goblin.cpp
    scummvm/trunk/engines/gob/goblin_v2.cpp
    scummvm/trunk/engines/gob/inter_v1.cpp
    scummvm/trunk/engines/gob/inter_v2.cpp
    scummvm/trunk/engines/gob/sound.cpp
    scummvm/trunk/engines/gob/sound.h

Modified: scummvm/trunk/engines/gob/goblin.cpp
===================================================================
--- scummvm/trunk/engines/gob/goblin.cpp	2007-02-14 09:52:21 UTC (rev 25584)
+++ scummvm/trunk/engines/gob/goblin.cpp	2007-02-14 16:36:17 UTC (rev 25585)
@@ -1925,7 +1925,7 @@
 			mouseX = _vm->_global->_inter_mouseX;
 			mouseY = _vm->_global->_inter_mouseY;
 			if (_vm->_map->_bigTiles)
-				mouseY += ((_vm->_global->_inter_mouseX / _vm->_map->_tilesHeight) + 1) / 2;
+				mouseY += ((_vm->_global->_inter_mouseY / _vm->_map->_tilesHeight) + 1) / 2;
 			obj->gobDestX = mouseX / _vm->_map->_tilesWidth;
 			obj->gobDestY = mouseY / _vm->_map->_tilesHeight;
 			gobDestX = obj->gobDestX;

Modified: scummvm/trunk/engines/gob/goblin_v2.cpp
===================================================================
--- scummvm/trunk/engines/gob/goblin_v2.cpp	2007-02-14 09:52:21 UTC (rev 25584)
+++ scummvm/trunk/engines/gob/goblin_v2.cpp	2007-02-14 16:36:17 UTC (rev 25585)
@@ -83,8 +83,8 @@
 			*obj->pPosY = (y + 1) * _vm->_map->_tilesHeight
 				- (_vm->_scenery->_animBottom - _vm->_scenery->_animTop);
 		else
-			*obj->pPosY = ((y + 1) / 2) * _vm->_map->_tilesHeight
-				- (_vm->_scenery->_animBottom - _vm->_scenery->_animTop);
+			*obj->pPosY = ((y + 1) * _vm->_map->_tilesHeight) -
+				(_vm->_scenery->_animBottom - _vm->_scenery->_animTop) - (y + 1) / 2;
 		*obj->pPosX = x * _vm->_map->_tilesWidth;
 	} else {
 		if (obj->goblinStates[state] != 0) {
@@ -102,8 +102,8 @@
 				*obj->pPosY = (y + 1) * _vm->_map->_tilesHeight
 					- (_vm->_scenery->_animBottom - _vm->_scenery->_animTop);
 			else
-				*obj->pPosY = ((y + 1) / 2) * _vm->_map->_tilesHeight
-					- (_vm->_scenery->_animBottom - _vm->_scenery->_animTop);
+				*obj->pPosY = ((y + 1) * _vm->_map->_tilesHeight) -
+					(_vm->_scenery->_animBottom - _vm->_scenery->_animTop) - (y + 1) / 2;
 			*obj->pPosX = x * _vm->_map->_tilesWidth;
 			initiateMove(obj);
 		} else

Modified: scummvm/trunk/engines/gob/inter_v1.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v1.cpp	2007-02-14 09:52:21 UTC (rev 25584)
+++ scummvm/trunk/engines/gob/inter_v1.cpp	2007-02-14 16:36:17 UTC (rev 25585)
@@ -1468,7 +1468,7 @@
 		if (flag != 1) {
 			if (flag != 2) {
 				if (flag < 20) {
-					_vm->_util->delay(flag);
+					_vm->_util->delay(flag * 2);
 					_noBusyWait = true;
 				}
 				else

Modified: scummvm/trunk/engines/gob/inter_v2.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v2.cpp	2007-02-14 09:52:21 UTC (rev 25584)
+++ scummvm/trunk/engines/gob/inter_v2.cpp	2007-02-14 16:36:17 UTC (rev 25585)
@@ -1138,7 +1138,7 @@
 			mouseX = _vm->_global->_inter_mouseX;
 			mouseY = _vm->_global->_inter_mouseY;
 			if (_vm->_map->_bigTiles)
-				mouseY += ((_vm->_global->_inter_mouseX / _vm->_map->_tilesHeight) + 1) / 2;
+				mouseY += ((_vm->_global->_inter_mouseY / _vm->_map->_tilesHeight) + 1) / 2;
 			obj->gobDestX = mouseX / _vm->_map->_tilesWidth;
 			obj->gobDestY = mouseY / _vm->_map->_tilesHeight;
 			gobDestX = obj->gobDestX;
@@ -1296,13 +1296,13 @@
 			objAnim->layer = obj->goblinStates[objAnim->state][0].layer;
 			objAnim->animation = animation;
 			_vm->_scenery->updateAnim(layer, 0, animation, 0, *obj->pPosX, *obj->pPosY, 0);
-			if (!_vm->_map->_bigTiles) {
+			if (!_vm->_map->_bigTiles)
 				*obj->pPosY = (obj->goblinY + 1) * _vm->_map->_tilesHeight
 					- (_vm->_scenery->_animBottom - _vm->_scenery->_animTop);
-			} else {
-				*obj->pPosY = ((obj->goblinY + 1) / 2) * _vm->_map->_tilesHeight
-					- (_vm->_scenery->_animBottom - _vm->_scenery->_animTop);
-			}
+			else
+				*obj->pPosY = ((obj->goblinY + 1) * _vm->_map->_tilesHeight) -
+					(_vm->_scenery->_animBottom - _vm->_scenery->_animTop) -
+					((obj->goblinY + 1) / 2);
 			*obj->pPosX = obj->goblinX * _vm->_map->_tilesWidth;
 		}
 	}

Modified: scummvm/trunk/engines/gob/sound.cpp
===================================================================
--- scummvm/trunk/engines/gob/sound.cpp	2007-02-14 09:52:21 UTC (rev 25584)
+++ scummvm/trunk/engines/gob/sound.cpp	2007-02-14 16:36:17 UTC (rev 25585)
@@ -29,6 +29,15 @@
 
 namespace Gob {
 
+Snd::SquareWaveStream::SquareWaveStream() {
+	_rate = 44100;
+	_beepForever = false;
+	_periodLength = 0;
+	_periodSamples = 0;
+	_remainingSamples = 0;
+	_sampleValue = 0;
+}
+
 void Snd::SquareWaveStream::playNote(int freq, int32 ms, uint rate) {
 	_rate = rate;
 	_periodLength = _rate / (2 * freq);
@@ -44,20 +53,21 @@
 }
 
 int Snd::SquareWaveStream::readBuffer(int16 *buffer, const int numSamples) {
-	int samples = 0;
-
-	while (samples < numSamples && _remainingSamples > 0) {
-		*buffer++ = _sampleValue;
+	for (int i = 0; i < numSamples; i++) {
+		if (!_remainingSamples) {
+			buffer[i] = 0;
+			continue;
+		}
+		buffer[i] = _sampleValue;
 		if (_periodSamples++ > _periodLength) {
 			_periodSamples = 0;
 			_sampleValue = -_sampleValue;
 		}
-		samples++;
 		if (!_beepForever)
 			_remainingSamples--;
 	}
 
-	return samples;
+	return numSamples;
 }
 
 Snd::Snd(GobEngine *vm) : _vm(vm) {
@@ -89,19 +99,18 @@
 
 	_vm->_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_handle,
 			this, -1, 255, 0, false, true);
+	_vm->_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_speakerHandle,
+			&_speakerStream, -1, 255, 0, false, true);
 }
 
 void Snd::setBlasterPort(int16 port) {return;}
 
 void Snd::speakerOn(int16 frequency, int32 length) {
 	_speakerStream.playNote(frequency, length, _vm->_mixer->getOutputRate());
-	if (!_vm->_mixer->isSoundHandleActive(_speakerHandle)) {
-		_vm->_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_speakerHandle, &_speakerStream, -1, 255, 0, false);
-	}
 }
 
 void Snd::speakerOff(void) {
-	_vm->_mixer->stopHandle(_speakerHandle);
+	_speakerStream.stop();
 }
 
 void Snd::stopSound(int16 fadeLength)

Modified: scummvm/trunk/engines/gob/sound.h
===================================================================
--- scummvm/trunk/engines/gob/sound.h	2007-02-14 09:52:21 UTC (rev 25584)
+++ scummvm/trunk/engines/gob/sound.h	2007-02-14 16:36:17 UTC (rev 25585)
@@ -82,15 +82,17 @@
 		int16 _sampleValue;
 
 	public:
-		SquareWaveStream() {}
+		SquareWaveStream();
 		~SquareWaveStream() {}
 
 		void playNote(int freq, int32 ms, uint rate);
+		void stop(void) { _remainingSamples = 0; }
 
 		int readBuffer(int16 *buffer, const int numSamples);
 
-		bool endOfData() const	{ return _remainingSamples == 0; }
 		bool isStereo() const	{ return false; }
+		bool endOfData() const	{ return false; }
+		bool endOfStream() const { return false; }
 		int getRate() const	{ return _rate; }
 	};
 


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