diff options
-rw-r--r-- | engines/scumm/player_v4a.cpp | 3 | ||||
-rw-r--r-- | sound/mods/tfmx.cpp | 48 | ||||
-rw-r--r-- | sound/mods/tfmx.h | 4 |
3 files changed, 20 insertions, 35 deletions
diff --git a/engines/scumm/player_v4a.cpp b/engines/scumm/player_v4a.cpp index 6be06c018e..7dddffe0ad 100644 --- a/engines/scumm/player_v4a.cpp +++ b/engines/scumm/player_v4a.cpp @@ -75,7 +75,6 @@ void Player_V4A::setMusicVolume(int vol) { debug("player_v4a: setMusicVolume %i", vol); } - void Player_V4A::stopAllSounds() { if (_musicId) stopSound(_musicId); @@ -133,13 +132,11 @@ void Player_V4A::startSound(int nr) { _tfmxPlay->doSong(index); _musicId = nr; - if (!_mixer->isSoundHandleActive(_musicHandle)) _mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _tfmxPlay, -1, Audio::Mixer::kMaxChannelVolume, 0, false, false); } } - int Player_V4A::getMusicTimer() const { if (_musicId) { // TODO: The titlesong is running with ~70 ticks per second and the scale seems to be based on that. 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); }; |