diff options
author | Norbert Lange | 2009-06-19 20:41:32 +0000 |
---|---|---|
committer | Norbert Lange | 2009-06-19 20:41:32 +0000 |
commit | f94b8565a9ee413c849563b33e959bcaed8376fa (patch) | |
tree | a41dcc0de838d864325ea7266136a35ffeef4cb2 /sound | |
parent | 4865863f6cff6c141edaf4f6cb6ce4ef2687d12a (diff) | |
download | scummvm-rg350-f94b8565a9ee413c849563b33e959bcaed8376fa.tar.gz scummvm-rg350-f94b8565a9ee413c849563b33e959bcaed8376fa.tar.bz2 scummvm-rg350-f94b8565a9ee413c849563b33e959bcaed8376fa.zip |
more cleanups, got rid of pendingTrackstep variable
svn-id: r41686
Diffstat (limited to 'sound')
-rw-r--r-- | sound/mods/tfmx.cpp | 48 | ||||
-rw-r--r-- | sound/mods/tfmx.h | 4 |
2 files changed, 20 insertions, 32 deletions
diff --git a/sound/mods/tfmx.cpp b/sound/mods/tfmx.cpp index 8a9fc0d962..931ec7bb27 100644 --- a/sound/mods/tfmx.cpp +++ b/sound/mods/tfmx.cpp @@ -90,10 +90,6 @@ void Tfmx::interrupt() { channel.sfxLocked = (channel.customMacroPrio != 0); } - - - // TODO: Sometimes a macro will be executed here - // apply timebased effects on Parameters effects(channel); @@ -473,12 +469,7 @@ FORCEINLINE bool Tfmx::macroStep(ChannelContext &channel) { } void Tfmx::advancePatterns() { -doTrackstep: - if (_playerCtx.pendingTrackstep) { - while (trackStep()) - ; - _playerCtx.pendingTrackstep = false; - } +startPatterns: int runningPatterns = 0; for (int i = 0; i < kNumChannels; ++i) { @@ -486,9 +477,22 @@ doTrackstep: if (pattCmd < 0x90) { // execute Patternstep ++runningPatterns; if (_patternCtx[i].wait == 0) { + bool pendingTrackstep = false; // issue all Steps for this tick - while (patternStep(_patternCtx[i])) + while (patternStep(_patternCtx[i], pendingTrackstep)) ; + if (pendingTrackstep) { + // we load the next Trackstep Command and then process all Channels again + // TODO Optionally disable looping + if (_trackCtx.posInd == _trackCtx.stopInd) + _trackCtx.posInd = _trackCtx.startInd; + else + ++_trackCtx.posInd; + while (trackStep()) + ; + goto startPatterns; + } + } else --_patternCtx[i].wait; @@ -496,16 +500,6 @@ doTrackstep: _patternCtx[i].command = 0xFF; stopChannel(_channelCtx[_patternCtx[i].expose % kNumVoices]); } // else this pattern-Channel is stopped - - if (_playerCtx.pendingTrackstep) { - // we load the next Trackstep Command and then process all Channels again - // TODO Optionally disable looping - if (_trackCtx.posInd == _trackCtx.stopInd) - _trackCtx.posInd = _trackCtx.startInd; - else - ++_trackCtx.posInd; - goto doTrackstep; - } } if (_playerCtx.stopWithLastPattern && !runningPatterns) { _playerCtx.enabled = 0; @@ -526,7 +520,7 @@ static void warnPatternUnimplemented(const byte *patternPtr, int level) { } -FORCEINLINE bool Tfmx::patternStep(PatternContext &pattern) { +FORCEINLINE bool Tfmx::patternStep(PatternContext &pattern, bool &pendingTrackstep) { const byte *const patternPtr = (byte *)(_resource.getPatternPtr(pattern.offset) + pattern.step); ++pattern.step; @@ -554,7 +548,7 @@ FORCEINLINE bool Tfmx::patternStep(PatternContext &pattern) { case 0: // End Pattern + Next Trackstep pattern.command = 0xFF; --pattern.step; - _playerCtx.pendingTrackstep = true; + pendingTrackstep = true; return false; case 1: // Loop Pattern. Parameters: Loopcount, PatternStep(W) @@ -950,7 +944,6 @@ void Tfmx::doSong(int songPos) { while (trackStep()) ; - _playerCtx.pendingTrackstep = false; startPaula(); } @@ -959,23 +952,20 @@ void Tfmx::doSfx(int sfxIndex) { Common::StackLock lock(_mutex); const byte *sfxEntry = _resource.getSfxPtr(sfxIndex); - if (sfxEntry[0] == 0xFB) { // custompattern const uint8 patCmd = sfxEntry[2]; const int8 patExp = (int8)sfxEntry[3]; } else { // custommacro - // byte index = (_playerCtx.song >= 0) ? sfxEntry[2] : sfxEntry[4]; const byte channelNo = sfxEntry[2] % kNumVoices; + const byte index = (_playerCtx.song >= 0) ? sfxEntry[2] : sfxEntry[4]; const byte priority = sfxEntry[5] & 0x7F; ChannelContext &channel = _channelCtx[channelNo]; - const int16 sfxLocktime = channel.sfxLockTime; - if (priority >= channel.customMacroPrio || sfxLocktime < 0) { - if (sfxIndex != channel.customMacroIndex || sfxLocktime < 0 || (sfxEntry[5] < 0x80) ) { + 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; diff --git a/sound/mods/tfmx.h b/sound/mods/tfmx.h index e33c4e8037..b59d0d0f0c 100644 --- a/sound/mods/tfmx.h +++ b/sound/mods/tfmx.h @@ -205,8 +205,6 @@ public: // bool end; int8 song; //!< >= 0 if Song is running (means process Patterns) - bool pendingTrackstep; - uint16 patternCount; uint16 patternSkip; //!< skip that amount of CIA-Interrupts @@ -261,7 +259,7 @@ public: void effects(ChannelContext &channel); FORCEINLINE bool macroStep(ChannelContext &channel); void advancePatterns(); - FORCEINLINE bool patternStep(PatternContext &pattern); + FORCEINLINE bool patternStep(PatternContext &pattern, bool &pendingTrackstep); bool trackStep(); void noteCommand(uint8 note, uint8 param1, uint8 param2, uint8 param3); }; |