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 | |
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')
-rw-r--r-- | sound/mods/tfmx.cpp | 87 | ||||
-rw-r--r-- | sound/mods/tfmx.h | 92 |
2 files changed, 94 insertions, 85 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; diff --git a/sound/mods/tfmx.h b/sound/mods/tfmx.h index 9af348ad47..5e6550282f 100644 --- a/sound/mods/tfmx.h +++ b/sound/mods/tfmx.h @@ -256,90 +256,14 @@ private: return sample; } - static void 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; - } - - static void clearEffects(ChannelContext &channel) { - channel.addBeginLength = 0; - channel.envSkip = 0; - channel.vibLength = 0; - channel.portaDelta = 0; - } - - static void haltMacroProgramm(ChannelContext &channel) { - channel.macroRun = false; - channel.dmaIntCount = 0; - } - - static void unlockMacroChannel(ChannelContext &channel) { - channel.customMacro = 0; - channel.customMacroPrio = false; - channel.sfxLocked = false; - channel.sfxLockTime = -1; - } - - static void 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 stopSongImpl(bool stopAudio = true) { - _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); - } - } - } - - static void 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 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; - } - } - + static inline void initMacroProgramm(ChannelContext &channel); + static inline void clearEffects(ChannelContext &channel); + static inline void haltMacroProgramm(ChannelContext &channel); + static inline void unlockMacroChannel(ChannelContext &channel); + static inline void initPattern(PatternContext &pattern, uint8 cmd, int8 expose, uint32 offset); + void stopSongImpl(bool stopAudio = true); + static void inline setNoteMacro(ChannelContext &channel, uint note, int fineTune); + void initFadeCommand(const uint8 fadeTempo, const int8 endVol); void setModuleData(const MdatResource *resource, const int8 *sampleData, uint32 sampleLen, bool autoDelete = true); static const MdatResource *loadMdatFile(Common::SeekableReadStream &musicData); static const int8 *loadSampleFile(uint32 &sampleLen, Common::SeekableReadStream &sampleStream); |