|
From: <sag...@us...> - 2013-05-19 20:23:32
|
Revision: 2139
http://sourceforge.net/p/modplug/code/2139
Author: saga-games
Date: 2013-05-19 20:23:13 +0000 (Sun, 19 May 2013)
Log Message:
-----------
[Fix] FT2 compatibility: Emulate FT2's very weird frequency wraparound behaviour with 2xx effects (http://bugs.openmpt.org/view.php?id=386, test case: FreqWarparound.xm)
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-05-19 20:20:42 UTC (rev 2138)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-05-19 20:23:13 UTC (rev 2139)
@@ -4691,9 +4691,23 @@
} else if (GetType() == MOD_TYPE_XM)
{
if(m_SongFlags[SONG_LINEARSLIDES])
- return XMLinearTable[period % 768] >> (period / 768);
- else
+ {
+ uint32 octave = period / 768;
+ if(IsCompatibleMode(TRK_FASTTRACKER2))
+ {
+ // Under normal circumstances, this calculation returns the same values as the non-compatible one.
+ // However, once the 12 octaves are exceeded (through portamento slides), FT2 wraps the frequency around...
+ // Test case: FreqWraparound.xm
+ // 12 octaves * (12 * 64) LUT entries = 9216, add 767 for rounding
+ // Period is a 16 bit value in FT2, hence the "& 0xFFFF".
+ uint32 div = ((9216u + 767u - (period & 0xFFFF)) / 768);
+ octave = ((12 - div) & 0x1F) % 29u;
+ }
+ return XMLinearTable[period % 768] >> octave;
+ } else
+ {
return 8363 * 1712L / period;
+ }
} else
{
if(m_SongFlags[SONG_LINEARSLIDES])
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-05-19 20:20:42 UTC (rev 2138)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-05-19 20:23:13 UTC (rev 2139)
@@ -230,7 +230,7 @@
m_PatternCuePoints.push_back(cue);
}
#endif
- } else
+ } else
{
#ifdef MODPLUG_TRACKER
if ((m_nMaxOrderPosition) && (m_nCurrentOrder >= m_nMaxOrderPosition))
@@ -1909,7 +1909,7 @@
int32 ninc = Util::muldiv(freq, 0x10000, m_MixerSettings.gdwMixingFreq);
if ((ninc >= 0xFFB0) && (ninc <= 0x10090)) ninc = 0x10000;
if (m_nFreqFactor != 128) ninc = (ninc * m_nFreqFactor) >> 7;
- if (ninc > 0xFF0000) ninc = 0xFF0000;
+ Limit(ninc, 3, 0xFF0000);
pChn->nInc = (ninc + 1) & ~3;
} else
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|