From: <sag...@us...> - 2011-07-31 13:13:30
|
Revision: 950 http://modplug.svn.sourceforge.net/modplug/?rev=950&view=rev Author: saga-games Date: 2011-07-31 13:13:23 +0000 (Sun, 31 Jul 2011) Log Message: ----------- [Fix] Pattern interpolation broke in revision 944 [Mod] OpenMPT: Version is now 1.20.00.01 Revision Links: -------------- http://modplug.svn.sourceforge.net/modplug/?rev=944&view=rev Modified Paths: -------------- trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_pat.h trunk/OpenMPT/mptrack/version.h Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2011-07-31 12:02:15 UTC (rev 949) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2011-07-31 13:13:23 UTC (rev 950) @@ -617,7 +617,7 @@ } -BOOL CViewPattern::PrepareUndo(DWORD dwBegin, DWORD dwEnd) +bool CViewPattern::PrepareUndo(DWORD dwBegin, DWORD dwEnd) //-------------------------------------------------------- { CModDoc *pModDoc = GetDocument(); @@ -627,9 +627,8 @@ nRowBeg = GetRowFromCursor(dwBegin); nChnEnd = GetChanFromCursor(dwEnd); nRowEnd = GetRowFromCursor(dwEnd); - if( (nChnEnd < nChnBeg) || (nRowEnd < nRowBeg) ) return FALSE; - if (pModDoc) return pModDoc->GetPatternUndo()->PrepareUndo(m_nPattern, nChnBeg, nRowBeg, nChnEnd-nChnBeg+1, nRowEnd-nRowBeg+1); - return FALSE; + if((nChnEnd < nChnBeg) || (nRowEnd < nRowBeg) || pModDoc == nullptr) return false; + return pModDoc->GetPatternUndo()->PrepareUndo(m_nPattern, nChnBeg, nRowBeg, nChnEnd-nChnBeg+1, nRowEnd-nRowBeg+1); } @@ -2388,9 +2387,7 @@ bool doPCinterpolation = false; - int vsrc, vdest, vcmd = 0, verr = 0; - ASSERT(row1 >= row0); - UINT distance = row1 - row0; + int vsrc, vdest, vcmd = 0, verr = 0, distance = row1 - row0; const MODCOMMAND srcCmd = *pSndFile->Patterns[m_nPattern].GetpModCommand(row0, nchn); const MODCOMMAND destCmd = *pSndFile->Patterns[m_nPattern].GetpModCommand(row1, nchn); @@ -2404,7 +2401,7 @@ vsrc = srcCmd.note; vdest = destCmd.note; vcmd = srcCmd.instr; - verr = (distance * 59) / NOTE_MAX; + verr = (distance * (NOTE_MAX - 1)) / NOTE_MAX; break; case VOL_COLUMN: vsrc = srcCmd.vol; @@ -2459,19 +2456,23 @@ MODCOMMAND* pcmd = pSndFile->Patterns[m_nPattern].GetpModCommand(row0, nchn); - for (UINT i=0; i<=distance; i++, pcmd += pSndFile->m_nChannels) { + for (int i = 0; i <= distance; i++, pcmd += pSndFile->GetNumChannels()) + { - switch(type) { + switch(type) + { case NOTE_COLUMN: - if ((!pcmd->note) || (pcmd->instr == vcmd)) { - int note = vsrc + ((vdest - vsrc) * (int)i + verr) / distance; + if ((!pcmd->note) || (pcmd->instr == vcmd)) + { + int note = vsrc + ((vdest - vsrc) * i + verr) / distance; pcmd->note = (BYTE)note; pcmd->instr = vcmd; } break; case VOL_COLUMN: - if ((!pcmd->volcmd) || (pcmd->volcmd == vcmd)) { - int vol = vsrc + ((vdest - vsrc) * (int)i + verr) / distance; + if ((!pcmd->volcmd) || (pcmd->volcmd == vcmd)) + { + int vol = vsrc + ((vdest - vsrc) * i + verr) / distance; pcmd->vol = (BYTE)vol; pcmd->volcmd = vcmd; } @@ -2480,7 +2481,7 @@ if(doPCinterpolation) { // With PC/PCs notes, copy PCs note and plug index to all rows where // effect interpolation is done if no PC note with non-zero instrument is there. - const uint16 val = static_cast<uint16>(vsrc + ((vdest - vsrc) * (int)i + verr) / distance); + const uint16 val = static_cast<uint16>(vsrc + ((vdest - vsrc) * i + verr) / distance); if (pcmd->IsPcNote() == false || pcmd->instr == 0) { pcmd->note = PCnote; @@ -2493,7 +2494,7 @@ { if ((!pcmd->command) || (pcmd->command == vcmd)) { - int val = vsrc + ((vdest - vsrc) * (int)i + verr) / distance; + int val = vsrc + ((vdest - vsrc) * i + verr) / distance; pcmd->param = (BYTE)val; pcmd->command = vcmd; } @@ -2508,7 +2509,8 @@ } //end for all channels where type is selected - if (changed) { + if (changed) + { pModDoc->SetModified(); InvalidatePattern(FALSE); } @@ -2870,8 +2872,6 @@ if (pSndFile->Patterns[m_nPattern]) { - MODCOMMAND *p = pSndFile->Patterns[m_nPattern]; - CHANNELINDEX firstChannel = GetSelectionStartChan(), lastChannel = GetSelectionEndChan(); ROWINDEX firstRow = GetSelectionStartRow(), lastRow = GetSelectionEndRow(); firstChannel = CLAMP(firstChannel, 0, pSndFile->GetNumChannels() - 1); @@ -2906,7 +2906,7 @@ for (ROWINDEX nRow = firstRow; nRow <= lastRow; nRow++) { - MODCOMMAND *m = p + nRow * pSndFile->m_nChannels + firstChannel; + MODCOMMAND *m = pSndFile->Patterns[m_nPattern].GetpModCommand(nRow, firstChannel); for (CHANNELINDEX nChn = firstChannel; nChn <= lastChannel; nChn++, m++) { if ((m->command == CMD_VOLUME) && (m->param <= 64)) @@ -2922,9 +2922,9 @@ if ((m->note) && (m->note <= NOTE_MAX) && (m->instr)) { UINT nSmp = m->instr; - if (pSndFile->m_nInstruments) + if (pSndFile->GetNumInstruments()) { - if ((nSmp <= pSndFile->m_nInstruments) && (pSndFile->Instruments[nSmp])) + if ((nSmp <= pSndFile->GetNumInstruments()) && (pSndFile->Instruments[nSmp])) { nSmp = pSndFile->Instruments[nSmp]->Keyboard[m->note]; if(!nSmp) chvol[nChn] = 64; // hack for instruments without samples @@ -2933,7 +2933,7 @@ nSmp = 0; } } - if ((nSmp) && (nSmp <= pSndFile->m_nSamples)) + if ((nSmp) && (nSmp <= pSndFile->GetNumSamples())) { chvol[nChn] = (BYTE)(pSndFile->Samples[nSmp].nVolume >> 2); break; @@ -2958,7 +2958,7 @@ for (ROWINDEX nRow = firstRow; nRow <= lastRow; nRow++) { - MODCOMMAND *m = p + nRow * pSndFile->m_nChannels + firstChannel; + MODCOMMAND *m = pSndFile->Patterns[m_nPattern].GetpModCommand(nRow, firstChannel); const int cy = lastRow - firstRow + 1; // total rows (for fading) for (CHANNELINDEX nChn = firstChannel; nChn <= lastChannel; nChn++, m++) { Modified: trunk/OpenMPT/mptrack/View_pat.h =================================================================== --- trunk/OpenMPT/mptrack/View_pat.h 2011-07-31 12:02:15 UTC (rev 949) +++ trunk/OpenMPT/mptrack/View_pat.h 2011-07-31 13:13:23 UTC (rev 950) @@ -196,7 +196,7 @@ void SelectBeatOrMeasure(bool selectBeat); BOOL TransposeSelection(int transp); - BOOL PrepareUndo(DWORD dwBegin, DWORD dwEnd); + bool PrepareUndo(DWORD dwBegin, DWORD dwEnd); void DeleteRows(UINT colmin, UINT colmax, UINT nrows); void OnDropSelection(); void ProcessChar(UINT nChar, UINT nFlags); Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-07-31 12:02:15 UTC (rev 949) +++ trunk/OpenMPT/mptrack/version.h 2011-07-31 13:13:23 UTC (rev 950) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 00 +#define VER_MINORMINOR 01 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |