mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-31 07:53:36 +00:00
- Changed the square wave generator / speaker emulation, hopefully fixing the walking sound issue (#1621086)
- Fixed some misplaced actor glitches in Bargon svn-id: r25585
This commit is contained in:
parent
0e46eb8265
commit
77c70d4ee7
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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; }
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user