From: <sv...@op...> - 2024-09-08 11:44:59
|
Author: sagamusix Date: Sun Sep 8 13:44:52 2024 New Revision: 21573 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21573 Log: Merged revision(s) 21572 from trunk/OpenMPT: [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: branches/OpenMPT-1.31/ (props changed) branches/OpenMPT-1.31/soundlib/Snd_fx.cpp Modified: branches/OpenMPT-1.31/soundlib/Snd_fx.cpp ============================================================================== --- branches/OpenMPT-1.31/soundlib/Snd_fx.cpp Sun Sep 8 13:44:02 2024 (r21572) +++ branches/OpenMPT-1.31/soundlib/Snd_fx.cpp Sun Sep 8 13:44:52 2024 (r21573) @@ -3216,18 +3216,16 @@ if(m_playBehaviour[kMODVBlankTiming]) { // ProTracker MODs with VBlank timing: All Fxx parameters set the tick count. - if(m_SongFlags[SONG_FIRSTTICK] && param != 0) SetSpeed(m_PlayState, param); - break; - } + if(m_SongFlags[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; @@ -5978,17 +5976,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_SongFlags[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_SongFlags[SONG_FIRSTTICK]) { // Tempo Slide @@ -5998,12 +6003,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); } } |