From 9a84c13bef923eedc020b6706d0a7b6685bb42fd Mon Sep 17 00:00:00 2001 From: Benjamin Haisch Date: Mon, 22 Jun 2009 16:11:49 +0000 Subject: TOLTECS: - Implemented playSoundAtPos and fixed sound panning (0 is center, not 64 like in the original) - Minor cleanup --- engines/toltecs/script.cpp | 3 +-- engines/toltecs/sound.cpp | 42 +++++++++++++++++++++++++++--------------- engines/toltecs/toltecs.cpp | 21 +-------------------- engines/toltecs/toltecs.h | 1 - 4 files changed, 29 insertions(+), 38 deletions(-) (limited to 'engines') diff --git a/engines/toltecs/script.cpp b/engines/toltecs/script.cpp index 602c3f507b..920c0d0180 100644 --- a/engines/toltecs/script.cpp +++ b/engines/toltecs/script.cpp @@ -1054,8 +1054,7 @@ void ScriptInterpreter::sfSetSequenceVolume() { } void ScriptInterpreter::sfPlayPositionalSound() { - // TODO - debug("ScriptInterpreter::sfPlayPositionalSound()"); + _vm->_sound->playSoundAtPos(arg16(3), arg16(9), arg16(7)); } void ScriptInterpreter::sfPlaySound2() { diff --git a/engines/toltecs/sound.cpp b/engines/toltecs/sound.cpp index b3d327f5f8..012b5eec61 100644 --- a/engines/toltecs/sound.cpp +++ b/engines/toltecs/sound.cpp @@ -56,47 +56,59 @@ Sound::~Sound() { } void Sound::playSpeech(int16 resIndex) { - - // TODO - debug(0, "playSpeech(%d)", resIndex); - - internalPlaySound(resIndex, kChannelTypeSpeech, 50 /*TODO*/, 64); - + internalPlaySound(resIndex, kChannelTypeSpeech, 50 /*TODO*/, 0); } void Sound::playSound(int16 resIndex, int16 type, int16 volume) { // TODO: Use the right volumes - debug(0, "playSound(%d, %d, %d)", resIndex, type, volume); + debug("playSound(%d, %d, %d)", resIndex, type, volume); if (volume == -1 || type == kChannelTypeSfx) { if (type == kChannelTypeBackground) { - internalPlaySound(resIndex, type, 50 /*TODO*/, 64); + internalPlaySound(resIndex, type, 50 /*TODO*/, 0); } else { - internalPlaySound(resIndex, type, 100 /*TODO*/, 64); + internalPlaySound(resIndex, type, 100 /*TODO*/, 0); } } else { - internalPlaySound(resIndex, type, 100 /*TODO*/, 64); + internalPlaySound(resIndex, type, 100 /*TODO*/, 0); } } void Sound::playSoundAtPos(int16 resIndex, int16 x, int16 y) { - // TODO: Everything - debug(0, "playSoundAtPos(%d, %d, %d)", resIndex, x, y); - internalPlaySound(resIndex, 1, 50, 64); + int16 volume, panning = 0, deltaX = 0; + int8 scaling = _vm->_segmap->getScalingAtPoint(x, y); + + if (scaling >= 0) + volume = 50 + ABS(scaling) / 2; + else + volume = 50 - ABS(scaling) / 2; + + if (_vm->_cameraX > x) + deltaX = _vm->_cameraX - x; + else if (_vm->_cameraX + 640 < x) + deltaX = x - (_vm->_cameraX + 640); + if (deltaX > 600) + deltaX = 600; + + volume = ((100 - deltaX / 6) * volume) / 100; + + if (_vm->_cameraX + 320 != x) { + panning = CLIP(x - (_vm->_cameraX + 320), -381, 381) / 3; + } + + internalPlaySound(resIndex, 1, volume, panning); } void Sound::internalPlaySound(int16 resIndex, int16 type, int16 volume, int16 panning) { - // TODO - if (resIndex == -1) { // Stop all sounds _vm->_mixer->stopAll(); diff --git a/engines/toltecs/toltecs.cpp b/engines/toltecs/toltecs.cpp index 80a77af994..cd736fb129 100644 --- a/engines/toltecs/toltecs.cpp +++ b/engines/toltecs/toltecs.cpp @@ -415,7 +415,6 @@ void ToltecsEngine::talk(int16 slotIndex, int16 slotOffset) { byte *scanData = _script->getSlotData(slotIndex) + slotOffset; while (*scanData < 0xF0) { - if (*scanData == 0x19) { scanData++; } else if (*scanData == 0x14) { @@ -425,7 +424,6 @@ void ToltecsEngine::talk(int16 slotIndex, int16 slotOffset) { } else if (*scanData < 0x0A) { scanData++; } - scanData++; } @@ -438,7 +436,7 @@ void ToltecsEngine::talk(int16 slotIndex, int16 slotOffset) { if (_doText) { _screen->updateTalkText(slotIndex, slotOffset); } else { - // TODO: font_sub_4B3E2 + _screen->keepTalkTextItemsAlive(); } } else { _screen->updateTalkText(slotIndex, slotOffset); @@ -446,23 +444,6 @@ void ToltecsEngine::talk(int16 slotIndex, int16 slotOffset) { } -void ToltecsEngine::playText(int16 slotIndex, int16 slotOffset) { - - byte *textData = _script->getSlotData(slotIndex) + slotOffset; - - debug(0, "ToltecsEngine::playText() [textData = %s]", (char*)textData); - - Common::String str; - while (*textData < 0xF0) { - if (*textData >= 32) - str += (char)*textData; - textData++; - } - - debug(0, "ToltecsEngine::playText() [%s]", str.c_str()); - -} - void ToltecsEngine::walk(byte *walkData) { int16 xdelta, ydelta, v8, v10, v11; diff --git a/engines/toltecs/toltecs.h b/engines/toltecs/toltecs.h index 7b7e1a33fc..b425af8274 100644 --- a/engines/toltecs/toltecs.h +++ b/engines/toltecs/toltecs.h @@ -91,7 +91,6 @@ public: void updateCamera(); void talk(int16 slotIndex, int16 slotOffset); - void playText(int16 slotIndex, int16 slotOffset); void walk(byte *walkData); -- cgit v1.2.3