aboutsummaryrefslogtreecommitdiff
path: root/engines/gob
diff options
context:
space:
mode:
authorSven Hesse2007-02-14 16:36:17 +0000
committerSven Hesse2007-02-14 16:36:17 +0000
commit77c70d4ee7731ad0581b3bb8321de23d9042de5e (patch)
treefc5f3d9ede1ead065fe6c65c5d4521c57afb369a /engines/gob
parent0e46eb82656617d3a15bb35315a3300618d15955 (diff)
downloadscummvm-rg350-77c70d4ee7731ad0581b3bb8321de23d9042de5e.tar.gz
scummvm-rg350-77c70d4ee7731ad0581b3bb8321de23d9042de5e.tar.bz2
scummvm-rg350-77c70d4ee7731ad0581b3bb8321de23d9042de5e.zip
- Changed the square wave generator / speaker emulation, hopefully fixing the walking sound issue (#1621086)
- Fixed some misplaced actor glitches in Bargon svn-id: r25585
Diffstat (limited to 'engines/gob')
-rw-r--r--engines/gob/goblin.cpp2
-rw-r--r--engines/gob/goblin_v2.cpp8
-rw-r--r--engines/gob/inter_v1.cpp2
-rw-r--r--engines/gob/inter_v2.cpp12
-rw-r--r--engines/gob/sound.cpp29
-rw-r--r--engines/gob/sound.h6
6 files changed, 35 insertions, 24 deletions
diff --git a/engines/gob/goblin.cpp b/engines/gob/goblin.cpp
index 46d49b46a1..afbcf83ae6 100644
--- a/engines/gob/goblin.cpp
+++ b/engines/gob/goblin.cpp
@@ -1925,7 +1925,7 @@ void Goblin::sub_197A6(int16 destX, int16 destY, int16 objIndex) {
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;
diff --git a/engines/gob/goblin_v2.cpp b/engines/gob/goblin_v2.cpp
index 35114f4ed9..4df678f118 100644
--- a/engines/gob/goblin_v2.cpp
+++ b/engines/gob/goblin_v2.cpp
@@ -83,8 +83,8 @@ void Goblin_v2::placeObject(Gob_Object *objDesc, char animated,
*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 @@ void Goblin_v2::placeObject(Gob_Object *objDesc, char animated,
*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
diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp
index 5cdb0d5d53..e11f452287 100644
--- a/engines/gob/inter_v1.cpp
+++ b/engines/gob/inter_v1.cpp
@@ -1468,7 +1468,7 @@ bool Inter_v1::o1_keyFunc(char &cmdCount, int16 &counter, int16 &retFlag) {
if (flag != 1) {
if (flag != 2) {
if (flag < 20) {
- _vm->_util->delay(flag);
+ _vm->_util->delay(flag * 2);
_noBusyWait = true;
}
else
diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp
index 725810de5f..bf6082bade 100644
--- a/engines/gob/inter_v2.cpp
+++ b/engines/gob/inter_v2.cpp
@@ -1138,7 +1138,7 @@ void Inter_v2::o2_moveGoblin(void) {
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 @@ void Inter_v2::loadMult(void) {
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;
}
}
diff --git a/engines/gob/sound.cpp b/engines/gob/sound.cpp
index 6d9e66ce21..c39eb1165d 100644
--- a/engines/gob/sound.cpp
+++ b/engines/gob/sound.cpp
@@ -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 @@ void Snd::SquareWaveStream::playNote(int freq, int32 ms, uint rate) {
}
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 @@ Snd::Snd(GobEngine *vm) : _vm(vm) {
_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)
diff --git a/engines/gob/sound.h b/engines/gob/sound.h
index 773193af36..4a614fc8cc 100644
--- a/engines/gob/sound.h
+++ b/engines/gob/sound.h
@@ -82,15 +82,17 @@ protected:
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; }
};