From: <sag...@us...> - 2011-04-11 16:44:14
|
Revision: 845 http://modplug.svn.sourceforge.net/modplug/?rev=845&view=rev Author: saga-games Date: 2011-04-11 16:44:07 +0000 (Mon, 11 Apr 2011) Log Message: ----------- [Ref] TryWriteEffect can now also try to write an effect on a previous row if there's no space left on the current row [Fix] MPT hack detector: It was possible that the log said "no hacks found" if only invalid pattern commands were found. [Fix] IT Compatibility: Panning slides with both parameter nibbles set were not ignored. Modified Paths: -------------- trunk/OpenMPT/mptrack/MPTHacks.cpp trunk/OpenMPT/mptrack/ModConvert.cpp trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/soundlib/Load_psm.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/modcommand.cpp Modified: trunk/OpenMPT/mptrack/MPTHacks.cpp =================================================================== --- trunk/OpenMPT/mptrack/MPTHacks.cpp 2011-04-09 17:16:43 UTC (rev 844) +++ trunk/OpenMPT/mptrack/MPTHacks.cpp 2011-04-11 16:44:07 UTC (rev 845) @@ -157,7 +157,10 @@ foundHere = false; m_SndFile.Patterns.ForEachModCommand(FixHackedPatterns(originalSpecs, m_SndFile.GetType(), autofix, &foundHere)); if(foundHere) + { AddToLog("Found invalid pattern commands\n"); + foundHacks = true; + } // Check for pattern names foundHere = false; Modified: trunk/OpenMPT/mptrack/ModConvert.cpp =================================================================== --- trunk/OpenMPT/mptrack/ModConvert.cpp 2011-04-09 17:16:43 UTC (rev 844) +++ trunk/OpenMPT/mptrack/ModConvert.cpp 2011-04-11 16:44:07 UTC (rev 845) @@ -141,7 +141,7 @@ // try to save short patterns by inserting a pattern break. if(m_SndFile.Patterns[nPat].GetNumRows() < 64) { - m_SndFile.TryWriteEffect(nPat, m_SndFile.Patterns[nPat].GetNumRows() - 1, CMD_PATTERNBREAK, 0, false, CHANNELINDEX_INVALID, false, true); + m_SndFile.TryWriteEffect(nPat, m_SndFile.Patterns[nPat].GetNumRows() - 1, CMD_PATTERNBREAK, 0, false, CHANNELINDEX_INVALID, false, weTryNextRow); } m_SndFile.Patterns[nPat].Resize(64, false); CHANGEMODTYPE_WARNING(wResizedPatterns); @@ -246,7 +246,7 @@ } if(addBreak) { - m_SndFile.TryWriteEffect(nPat, m_SndFile.Patterns[nPat].GetNumRows() - 1, CMD_PATTERNBREAK, 0, false, CHANNELINDEX_INVALID, false, false); + m_SndFile.TryWriteEffect(nPat, m_SndFile.Patterns[nPat].GetNumRows() - 1, CMD_PATTERNBREAK, 0, false, CHANNELINDEX_INVALID, false, weIgnore); } } Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2011-04-09 17:16:43 UTC (rev 844) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2011-04-11 16:44:07 UTC (rev 845) @@ -1282,7 +1282,7 @@ GetLengthType length = m_SndFile.GetLength(eNoAdjust); if(length.endOrder != ORDERINDEX_INVALID && length.endRow != ROWINDEX_INVALID) { - result = m_SndFile.TryWriteEffect(m_SndFile.Order[length.endOrder], length.endRow, CMD_POSITIONJUMP, m_SndFile.m_nRestartPos, false, CHANNELINDEX_INVALID, false, true); + result = m_SndFile.TryWriteEffect(m_SndFile.Order[length.endOrder], length.endRow, CMD_POSITIONJUMP, m_SndFile.m_nRestartPos, false, CHANNELINDEX_INVALID, false, weTryNextRow); } m_SndFile.m_nRestartPos = 0; return result; Modified: trunk/OpenMPT/soundlib/Load_psm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_psm.cpp 2011-04-09 17:16:43 UTC (rev 844) +++ trunk/OpenMPT/soundlib/Load_psm.cpp 2011-04-11 16:44:07 UTC (rev 845) @@ -775,14 +775,14 @@ for(CHANNELINDEX nChn = 0; nChn < m_nChannels; nChn++) { if(subsongs[i].channelSurround[nChn] == true) - TryWriteEffect(startPattern, 0, CMD_S3MCMDEX, 0x91, false, nChn, false, true); + TryWriteEffect(startPattern, 0, CMD_S3MCMDEX, 0x91, false, nChn, false, weTryNextRow); else - TryWriteEffect(startPattern, 0, CMD_PANNING8, subsongs[i].channelPanning[nChn], false, nChn, false, true); + TryWriteEffect(startPattern, 0, CMD_PANNING8, subsongs[i].channelPanning[nChn], false, nChn, false, weTryNextRow); } } // write default tempo/speed to pattern - TryWriteEffect(startPattern, 0, CMD_SPEED, subsongs[i].defaultSpeed, false, CHANNELINDEX_INVALID, false, true); - TryWriteEffect(startPattern, 0, CMD_TEMPO, subsongs[i].defaultTempo, false, CHANNELINDEX_INVALID, false, true); + TryWriteEffect(startPattern, 0, CMD_SPEED, subsongs[i].defaultSpeed, false, CHANNELINDEX_INVALID, false, weTryNextRow); + TryWriteEffect(startPattern, 0, CMD_TEMPO, subsongs[i].defaultTempo, false, CHANNELINDEX_INVALID, false, weTryNextRow); // don't write channel volume for now, as it's always set to 100% anyway @@ -800,7 +800,7 @@ break; } } - TryWriteEffect(endPattern, lastRow, CMD_POSITIONJUMP, (BYTE)subsongs[i].restartPos, false, CHANNELINDEX_INVALID, false, true); + TryWriteEffect(endPattern, lastRow, CMD_POSITIONJUMP, (BYTE)subsongs[i].restartPos, false, CHANNELINDEX_INVALID, false, weTryNextRow); } } } @@ -1194,7 +1194,7 @@ } // Pattern break for short patterns (so saving the modules as S3M won't break it) if(phdr->numRows != 64) - TryWriteEffect(nPat, phdr->numRows - 1, CMD_PATTERNBREAK, 0, false, CHANNELINDEX_INVALID, false, false); + TryWriteEffect(nPat, phdr->numRows - 1, CMD_PATTERNBREAK, 0, false, CHANNELINDEX_INVALID, false, weTryNextRow); dwMemPos = dwNextPattern; if(dwMemPos > dwPatEndPos) break; Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-04-09 17:16:43 UTC (rev 844) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-04-11 16:44:07 UTC (rev 845) @@ -2643,8 +2643,15 @@ { if (!(m_dwSongFlags & SONG_FIRSTTICK)) { - if (param & 0x0F) nPanSlide = (int)((param & 0x0F) << 2); - else nPanSlide = -(int)((param & 0xF0) >> 2); + if (param & 0x0F) + { + if(!IsCompatibleMode(TRK_IMPULSETRACKER) || (param & 0xF0) == 0) + nPanSlide = (int)((param & 0x0F) << 2); + } else + { + if(!IsCompatibleMode(TRK_IMPULSETRACKER) || (param & 0x0F) == 0) + nPanSlide = -(int)((param & 0xF0) >> 2); + } } } } else @@ -2654,13 +2661,11 @@ // IT compatibility: Ignore slide commands with both nibbles set. if (param & 0x0F) { - if(!IsCompatibleMode(TRK_IMPULSETRACKER) || (param & 0xF0) == 0) - nPanSlide = -(int)((param & 0x0F) << 2); + nPanSlide = -(int)((param & 0x0F) << 2); } else { - if(!IsCompatibleMode(TRK_IMPULSETRACKER) || (param & 0x0F) == 0) - nPanSlide = (int)((param & 0xF0) >> 2); + nPanSlide = (int)((param & 0xF0) >> 2); } // XM compatibility: FT2's panning slide is not as deep if(IsCompatibleMode(TRK_FASTTRACKER2)) @@ -3157,7 +3162,7 @@ pChn->m_nPlugParamValueStep = (float)((int)dwParam - pChn->m_nPlugInitialParamValue) / (float)m_nMusicSpeed; } //update param on all ticks - pChn->nCutOff = (BYTE) (pChn->m_nPlugInitialParamValue + (m_nTickCount + 1 ) *pChn->m_nPlugParamValueStep + 0.5); + pChn->nCutOff = (BYTE) (pChn->m_nPlugInitialParamValue + (m_nTickCount + 1) * pChn->m_nPlugParamValueStep + 0.5); } pChn->nRestoreCutoffOnNewNote = 0; } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2011-04-09 17:16:43 UTC (rev 844) +++ trunk/OpenMPT/soundlib/Sndfile.h 2011-04-11 16:44:07 UTC (rev 845) @@ -511,6 +511,15 @@ }; +// Row advance mode for TryWriteEffect() +enum writeEffectAllowRowChange +{ + weIgnore, // If effect can't be written, abort. + weTryNextRow, // If effect can't be written, try next row. + weTryPreviousRow, // If effect can't be written, try previous row. +}; + + //Note: These are bit indeces. MSF <-> Mod(Specific)Flag. //If changing these, ChangeModTypeTo() might need modification. const BYTE MSF_COMPATIBLE_PLAY = 0; //IT/MPT/XM @@ -922,7 +931,7 @@ UINT GetNumTicksOnCurrentRow() { return m_nMusicSpeed * (m_nPatternDelay + 1) + m_nFrameDelay; }; public: // Write pattern effect functions - bool TryWriteEffect(PATTERNINDEX nPat, ROWINDEX nRow, BYTE nEffect, BYTE nParam, bool bIsVolumeEffect, CHANNELINDEX nChn = CHANNELINDEX_INVALID, bool bAllowMultipleEffects = true, bool bAllowNextRow = false, bool bRetry = true); + bool TryWriteEffect(PATTERNINDEX nPat, ROWINDEX nRow, BYTE nEffect, BYTE nParam, bool bIsVolumeEffect, CHANNELINDEX nChn = CHANNELINDEX_INVALID, bool bAllowMultipleEffects = true, writeEffectAllowRowChange allowRowChange = weIgnore, bool bRetry = true); // Read/Write sample functions char GetDeltaValue(char prev, UINT n) const { return (char)(prev + CompressionTable[n & 0x0F]); } Modified: trunk/OpenMPT/soundlib/modcommand.cpp =================================================================== --- trunk/OpenMPT/soundlib/modcommand.cpp 2011-04-09 17:16:43 UTC (rev 844) +++ trunk/OpenMPT/soundlib/modcommand.cpp 2011-04-11 16:44:07 UTC (rev 845) @@ -674,12 +674,12 @@ bIsVolumeEffect - Indicates whether the given effect is a volume column effect or not nChn - Channel that should be modified - use CHANNELINDEX_INVALID to allow all channels of the given row bAllowMultipleEffects - If false, No effect will be written if an effect of the same type is already present in the channel(s). Useful for f.e. tempo effects. - bAllowNextRow - Indicates whether it is allowed to use the next row if there's no space for the effect + allowRowChange - Indicates whether it is allowed to use the next or previous row if there's no space for the effect bRetry - For internal use only. Indicates whether an effect "rewrite" has already taken place (for recursive calls) NOTE: Effect remapping is only implemented for a few basic effects. */ -bool CSoundFile::TryWriteEffect(PATTERNINDEX nPat, ROWINDEX nRow, BYTE nEffect, BYTE nParam, bool bIsVolumeEffect, CHANNELINDEX nChn, bool bAllowMultipleEffects, bool bAllowNextRow, bool bRetry) -//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +bool CSoundFile::TryWriteEffect(PATTERNINDEX nPat, ROWINDEX nRow, BYTE nEffect, BYTE nParam, bool bIsVolumeEffect, CHANNELINDEX nChn, bool bAllowMultipleEffects, writeEffectAllowRowChange allowRowChange, bool bRetry) +//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- { // First, reject invalid parameters. if(!Patterns.IsValidIndex(nPat) || nRow >= Patterns[nPat].GetNumRows() || (nChn >= GetNumChannels() && nChn != CHANNELINDEX_INVALID)) @@ -810,14 +810,17 @@ } if(nNewEffect != CMD_NONE) { - if(TryWriteEffect(nPat, nRow, nNewEffect, nParam, !bIsVolumeEffect, nChn, bAllowMultipleEffects, bAllowNextRow, false) == true) return true; + if(TryWriteEffect(nPat, nRow, nNewEffect, nParam, !bIsVolumeEffect, nChn, bAllowMultipleEffects, allowRowChange, false) == true) return true; } } // Try in the next row if possible (this may also happen if we already retried) - if(bAllowNextRow && (nRow + 1 < Patterns[nPat].GetNumRows())) + if(allowRowChange == weTryNextRow && (nRow + 1 < Patterns[nPat].GetNumRows())) { - return TryWriteEffect(nPat, nRow + 1, nEffect, nParam, bIsVolumeEffect, nChn, bAllowMultipleEffects, bAllowNextRow, bRetry); + return TryWriteEffect(nPat, nRow + 1, nEffect, nParam, bIsVolumeEffect, nChn, bAllowMultipleEffects, allowRowChange, bRetry); + } else if(allowRowChange == weTryPreviousRow && (nRow > 0)) + { + return TryWriteEffect(nPat, nRow - 1, nEffect, nParam, bIsVolumeEffect, nChn, bAllowMultipleEffects, allowRowChange, bRetry); } return false; @@ -859,7 +862,7 @@ { // hack for people who can't type F twice :) *e = VOLCMD_TONEPORTAMENTO; - *p = 0xFF; + *p = 9; return true; } for (uint8 n = 0; n < 10; n++) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |