From: <sv...@op...> - 2024-09-08 11:44:16
|
Author: sagamusix Date: Sun Sep 8 13:44:02 2024 New Revision: 21572 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21572 Log: [Imp] MED: Tempo commands > 255 BPM were not imported properly if the files was imported as MOD instead of XM. Fixes OSS.Mad Frenchman (https://www.un4seen.com/forum/?topic=15448.msg143478#msg143478). Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp Tue Sep 3 15:05:59 2024 (r21571) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp Sun Sep 8 13:44:02 2024 (r21572) @@ -3382,18 +3382,16 @@ if(m_playBehaviour[kMODVBlankTiming]) { // ProTracker MODs with VBlank timing: All Fxx parameters set the tick count. - if(m_PlayState.m_flags[SONG_FIRSTTICK] && param != 0) SetSpeed(m_PlayState, param); - break; - } + if(m_PlayState.m_flags[SONG_FIRSTTICK] && param != 0) + SetSpeed(m_PlayState, param); + } else { param = CalculateXParam(m_PlayState.m_nPattern, m_PlayState.m_nRow, nChn); - if (GetType() & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT)) + if (GetType() & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT)) { if (param) chn.nOldTempo = static_cast<ModCommand::PARAM>(param); else param = chn.nOldTempo; } - TEMPO t(param, 0); - LimitMax(t, GetModSpecifications().GetTempoMax()); - SetTempo(t); + SetTempo(TEMPO(param, 0)); } break; @@ -6360,17 +6358,24 @@ // Anything lower than the minimum tempo is considered to be a tempo slide const TEMPO minTempo = GetMinimumTempoParam(GetType()); + TEMPO maxTempo = specs.GetTempoMax(); + // MED files may be imported with #xx parameter extension for tempos above 255, but they may be imported as either MOD or XM. + // As regular MOD files cannot contain effect #xx, the tempo parameter cannot exceed 255 anyway, so we simply ignore their max tempo in CModSpecifications here. + if(!(GetType() & (MOD_TYPE_XM | MOD_TYPE_IT | MOD_TYPE_MPT))) + maxTempo = GetModSpecifications(MOD_TYPE_MPT).GetTempoMax(); + if(m_playBehaviour[kTempoClamp]) + maxTempo.Set(255); if(setFromUI) { // Set tempo from UI - ignore slide commands and such. - m_PlayState.m_nMusicTempo = Clamp(param, specs.GetTempoMin(), specs.GetTempoMax()); + m_PlayState.m_nMusicTempo = Clamp(param, specs.GetTempoMin(), maxTempo); } else if(param >= minTempo && m_PlayState.m_flags[SONG_FIRSTTICK] == !m_playBehaviour[kMODTempoOnSecondTick]) { // ProTracker sets the tempo after the first tick. // Note: The case of one tick per row is handled in ProcessRow() instead. // Test case: TempoChange.mod - m_PlayState.m_nMusicTempo = std::min(param, specs.GetTempoMax()); + m_PlayState.m_nMusicTempo = std::min(param, maxTempo); } else if(param < minTempo && !m_PlayState.m_flags[SONG_FIRSTTICK]) { // Tempo Slide @@ -6380,12 +6385,8 @@ else m_PlayState.m_nMusicTempo -= tempDiff; - TEMPO tempoMin = specs.GetTempoMin(), tempoMax = specs.GetTempoMax(); - if(m_playBehaviour[kTempoClamp]) // clamp tempo correctly in compatible mode - { - tempoMax.Set(255); - } - Limit(m_PlayState.m_nMusicTempo, tempoMin, tempoMax); + TEMPO tempoMin = specs.GetTempoMin(); + Limit(m_PlayState.m_nMusicTempo, tempoMin, maxTempo); } } |