From: <sag...@us...> - 2015-03-11 15:39:33
|
Revision: 4866 http://sourceforge.net/p/modplug/code/4866 Author: saga-games Date: 2015-03-11 15:39:19 +0000 (Wed, 11 Mar 2015) Log Message: ----------- [Fix] SetTempo() mustn't be used by GetLength, because it modifies global state and doesn't handle slides correctly. Note that an old bug regarding slides remains for now: If there is a set speed command right of the tempo slide command, it is not considered. Modified Paths: -------------- trunk/OpenMPT/soundlib/Snd_fx.cpp Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-03-11 15:35:56 UTC (rev 4865) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-03-11 15:39:19 UTC (rev 4866) @@ -383,7 +383,28 @@ { if (param) pChn->nOldTempo = param; else param = pChn->nOldTempo; } - SetTempo(param); + + if (param >= 0x20) memory.state.m_nMusicTempo = param; + else + { + // Tempo Slide + uint32_t tempoDiff = (param & 0x0F) * (memory.state.m_nMusicSpeed - 1); + if ((param & 0xF0) == 0x10) + { + memory.state.m_nMusicTempo += tempoDiff; + } else + { + if(tempoDiff < memory.state.m_nMusicTempo) + memory.state.m_nMusicTempo -= tempoDiff; + else + memory.state.m_nMusicTempo = 0; + } + } + if(IsCompatibleMode(TRK_ALLTRACKERS)) // clamp tempo correctly in compatible mode + memory.state.m_nMusicTempo = Clamp(memory.state.m_nMusicTempo, 32u, 255u); + else + memory.state.m_nMusicTempo = Clamp(memory.state.m_nMusicTempo, GetModSpecifications().tempoMin, GetModSpecifications().tempoMax); + break; case CMD_S3MCMDEX: if((param & 0xF0) == 0x60) @@ -4885,26 +4906,22 @@ { // Set tempo from UI - ignore slide commands and such. m_PlayState.m_nMusicTempo = Clamp(param, specs.tempoMin, specs.tempoMax); - } - else + } else if (param >= 0x20 && m_SongFlags[SONG_FIRSTTICK]) { - if (param >= 0x20 && m_SongFlags[SONG_FIRSTTICK]) //rewbs.tempoSlideFix: only set if not (T0x or T1x) and tick is 0 - { - m_PlayState.m_nMusicTempo = param; - if (param > GetModSpecifications().tempoMax) param = GetModSpecifications().tempoMax; - } else if (param < 0x20 && !m_SongFlags[SONG_FIRSTTICK]) //rewbs.tempoSlideFix: only slide if (T0x or T1x) and tick is not 0 - { - // Tempo Slide - if ((param & 0xF0) == 0x10) - m_PlayState.m_nMusicTempo += (param & 0x0F); //rewbs.tempoSlideFix: no *2 - else - m_PlayState.m_nMusicTempo -= (param & 0x0F); //rewbs.tempoSlideFix: no *2 + m_PlayState.m_nMusicTempo = param; + if (param > GetModSpecifications().tempoMax) param = GetModSpecifications().tempoMax; + } else if (param < 0x20 && !m_SongFlags[SONG_FIRSTTICK]) + { + // Tempo Slide + if ((param & 0xF0) == 0x10) + m_PlayState.m_nMusicTempo += (param & 0x0F); + else + m_PlayState.m_nMusicTempo -= (param & 0x0F); - if(IsCompatibleMode(TRK_ALLTRACKERS)) // clamp tempo correctly in compatible mode - m_PlayState.m_nMusicTempo = Clamp(m_PlayState.m_nMusicTempo, 32u, 255u); - else - m_PlayState.m_nMusicTempo = Clamp(m_PlayState.m_nMusicTempo, specs.tempoMin, specs.tempoMax); - } + if(IsCompatibleMode(TRK_ALLTRACKERS)) // clamp tempo correctly in compatible mode + m_PlayState.m_nMusicTempo = Clamp(m_PlayState.m_nMusicTempo, 32u, 255u); + else + m_PlayState.m_nMusicTempo = Clamp(m_PlayState.m_nMusicTempo, specs.tempoMin, specs.tempoMax); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |