|
From: <sag...@us...> - 2015-03-11 15:23:43
|
Revision: 4864
http://sourceforge.net/p/modplug/code/4864
Author: saga-games
Date: 2015-03-11 15:23:30 +0000 (Wed, 11 Mar 2015)
Log Message:
-----------
[Fix] XParam + Oxx was no longer able to create offsets < 256.
[Ref] Make tempo code also use CalculateXParam.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndfile.h
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-03-11 14:23:08 UTC (rev 4863)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-03-11 15:23:30 UTC (rev 4864)
@@ -378,34 +378,13 @@
if(param != 0) memory.state.m_nMusicSpeed = param;
break;
}
+ param = CalculateXParam(memory.state.m_nPattern, memory.state.m_nRow, nChn);
if ((adjustMode & eAdjust) && (GetType() & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT)))
{
if (param) pChn->nOldTempo = param; else param = pChn->nOldTempo;
}
- if (param >= 0x20) memory.state.m_nMusicTempo = param; else
- {
- // Tempo Slide
- uint32 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 = 32;
- }
- }
-// -> CODE#0010
-// -> DESC="add extended parameter mechanism to pattern effects"
- 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);
-// -! NEW_FEATURE#0010
+ SetTempo(param);
break;
-
case CMD_S3MCMDEX:
if((param & 0xF0) == 0x60)
{
@@ -641,8 +620,9 @@
if(p->command == CMD_OFFSET)
{
- SmpLength offset = CalculateXParam(memory.state.m_nPattern, memory.state.m_nRow, nChn);
- if(offset < 256)
+ bool isExtended = false;
+ SmpLength offset = CalculateXParam(memory.state.m_nPattern, memory.state.m_nRow, nChn, &isExtended);
+ if(!isExtended)
{
offset <<= 8;
if(offset == 0) offset = pChn->oldOffset;
@@ -2600,27 +2580,12 @@
if(m_SongFlags[SONG_FIRSTTICK] && param != 0) SetSpeed(param);
break;
}
-// -> CODE#0010
-// -> DESC="add extended parameter mechanism to pattern effects"
- m = nullptr;
- if (m_PlayState.m_nRow < Patterns[m_PlayState.m_nPattern].GetNumRows()-1)
- {
- m = Patterns[m_PlayState.m_nPattern].GetpModCommand(m_PlayState.m_nRow + 1, nChn);
- }
- if (m && m->command == CMD_XPARAM)
- {
- if ((GetType() & MOD_TYPE_XM))
- {
- param -= 0x20; //with XM, 0x20 is the lowest tempo. Anything below changes ticks per row.
- }
- param = (param << 8) + m->param;
- }
-// -! NEW_FEATURE#0010
+
+ param = CalculateXParam(m_PlayState.m_nPattern, m_PlayState.m_nRow, nChn);
if (GetType() & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT))
{
if (param) pChn->nOldTempo = param; else param = pChn->nOldTempo;
}
- if (param > GetModSpecifications().tempoMax) param = GetModSpecifications().tempoMax; // rewbs.merge: added check to avoid hyperspaced tempo!
SetTempo(param);
break;
@@ -2634,8 +2599,9 @@
{
break;
}
- SmpLength offset = CalculateXParam(m_PlayState.m_nPattern, m_PlayState.m_nRow, nChn);
- if(offset < 256)
+ bool isExtended = false;
+ SmpLength offset = CalculateXParam(m_PlayState.m_nPattern, m_PlayState.m_nRow, nChn, &isExtended);
+ if(!isExtended)
{
// No X-param (normal behaviour)
offset <<= 8;
@@ -3020,9 +2986,11 @@
// Calculate full parameter for effects that support parameter extension at the given pattern location.
// maxCommands sets the maximum number of XParam commands to look at for this effect
-uint32_t CSoundFile::CalculateXParam(PATTERNINDEX pat, ROWINDEX row, CHANNELINDEX chn) const
-//------------------------------------------------------------------------------------------
+// isExtended returns if the command is actually using any XParam extensions.
+uint32_t CSoundFile::CalculateXParam(PATTERNINDEX pat, ROWINDEX row, CHANNELINDEX chn, bool *isExtended) const
+//------------------------------------------------------------------------------------------------------------
{
+ if(isExtended != nullptr) *isExtended = false;
ROWINDEX maxCommands = 4;
const ModCommand *m = Patterns[pat].GetpModCommand(chn, row);
uint32_t val = m->param;
@@ -3042,6 +3010,7 @@
return val;
}
+ const bool xmTempoFix = m->command == CMD_TEMPO && GetType() == MOD_TYPE_XM;
ROWINDEX numRows = std::min(Patterns[pat].GetNumRows() - row - 1, maxCommands);
while(numRows > 0)
{
@@ -3050,8 +3019,14 @@
{
break;
}
+ if(xmTempoFix && val < 256)
+ {
+ // With XM, 0x20 is the lowest tempo. Anything below changes ticks per row.
+ val -= 0x20;
+ }
val = (val << 8) | m->param;
numRows--;
+ if(isExtended != nullptr) *isExtended = true;
}
return val;
}
@@ -4916,22 +4891,19 @@
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;
- }
- // Tempo Slide
- else if (param < 0x20 && !m_SongFlags[SONG_FIRSTTICK]) //rewbs.tempoSlideFix: only slide if (T0x or T1x) and tick is not 0
+ 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
- // -> CODE#0016
- // -> DESC="default tempo update"
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);
- // -! BEHAVIOUR_CHANGE#0016
}
}
}
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2015-03-11 14:23:08 UTC (rev 4863)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2015-03-11 15:23:30 UTC (rev 4864)
@@ -781,7 +781,7 @@
void NoteChange(ModChannel *pChn, int note, bool bPorta = false, bool bResetEnv = true, bool bManual = false) const;
void InstrumentChange(ModChannel *pChn, UINT instr, bool bPorta = false, bool bUpdVol = true, bool bResetEnv = true) const;
void ApplyInstrumentPanning(ModChannel *pChn, const ModInstrument *instr, const ModSample *smp) const;
- uint32_t CalculateXParam(PATTERNINDEX pat, ROWINDEX row, CHANNELINDEX chn) const;
+ uint32_t CalculateXParam(PATTERNINDEX pat, ROWINDEX row, CHANNELINDEX chn, bool *isExtended = nullptr) const;
// Channel Effects
void KeyOff(ModChannel *pChn) const;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|