diff options
author | Norbert Lange | 2009-06-20 21:04:57 +0000 |
---|---|---|
committer | Norbert Lange | 2009-06-20 21:04:57 +0000 |
commit | 8e00db241f30774544bc22fb0499f08c0d39d8c4 (patch) | |
tree | 400d94a81892d43c34f4402d37a765a3b27c280b /sound | |
parent | 4725f4ab384e1c9ca3ec31d642c70b6a4e3b5f76 (diff) | |
download | scummvm-rg350-8e00db241f30774544bc22fb0499f08c0d39d8c4.tar.gz scummvm-rg350-8e00db241f30774544bc22fb0499f08c0d39d8c4.tar.bz2 scummvm-rg350-8e00db241f30774544bc22fb0499f08c0d39d8c4.zip |
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"
svn-id: r41716
Diffstat (limited to 'sound')
-rw-r--r-- | sound/mods/tfmx.cpp | 28 | ||||
-rw-r--r-- | sound/mods/tfmx.h | 13 |
2 files changed, 29 insertions, 12 deletions
diff --git a/sound/mods/tfmx.cpp b/sound/mods/tfmx.cpp index 1d5422d9fc..26879f85a6 100644 --- a/sound/mods/tfmx.cpp +++ b/sound/mods/tfmx.cpp @@ -139,19 +139,19 @@ void Tfmx::effects(ChannelContext &channel) { } // 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 @@ void Tfmx::effects(ChannelContext &channel) { 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::doMacro(int note, int macro, int relVol, int finetune, int channelNo) 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 @@ void Tfmx::doSong(int songPos, bool stopAudio) { Common::StackLock lock(_mutex); stopPatternChannels(); - if (stopAudio) + if (stopAudio) { stopMacroChannels(); + stopPaula(); + } _playerCtx.song = (int8)songPos; @@ -939,7 +943,7 @@ void Tfmx::doSong(int songPos, bool stopAudio) { 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 @@ void Tfmx::doSfx(int sfxIndex) { 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; } } diff --git a/sound/mods/tfmx.h b/sound/mods/tfmx.h index 195b582c69..91ea408834 100644 --- a/sound/mods/tfmx.h +++ b/sound/mods/tfmx.h @@ -48,12 +48,19 @@ public: 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 @@ public: 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); } } |