|
From: <sag...@us...> - 2012-01-04 00:30:56
|
Revision: 1159
http://modplug.svn.sourceforge.net/modplug/?rev=1159&view=rev
Author: saga-games
Date: 2012-01-04 00:30:49 +0000 (Wed, 04 Jan 2012)
Log Message:
-----------
[Imp] IT / MPTM Loading: Slide command parameters (Dxx etc) are now sanitized while loading, so in normal playback mode they are now treated exactly like in compatible mode.
[Mod] Playback: Changed 4-Bit panning computation a bit, so that f.e. S80 is true left and S8F is true right.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2012-01-03 23:44:56 UTC (rev 1158)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2012-01-04 00:30:49 UTC (rev 1159)
@@ -2761,7 +2761,7 @@
// IT compatibility: Ignore slide commands with both nibbles set.
if (param & 0x0F)
{
- if(!IsCompatibleMode(TRK_IMPULSETRACKER) || (param & 0xF0) == 0)
+ if(!(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) || (param & 0xF0) == 0)
newvolume -= (int)((param & 0x0F) * 4);
}
else
@@ -2807,7 +2807,7 @@
if (param & 0x0F)
{
// IT compatibility: Ignore slide commands with both nibbles set.
- if(!IsCompatibleMode(TRK_IMPULSETRACKER) || (param & 0xF0) == 0)
+ if(!(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) || (param & 0xF0) == 0)
nPanSlide = (int)((param & 0x0F) << 2);
} else
{
@@ -2894,7 +2894,7 @@
{
if (param & 0x0F)
{
- if(!IsCompatibleMode(TRK_IMPULSETRACKER) || (param & 0xF0) == 0)
+ if(!(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) || (param & 0xF0) == 0)
nChnSlide = -(int)(param & 0x0F);
} else
{
@@ -2948,7 +2948,9 @@
{
if (!(m_dwSongFlags & SONG_SURROUNDPAN)) pChn->dwFlags &= ~CHN_SURROUND;
}
- pChn->nPan = (param << 4) + 8; pChn->dwFlags |= CHN_FASTVOLRAMP;
+ //pChn->nPan = (param << 4) + 8;
+ pChn->nPan = (param * 256 + 8) / 15;
+ pChn->dwFlags |= CHN_FASTVOLRAMP;
}
break;
// E9x: Retrig
@@ -3101,7 +3103,9 @@
{
if (!(m_dwSongFlags & SONG_SURROUNDPAN)) pChn->dwFlags &= ~CHN_SURROUND;
}
- pChn->nPan = (param << 4) + 8; pChn->dwFlags |= CHN_FASTVOLRAMP;
+ //pChn->nPan = (param << 4) + 8;
+ pChn->nPan = (param * 256 + 8) / 15;
+ pChn->dwFlags |= CHN_FASTVOLRAMP;
//IT compatibility 20. Set pan overrides random pan
if(IsCompatibleMode(TRK_IMPULSETRACKER))
@@ -4053,7 +4057,7 @@
if (param & 0xF0)
{
// IT compatibility: Ignore slide commands with both nibbles set.
- if(!IsCompatibleMode(TRK_IMPULSETRACKER) || (param & 0x0F) == 0)
+ if(!(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) || (param & 0x0F) == 0)
nGlbSlide = (int)((param & 0xF0) >> 4) * 2;
} else
{
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2012-01-03 23:44:56 UTC (rev 1158)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2012-01-04 00:30:49 UTC (rev 1159)
@@ -663,26 +663,20 @@
lpStream = NULL;
}
#endif
- } else {
+ } else
+ {
// New song
m_dwCreatedWithVersion = MptVersion::num;
}
// Adjust song / sample names
- for (UINT iSmp=0; iSmp<MAX_SAMPLES; iSmp++)
+ for(SAMPLEINDEX iSmp = 0; iSmp <= GetNumSamples(); iSmp++)
{
- LPSTR p = m_szNames[iSmp];
- int j = 31;
- p[j] = 0;
- while ((j>=0) && (p[j]<=' ')) p[j--] = 0;
- while (j>=0)
- {
- if (((BYTE)p[j]) < ' ') p[j] = ' ';
- j--;
- }
+ StringFixer::SetNullTerminator(m_szNames[iSmp]);
}
+
// Adjust channels
- for (UINT ich=0; ich<MAX_BASECHANNELS; ich++)
+ for(CHANNELINDEX ich = 0; ich < MAX_BASECHANNELS; ich++)
{
if (ChnSettings[ich].nVolume > 64) ChnSettings[ich].nVolume = 64;
if (ChnSettings[ich].nPan > 256) ChnSettings[ich].nPan = 128;
@@ -700,18 +694,18 @@
}
// Checking samples
MODSAMPLE *pSmp = Samples;
- for (SAMPLEINDEX nSmp = 0; nSmp < MAX_SAMPLES; nSmp++, pSmp++)
+ for(SAMPLEINDEX nSmp = 0; nSmp < MAX_SAMPLES; nSmp++, pSmp++)
{
- if (pSmp->pSample)
+ if(pSmp->pSample)
{
- if (pSmp->nLoopEnd > pSmp->nLength) pSmp->nLoopEnd = pSmp->nLength;
- if (pSmp->nLoopStart >= pSmp->nLoopEnd)
+ if(pSmp->nLoopEnd > pSmp->nLength) pSmp->nLoopEnd = pSmp->nLength;
+ if(pSmp->nLoopStart >= pSmp->nLoopEnd)
{
pSmp->nLoopStart = 0;
pSmp->nLoopEnd = 0;
}
- if (pSmp->nSustainEnd > pSmp->nLength) pSmp->nSustainEnd = pSmp->nLength;
- if (pSmp->nSustainStart >= pSmp->nSustainEnd)
+ if(pSmp->nSustainEnd > pSmp->nLength) pSmp->nSustainEnd = pSmp->nLength;
+ if(pSmp->nSustainStart >= pSmp->nSustainEnd)
{
pSmp->nSustainStart = 0;
pSmp->nSustainEnd = 0;
@@ -724,9 +718,9 @@
pSmp->nSustainStart = 0;
pSmp->nSustainEnd = 0;
}
- if (!pSmp->nLoopEnd) pSmp->uFlags &= ~(CHN_LOOP|CHN_PINGPONGLOOP);
- if (!pSmp->nSustainEnd) pSmp->uFlags &= ~(CHN_SUSTAINLOOP|CHN_PINGPONGSUSTAIN);
- if (pSmp->nGlobalVol > 64) pSmp->nGlobalVol = 64;
+ if(!pSmp->nLoopEnd) pSmp->uFlags &= ~(CHN_LOOP|CHN_PINGPONGLOOP);
+ if(!pSmp->nSustainEnd) pSmp->uFlags &= ~(CHN_SUSTAINLOOP|CHN_PINGPONGSUSTAIN);
+ if(pSmp->nGlobalVol > 64) pSmp->nGlobalVol = 64;
}
// Check invalid instruments
while ((m_nInstruments > 0) && (!Instruments[m_nInstruments])) m_nInstruments--;
@@ -2996,6 +2990,31 @@
}
}
+ if((pSndFile->GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)))
+ {
+ // In the IT format, slide commands with both nibbles set should be ignored.
+ // For note volume slides, OpenMPT 1.18 fixes this in compatible mode, OpenMPT 1.20 fixes this in normal mode as well.
+ const bool noteVolSlide =
+ (pSndFile->m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 18, 00, 00) ||
+ (!pSndFile->IsCompatibleMode(TRK_IMPULSETRACKER) && pSndFile->m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 00)))
+ &&
+ (m.command == CMD_VOLUMESLIDE || m.command == CMD_VIBRATOVOL || m.command == CMD_TONEPORTAVOL || m.command == CMD_PANNINGSLIDE);
+
+ // OpenMPT 1.20 also fixes this for global volume and channel volume slides.
+ const bool chanVolSlide =
+ (pSndFile->m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 00))
+ &&
+ (m.command == CMD_GLOBALVOLSLIDE || m.command == CMD_CHANNELVOLSLIDE);
+
+ if(noteVolSlide || chanVolSlide)
+ {
+ if((m.param & 0x0F) != 0x00 && (m.param & 0x0F) != 0x0F && (m.param & 0xF0) != 0x00 && (m.param & 0xF0) != 0xF0)
+ {
+ m.param &= 0x0F;
+ }
+ }
+ }
+
if(pSndFile->GetType() == MOD_TYPE_XM)
{
if(pSndFile->m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 19, 00, 00) ||
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|