diff options
author | Norbert Lange | 2009-08-04 17:12:19 +0000 |
---|---|---|
committer | Norbert Lange | 2009-08-04 17:12:19 +0000 |
commit | c304c633cecce91b2cc6d71224960681a7a04707 (patch) | |
tree | 365153f085e304966f7b3f93db8ee448f9b78551 /sound/mods/tfmx.cpp | |
parent | dbe50abae4cc80cf94256ba88426d9a2f9d47d9c (diff) | |
download | scummvm-rg350-c304c633cecce91b2cc6d71224960681a7a04707.tar.gz scummvm-rg350-c304c633cecce91b2cc6d71224960681a7a04707.tar.bz2 scummvm-rg350-c304c633cecce91b2cc6d71224960681a7a04707.zip |
moved helper functions from the header file into the cpp file
svn-id: r43047
Diffstat (limited to 'sound/mods/tfmx.cpp')
-rw-r--r-- | sound/mods/tfmx.cpp | 87 |
1 files changed, 86 insertions, 1 deletions
diff --git a/sound/mods/tfmx.cpp b/sound/mods/tfmx.cpp index 1f4713b97c..9d5495d402 100644 --- a/sound/mods/tfmx.cpp +++ b/sound/mods/tfmx.cpp @@ -730,6 +730,90 @@ void Tfmx::noteCommand(const uint8 note, const uint8 param1, const uint8 param2, } } +void Tfmx::initMacroProgramm(ChannelContext &channel) { + channel.macroStep = 0; + channel.macroWait = 0; + channel.macroRun = true; + channel.macroSfxRun = 0; + channel.macroLoopCount = 0xFF; + channel.dmaIntCount = 0; + channel.deferWait = false; + + channel.macroReturnOffset = 0; + channel.macroReturnStep = 0; +} + +void Tfmx::clearEffects(ChannelContext &channel) { + channel.addBeginLength = 0; + channel.envSkip = 0; + channel.vibLength = 0; + channel.portaDelta = 0; +} + +void Tfmx::haltMacroProgramm(ChannelContext &channel) { + channel.macroRun = false; + channel.dmaIntCount = 0; +} + +void Tfmx::unlockMacroChannel(ChannelContext &channel) { + channel.customMacro = 0; + channel.customMacroPrio = false; + channel.sfxLocked = false; + channel.sfxLockTime = -1; +} + +void Tfmx::initPattern(PatternContext &pattern, uint8 cmd, int8 expose, uint32 offset) { + pattern.command = cmd; + pattern.offset = offset; + pattern.expose = expose; + pattern.step = 0; + pattern.wait = 0; + pattern.loopCount = 0xFF; + + pattern.savedOffset = 0; + pattern.savedStep = 0; +} + +void Tfmx::stopSongImpl(bool stopAudio) { + _playerCtx.song = -1; + for (int i = 0; i < kNumChannels; ++i) { + _patternCtx[i].command = 0xFF; + _patternCtx[i].expose = 0; + } + if (stopAudio) { + stopPaula(); + for (int i = 0; i < kNumVoices; ++i) { + clearEffects(_channelCtx[i]); + unlockMacroChannel(_channelCtx[i]); + haltMacroProgramm(_channelCtx[i]); + _channelCtx[i].note = 0; + _channelCtx[i].volume = 0; + Paula::disableChannel(i); + } + } +} + +void Tfmx::setNoteMacro(ChannelContext &channel, uint note, int fineTune) { + const uint16 noteInt = noteIntervalls[note & 0x3F]; + const uint16 finetune = (uint16)(fineTune + channel.fineTune + (1 << 8)); + channel.refPeriod = ((uint32)noteInt * finetune >> 8); + if (!channel.portaDelta) + channel.period = channel.refPeriod; +} + +void Tfmx::initFadeCommand(const uint8 fadeTempo, const int8 endVol) { + _playerCtx.fadeCount = _playerCtx.fadeSkip = fadeTempo; + _playerCtx.fadeEndVolume = endVol; + + if (fadeTempo) { + const int diff = _playerCtx.fadeEndVolume - _playerCtx.volume; + _playerCtx.fadeDelta = (diff != 0) ? ((diff > 0) ? 1 : -1) : 0; + } else { + _playerCtx.volume = endVol; + _playerCtx.fadeDelta = 0; + } +} + void Tfmx::setModuleData(Tfmx &otherPlayer) { setModuleData(otherPlayer._resource, otherPlayer._resourceSample.sampleData, otherPlayer._resourceSample.sampleLen, false); } @@ -765,7 +849,8 @@ void Tfmx::freeResourceDataImpl() { void Tfmx::setModuleData(const MdatResource *resource, const int8 *sampleData, uint32 sampleLen, bool autoDelete) { Common::StackLock lock(_mutex); - // TODO: stop sound and deallocate previous resources + stopSongImpl(true); + freeResourceDataImpl(); _resource = resource; _resourceSample.sampleData = sampleData; _resourceSample.sampleLen = sampleData ? sampleLen : 0; |