From: <sag...@us...> - 2013-05-21 21:19:04
|
Revision: 2165 http://sourceforge.net/p/modplug/code/2165 Author: saga-games Date: 2013-05-21 21:18:58 +0000 (Tue, 21 May 2013) Log Message: ----------- [Fix] FT2 compatibility: Also limit period values to 16-bit in Amiga slide mode (not 100% precise yet as it seems, but uh, "close enough", I guess.) Modified Paths: -------------- trunk/OpenMPT/soundlib/Snd_fx.cpp Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-05-21 21:18:34 UTC (rev 2164) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-05-21 21:18:58 UTC (rev 2165) @@ -4691,17 +4691,23 @@ return ((3546895L * 4) << FREQ_FRACBITS) / period; } else if (GetType() == MOD_TYPE_XM) { + if(IsCompatibleMode(TRK_FASTTRACKER2)) + { + // FT2 compatibility: Period is a 16-bit value in FT2, and it overflows happily. + // Test case: FreqWraparound.xm + period &= 0xFFFF; + } if(m_SongFlags[SONG_LINEARSLIDES]) { 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... + // However, once the 12 octaves are exceeded (through portamento slides), the octave shift goes + // crazy in FT2, meaning that the frequency wraps around randomly... // 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); + uint32 div = ((9216u + 767u - period) / 768); octave = ((12 - div) & 0x1F) % 29u; } return (XMLinearTable[period % 768] << FREQ_FRACBITS) >> octave; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |