diff options
author | Norbert Lange | 2009-08-04 15:43:40 +0000 |
---|---|---|
committer | Norbert Lange | 2009-08-04 15:43:40 +0000 |
commit | e6f8bfafc7d42b006977707a02ffdf6fe11f4d15 (patch) | |
tree | 53b5d8a66d4595c5bc184ef2d05710039decb9e7 | |
parent | 03066954597697a026c64e8a903358abbedc48e0 (diff) | |
download | scummvm-rg350-e6f8bfafc7d42b006977707a02ffdf6fe11f4d15.tar.gz scummvm-rg350-e6f8bfafc7d42b006977707a02ffdf6fe11f4d15.tar.bz2 scummvm-rg350-e6f8bfafc7d42b006977707a02ffdf6fe11f4d15.zip |
moved code for initialising patterns into own function
added initialisation of return-addresses for patterns and macros
svn-id: r43045
-rw-r--r-- | sound/mods/tfmx.cpp | 39 | ||||
-rw-r--r-- | sound/mods/tfmx.h | 19 |
2 files changed, 33 insertions, 25 deletions
diff --git a/sound/mods/tfmx.cpp b/sound/mods/tfmx.cpp index 634b9c7f45..5d37125e56 100644 --- a/sound/mods/tfmx.cpp +++ b/sound/mods/tfmx.cpp @@ -334,6 +334,7 @@ void Tfmx::macroRun(ChannelContext &channel) { channel.vibLength = macroPtr[1]; channel.vibCount = macroPtr[1] / 2; channel.vibDelta = macroPtr[3]; + // TODO: Perhaps a bug, vibValue could be left uninitialised if (!channel.portaDelta) { channel.period = channel.refPeriod; channel.vibValue = 0; @@ -358,7 +359,7 @@ void Tfmx::macroRun(ChannelContext &channel) { channel.envEndVolume = macroPtr[3]; continue; - case 0x11: // Add Begin. Parameters: times, Offset(W) + case 0x11: // Add Beginn. Parameters: times, Offset(W) channel.addBeginLength = channel.addBeginCount = macroPtr[1]; channel.addBeginDelta = (int16)READ_BE_UINT16(¯oPtr[2]); channel.sampleStart += channel.addBeginDelta; @@ -482,8 +483,10 @@ startPatterns: // issue all Steps for this tick if (patternRun(pattern)) { // we load the next Trackstep Command and then process all Channels again - trackRun(true); - goto startPatterns; + if (trackRun(true)) + goto startPatterns; + else + break; } } else @@ -493,7 +496,7 @@ startPatterns: pattern.command = 0xFF; ChannelContext &channel = _channelCtx[pattern.expose & (kNumVoices - 1)]; if (!channel.sfxLocked) { - clearMacroProgramm(channel); + haltMacroProgramm(channel); Paula::disableChannel(channel.paulaChannel); } } // else this pattern-Channel is stopped @@ -587,16 +590,8 @@ bool Tfmx::patternRun(PatternContext &pattern) { initFadeCommand((uint8)patternPtr[1], (int8)patternPtr[3]); continue; - case 11: { // play pattern. Parameters: patternCmd, channel, expose - PatternContext &target = _patternCtx[patternPtr[2] & (kNumChannels - 1)]; - - target.command = patternPtr[1]; - target.offset = _resource->patternOffset[patternPtr[1] & (kMaxPatternOffsets - 1)]; - target.expose = patternPtr[3]; - target.step = 0; - target.wait = 0; - target.loopCount = 0xFF; - } + case 11: // play pattern. Parameters: patternCmd, channel, expose + initPattern(_patternCtx[patternPtr[2] & (kNumChannels - 1)], patternPtr[1], patternPtr[3], _resource->patternOffset[patternPtr[1] & (kMaxPatternOffsets - 1)]); continue; case 12: // Lock. Parameters: lockFlag, channel, lockTime @@ -631,18 +626,16 @@ bool Tfmx::trackRun(const bool incStep) { if (trackData[0] != FROM_BE_16(0xEFFE)) { // 8 commands for Patterns for (int i = 0; i < 8; ++i) { - const uint patCmd = READ_BE_UINT16(&trackData[i]); + const uint8 *patCmd = (const uint8 *)&trackData[i]; // First byte is pattern number - const uint patNum = (patCmd >> 8); + const uint8 patNum = patCmd[0]; // if highest bit is set then keep previous pattern if (patNum < 0x80) { - _patternCtx[i].step = 0; - _patternCtx[i].wait = 0; - _patternCtx[i].loopCount = 0xFF; - _patternCtx[i].offset = _resource->patternOffset[patNum]; + initPattern(_patternCtx[i], patNum, patCmd[1], _resource->patternOffset[patNum]); + } else { + _patternCtx[i].command = patNum; + _patternCtx[i].expose = (int8)patCmd[1]; } - _patternCtx[i].command = (uint8)patNum; - _patternCtx[i].expose = patCmd & 0xFF; } return true; @@ -938,7 +931,7 @@ void Tfmx::stopMacroEffect(int channel) { assert(0 <= channel && channel < kNumVoices); Common::StackLock lock(_mutex); unlockMacroChannel(_channelCtx[channel]); - clearMacroProgramm(_channelCtx[channel]); + haltMacroProgramm(_channelCtx[channel]); Paula::disableChannel(_channelCtx[channel].paulaChannel); } diff --git a/sound/mods/tfmx.h b/sound/mods/tfmx.h index 24666e5be9..2b857dbe1d 100644 --- a/sound/mods/tfmx.h +++ b/sound/mods/tfmx.h @@ -231,6 +231,9 @@ private: channel.macroLoopCount = 0xFF; channel.dmaIntCount = 0; channel.deferWait = false; + + channel.macroReturnOffset = 0; + channel.macroReturnStep = 0; } static void clearEffects(ChannelContext &channel) { @@ -240,7 +243,7 @@ private: channel.portaDelta = 0; } - static void clearMacroProgramm(ChannelContext &channel) { + static void haltMacroProgramm(ChannelContext &channel) { channel.macroRun = false; channel.dmaIntCount = 0; } @@ -252,6 +255,18 @@ private: 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 stopPatternChannels() { for (int i = 0; i < kNumChannels; ++i) { _patternCtx[i].command = 0xFF; @@ -263,7 +278,7 @@ private: for (int i = 0; i < kNumVoices; ++i) { clearEffects(_channelCtx[i]); unlockMacroChannel(_channelCtx[i]); - clearMacroProgramm(_channelCtx[i]); + haltMacroProgramm(_channelCtx[i]); _channelCtx[i].note = 0; _channelCtx[i].volume = 0; } |