From: <sag...@us...> - 2010-03-08 17:44:26
|
Revision: 520 http://modplug.svn.sourceforge.net/modplug/?rev=520&view=rev Author: saga-games Date: 2010-03-08 17:44:16 +0000 (Mon, 08 Mar 2010) Log Message: ----------- [Fix] S3M Playback: In ST3, muted channels are completely ignored, not even effects are interpreted. Let's try this in MPT, too. [Fix] Pattern Editor: Find/Replace didn't work properly when replacing PC Notes with something that's not a PC Note. [Ref] Introduced a static version of IsPcNote() to get rid of all the "note == NOTE_PC || note == NOTE_PCS". [Ref] Some more refactoring Modified Paths: -------------- trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/mptrack/test/test.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndmix.cpp trunk/OpenMPT/soundlib/modcommand.h Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2010-03-08 14:26:04 UTC (rev 519) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2010-03-08 17:44:16 UTC (rev 520) @@ -1878,7 +1878,16 @@ if (m_cmdReplace.note == CFindReplaceTab::replaceNotePlusOne) { if (m->note < NOTE_MAX) m->note++; - } else m->note = m_cmdReplace.note; + } else + // Replace with another note + { + // If we're going to remove a PC Note, wipe out the complete column. + if(m->IsPcNote() && !MODCOMMAND::IsPcNote(m_cmdReplace.note)) + { + m->Clear(); + } + m->note = m_cmdReplace.note; + } } if ((m_dwReplaceFlags & PATSEARCH_INSTR)) { @@ -4155,7 +4164,7 @@ const bool bIsLiveRecord = IsLiveRecord(*pMainFrm, *pModDoc, *pSndFile); const bool usePlaybackPosition = (bIsLiveRecord && (CMainFrame::m_dwPatternSetup & PATTERN_AUTODELAY)); //Param control 'note' - if((note == NOTE_PC || note == NOTE_PCS) && bRecordEnabled) + if(MODCOMMAND::IsPcNote(note) && bRecordEnabled) { pModDoc->GetPatternUndo()->PrepareUndo(m_nPattern, nChn, nRow, 1, 1); pSndFile->Patterns[m_nPattern].GetpModCommand(nRow, nChn)->note = note; Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2010-03-08 14:26:04 UTC (rev 519) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2010-03-08 17:44:16 UTC (rev 520) @@ -1317,7 +1317,7 @@ { combo->ResetContent(); - if(m_nNote == NOTE_PC || m_nNote == NOTE_PCS) + if(MODCOMMAND::IsPcNote(m_nNote)) { // control plugin param note combo->SetItemData(combo->AddString("No Effect"), 0); @@ -1350,7 +1350,7 @@ void CPageEditNote::OnNoteChanged() //--------------------------------- { - bool bWasParamControl = (m_nNote == NOTE_PC || m_nNote == NOTE_PCS) ? true : false; + const bool bWasParamControl = MODCOMMAND::IsPcNote(m_nNote); CComboBox *combo; if ((combo = (CComboBox *)GetDlgItem(IDC_COMBO1)) != NULL) @@ -1374,7 +1374,7 @@ } } } - bool bIsNowParamControl = (m_nNote == NOTE_PC || m_nNote == NOTE_PCS) ? true : false; + const bool bIsNowParamControl = MODCOMMAND::IsPcNote(m_nNote); if(bWasParamControl != bIsNowParamControl) UpdateDialog(); Modified: trunk/OpenMPT/mptrack/test/test.cpp =================================================================== --- trunk/OpenMPT/mptrack/test/test.cpp 2010-03-08 14:26:04 UTC (rev 519) +++ trunk/OpenMPT/mptrack/test/test.cpp 2010-03-08 17:44:16 UTC (rev 520) @@ -189,6 +189,10 @@ VERIFY_EQUAL(ConvertStrTo<float>("-87.0"), -87.0); VERIFY_EQUAL(ConvertStrTo<double>("-0.5e-6"), -0.5e-6); VERIFY_EQUAL(ConvertStrTo<double>("58.65403492763"), 58.65403492763); + + VERIFY_EQUAL(MODCOMMAND::IsPcNote(NOTE_MAX), false); + VERIFY_EQUAL(MODCOMMAND::IsPcNote(NOTE_PC), true); + VERIFY_EQUAL(MODCOMMAND::IsPcNote(NOTE_PCS), true); } Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2010-03-08 14:26:04 UTC (rev 519) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2010-03-08 17:44:16 UTC (rev 520) @@ -86,7 +86,10 @@ // -> CODE#0022 // -> DESC="alternative BPM/Speed interpretation method" // UINT dwElapsedTime=0, nRow=0, nCurrentPattern=0, nNextPattern=0, nPattern=Order[0]; - UINT nRow=0, nCurrentPattern=0, nNextPattern=0, nPattern=Order[0]; + ROWINDEX nRow = 0; + ORDERINDEX nCurrentPattern = 0; + ORDERINDEX nNextPattern = 0; + PATTERNINDEX nPattern = Order[0]; DOUBLE dwElapsedTime=0.0; // -! NEW_FEATURE#0022 UINT nMusicSpeed=m_nDefaultSpeed, nMusicTempo=m_nDefaultTempo, nNextRow=0; @@ -94,10 +97,10 @@ LONG nGlbVol = m_nDefaultGlobalVolume, nOldGlbVolSlide = 0; BYTE samples[MAX_CHANNELS]; BYTE instr[MAX_CHANNELS]; - BYTE notes[MAX_CHANNELS]; + UINT notes[MAX_CHANNELS]; BYTE vols[MAX_CHANNELS]; BYTE oldparam[MAX_CHANNELS]; - BYTE chnvols[MAX_CHANNELS]; + UINT chnvols[MAX_CHANNELS]; DWORD patloop[MAX_CHANNELS]; memset(instr, 0, sizeof(instr)); @@ -107,7 +110,7 @@ memset(oldparam, 0, sizeof(oldparam)); memset(chnvols, 64, sizeof(chnvols)); memset(samples, 0, sizeof(samples)); - for (UINT icv=0; icv<m_nChannels; icv++) chnvols[icv] = ChnSettings[icv].nVolume; + for(CHANNELINDEX icv = 0; icv < m_nChannels; icv++) chnvols[icv] = ChnSettings[icv].nVolume; nMaxRow = m_nNextRow; nMaxPattern = m_nNextPattern; nCurrentPattern = nNextPattern = 0; @@ -206,7 +209,7 @@ if (!nRow) { for(UINT ipck = 0; ipck < m_nChannels; ipck++) - patloop[ipck] = dwElapsedTime; + patloop[ipck] = (DWORD)dwElapsedTime; } if (!bTotal) { @@ -224,8 +227,10 @@ MODCHANNEL *pChn = Chn; MODCOMMAND *p = Patterns[nPattern] + nRow * m_nChannels; MODCOMMAND *nextRow = NULL; - for (UINT nChn=0; nChn<m_nChannels; p++,pChn++, nChn++) if (*((DWORD *)p)) + for (CHANNELINDEX nChn = 0; nChn < m_nChannels; p++, pChn++, nChn++) if (*((DWORD *)p)) { + if((GetType() == MOD_TYPE_S3M) && (ChnSettings[nChn].dwFlags & CHN_MUTE) != 0) // not even effects are processed on muted S3M channels + continue; UINT command = p->command; UINT param = p->param; UINT note = p->note; @@ -237,7 +242,7 @@ // Position Jump case CMD_POSITIONJUMP: positionJumpOnThisRow=true; - nNextPattern = param; + nNextPattern = (ORDERINDEX)param; // see http://lpchip.com/modplug/viewtopic.php?t=2769 - FastTracker resets Dxx if Bxx is called _after_ Dxx if (!patternBreakOnThisRow || (GetType() == MOD_TYPE_XM)) { nNextRow = 0; @@ -283,7 +288,7 @@ case CMD_TEMPO: if ((bAdjust) && (m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT | MOD_TYPE_MPT))) { - if (param) pChn->nOldTempo = param; else param = pChn->nOldTempo; + if (param) pChn->nOldTempo = (BYTE)param; else param = pChn->nOldTempo; } if (param >= 0x20) nMusicTempo = param; else // Tempo Slide @@ -312,7 +317,7 @@ if ((param & 0xF0) == 0x60) { if (param & 0x0F) dwElapsedTime += (dwElapsedTime - patloop[nChn]) * (param & 0x0F); - else patloop[nChn] = dwElapsedTime; + else patloop[nChn] = (DWORD)dwElapsedTime; } break; case CMD_XFINEPORTAUPDOWN: @@ -1162,8 +1167,10 @@ // -> DESC="add extended parameter mechanism to pattern effects" MODCOMMAND* m = nullptr; // -! NEW_FEATURE#0010 - for (UINT nChn=0; nChn<m_nChannels; nChn++, pChn++) + for (CHANNELINDEX nChn = 0; nChn < m_nChannels; nChn++, pChn++) { + if((GetType() == MOD_TYPE_S3M) && (ChnSettings[nChn].dwFlags & CHN_MUTE) != 0) // not even effects are processed on muted S3M channels + continue; UINT instr = pChn->nRowInstr; UINT volcmd = pChn->nRowVolCmd; UINT vol = pChn->nRowVolume; @@ -1224,7 +1231,7 @@ // Apart from changing parameters, parameter control notes are intended to be 'invisible'. // To achieve this, clearing the note data so that rest of the process sees the row as empty row. - if(pChn->nRowNote == NOTE_PC || pChn->nRowNote == NOTE_PCS) + if(MODCOMMAND::IsPcNote(pChn->nRowNote)) { pChn->ClearRowCmd(); instr = 0; @@ -3980,4 +3987,4 @@ pChn->nOldFinePortaUpDown = abs(tickParam); pChn->m_CalculateFreq = true; -} +} \ No newline at end of file Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2010-03-08 14:26:04 UTC (rev 519) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2010-03-08 17:44:16 UTC (rev 520) @@ -1535,7 +1535,7 @@ df2 = LinearSlideDownTable[n1+1]; } n >>= 2; - period = _muldiv(period, df1 + ((df2-df1)*(n&0x3F)>>6), 256); + period = _muldiv(period, df1 + ((df2 - df1) * (n & 0x3F) >> 6), 256); nPeriodFrac = period & 0xFF; period >>= 8; } else @@ -1962,7 +1962,7 @@ // Previously this function took modcommand directly from pattern. ASSERT is there // to detect possible behaviour change now that the data is accessed from channel. const MODCOMMAND mc = *Patterns[m_nPattern].GetpModCommand(m_nRow, static_cast<CHANNELINDEX>(nChn)); - ASSERT( mc.note == NOTE_PC || mc.note == NOTE_PCS || + ASSERT( mc.IsPcNote() || (note == mc.note && instr == mc.instr && volcmd == mc.volcmd && vol == mc.vol)); } @@ -2122,4 +2122,3 @@ } } - Modified: trunk/OpenMPT/soundlib/modcommand.h =================================================================== --- trunk/OpenMPT/soundlib/modcommand.h 2010-03-08 14:26:04 UTC (rev 519) +++ trunk/OpenMPT/soundlib/modcommand.h 2010-03-08 17:44:16 UTC (rev 520) @@ -59,6 +59,7 @@ // Returns true if and only if note is NOTE_PC or NOTE_PCS. bool IsPcNote() const {return note == NOTE_PC || note == NOTE_PCS;} + static bool IsPcNote(MODCOMMAND::NOTE note_id) {return note_id == NOTE_PC || note_id == NOTE_PCS;} // Swap volume and effect column (doesn't do any conversion as it's mainly for importing formats with multiple effect columns, so beware!) void SwapEffects() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |