From: <sag...@us...> - 2011-04-29 21:32:36
|
Revision: 860 http://modplug.svn.sourceforge.net/modplug/?rev=860&view=rev Author: saga-games Date: 2011-04-29 21:32:29 +0000 (Fri, 29 Apr 2011) Log Message: ----------- [Fix] Orderlist info text truncates order list length after first "---" pattern for MOD files in hex display mode as well. [Fix] "+++" separator patterns were allowed in MOD files, which made them break in other trackers / players. [Fix] MIDI Macros are now sanitized when being loaded from files (malicious macros didn't seem to result in crashes, but let's be safe here) [Ref] Some more refactoring Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_seq.cpp trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_pat.h trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_itp.cpp trunk/OpenMPT/soundlib/Load_mod.cpp trunk/OpenMPT/soundlib/Load_xm.cpp trunk/OpenMPT/soundlib/Sampleio.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/mod_specifications.h Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2011-04-19 20:43:50 UTC (rev 859) +++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2011-04-29 21:32:29 UTC (rev 860) @@ -711,21 +711,22 @@ //------------------------------- { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - if ((pMainFrm) && (m_pModDoc) && (::GetFocus() == m_hWnd)) + CSoundFile *pSndFile; + if ((pMainFrm != nullptr) && (m_pModDoc != nullptr) && (pSndFile = m_pModDoc->GetSoundFile()) != nullptr && (::GetFocus() == m_hWnd)) { CHAR s[128]; - CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); + strcpy(s, ""); - s[0] = 0; + // MOD orderlist always ends after first empty pattern + const ORDERINDEX nLength = (pSndFile->GetType() & MOD_TYPE_MOD) ? pSndFile->Order.GetLengthFirstEmpty() : pSndFile->Order.GetLengthTailTrimmed(); + if(CMainFrame::m_dwPatternSetup & PATTERN_HEXDISPLAY) { - wsprintf(s, "Position %02Xh of %02Xh", m_nScrollPos, pSndFile->Order.GetLengthTailTrimmed()); + wsprintf(s, "Position %02Xh of %02Xh", m_nScrollPos, nLength); } else { - const ORDERINDEX nLength = pSndFile->Order.GetLengthTailTrimmed(); - wsprintf(s, "Position %d of %d (%02Xh of %02Xh)", - m_nScrollPos, nLength, m_nScrollPos, nLength); + wsprintf(s, "Position %d of %d (%02Xh of %02Xh)", m_nScrollPos, nLength, m_nScrollPos, nLength); } if (m_nScrollPos < pSndFile->Order.GetLength()) Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2011-04-19 20:43:50 UTC (rev 859) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2011-04-29 21:32:29 UTC (rev 860) @@ -860,7 +860,9 @@ tx_col = MODCOLOR_TEXTSELECTED; bk_col = MODCOLOR_BACKSELECTED; } - if ((!*((LPDWORD)m)) && (!*(((LPWORD)m)+2)) && ((!col_sel) || (col_sel == 0x1F))) + // Speedup: Empty command which is either not or fully selected + //if ((!*((LPDWORD)m)) && (!*(((LPWORD)m)+2)) && ((!col_sel) || (col_sel == 0x1F))) + if (m->IsEmpty() && ((!col_sel) || (col_sel == 0x1F))) { m_Dib.SetTextColor(tx_col, bk_col); m_Dib.TextBlt(xbmp, 0, nColumnWidth-4, m_szCell.cy, pfnt->nClrX, pfnt->nClrY); @@ -875,7 +877,7 @@ if ((CMainFrame::m_dwPatternSetup & PATTERN_EFFECTHILIGHT) && (m->note) && (m->note <= NOTE_MAX)) { tx_col = MODCOLOR_NOTE; - // Highlight notes that are not supported by the Amiga + // Highlight notes that are not supported by the Amiga (for S3M this is not always correct) if((pSndFile->m_dwSongFlags & (SONG_PT1XMODE|SONG_AMIGALIMITS)) && (m->note < NOTE_MIDDLEC - 12 || m->note >= NOTE_MIDDLEC + 2 * 12)) tx_col = MODCOLOR_DODGY_COMMANDS; } @@ -1187,11 +1189,13 @@ if (m_nMidRow) sizeTotal.cy += m_nMidRow * m_szCell.cy * 2; SetScrollSizes(MM_TEXT, sizeTotal, sizePage, sizeLine); //UpdateScrollPos(); //rewbs.FixLPsOddScrollingIssue - if (rect.Height() >= sizeTotal.cy) { - m_bWholePatternFitsOnScreen=true; + if (rect.Height() >= sizeTotal.cy) + { + m_bWholePatternFitsOnScreen = true; m_nYScroll = 0; //rewbs.fix2977 - } else { - m_bWholePatternFitsOnScreen=false; + } else + { + m_bWholePatternFitsOnScreen = false; } } } @@ -1450,7 +1454,7 @@ CSoundFile *pSndFile = pModDoc->GetSoundFile(); CHAR s[512]; UINT nChn; - wsprintf(s, "Row %d, Col %d", GetCurrentRow(), GetCurrentChannel()+1); + wsprintf(s, "Row %d, Col %d", GetCurrentRow(), GetCurrentChannel() + 1); pMainFrm->SetUserText(s); if (::GetFocus() == m_hWnd) { @@ -1464,12 +1468,12 @@ switch (GetColTypeFromCursor(m_dwCursor)) { - case 0: + case NOTE_COLUMN: // display note if(m->note >= NOTE_MIN_SPECIAL) strcpy(s, szSpecialNoteShortDesc[m->note - NOTE_MIN_SPECIAL]); break; - case 1: + case INST_COLUMN: // display instrument if (m->instr) { @@ -1485,9 +1489,9 @@ } else { // "normal" instrument - if (pSndFile->m_nInstruments) + if (pSndFile->GetNumInstruments()) { - if ((m->instr <= pSndFile->m_nInstruments) && (pSndFile->Instruments[m->instr])) + if ((m->instr <= pSndFile->GetNumInstruments()) && (pSndFile->Instruments[m->instr])) { MODINSTRUMENT *pIns = pSndFile->Instruments[m->instr]; memcpy(sztmp, pIns->name, 32); @@ -1495,7 +1499,7 @@ if ((m->note) && (m->note <= NOTE_MAX)) { UINT nsmp = pIns->Keyboard[m->note-1]; - if ((nsmp) && (nsmp <= pSndFile->m_nSamples)) + if ((nsmp) && (nsmp <= pSndFile->GetNumSamples())) { CHAR sztmp2[64] = ""; memcpy(sztmp2, pSndFile->m_szNames[nsmp], MAX_SAMPLENAME); @@ -1509,7 +1513,7 @@ } } else { - if (m->instr <= pSndFile->m_nSamples) + if (m->instr <= pSndFile->GetNumSamples()) { memcpy(sztmp, pSndFile->m_szNames[m->instr], MAX_SAMPLENAME); sztmp[32] = 0; @@ -1520,7 +1524,7 @@ if (sztmp[0]) wsprintf(s, "%d: %s", m->instr, sztmp); } break; - case 2: + case VOL_COLUMN: // display volume command if(m->IsPcNote()) { @@ -1538,8 +1542,8 @@ if (!pModDoc->GetVolCmdInfo(pModDoc->GetIndexFromVolCmd(m->volcmd), s)) s[0] = 0; } break; - case 3: - case 4: + case EFFECT_COLUMN: + case PARAM_COLUMN: // display effect command if(!m->IsPcNote()) { Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2011-04-19 20:43:50 UTC (rev 859) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2011-04-29 21:32:29 UTC (rev 860) @@ -3153,9 +3153,11 @@ //end rewbs.fix3185 //ensure order correlates with pattern. - if (pSndFile->Order[ord]!=pat) { + if (pSndFile->Order[ord]!=pat) + { ORDERINDEX tentativeOrder = pSndFile->FindOrder(pat); - if (tentativeOrder != ORDERINDEX_INVALID) { //ensure a valid order exists. + if (tentativeOrder != ORDERINDEX_INVALID) //ensure a valid order exists. + { ord = tentativeOrder; } } @@ -3192,11 +3194,13 @@ if ((param[1] >= '0') && (param[1] <= '9')) code += (param[1] - '0'); else if ((param[1] >= 'A') && (param[1] <= 'F')) code += (param[1] - 'A' + 0x0A); - if (macro.GetLength()>=4 && macro.GetAt(3)=='0') + if (macro.GetLength() >= 4 && macro.GetAt(3) == '0') return (code - 128); else return (code + 128); } + + int CModDoc::MacroToMidiCC(CString macro) //--------------------------------------- { @@ -3211,6 +3215,7 @@ return code; } + int CModDoc::FindMacroForParam(long param) const //---------------------------------------------- { @@ -3231,6 +3236,7 @@ return -1; } + // Retrieve Zxx (Z80-ZFF) type from current macro configuration enmFixedMacroType CModDoc::GetZxxType(const CHAR (&szMidiZXXExt)[128][MACRO_LENGTH]) //---------------------------------------------------------------------------------- @@ -3256,6 +3262,7 @@ return sfx_fixed_custom; // Custom setup } + // Create Zxx (Z80 - ZFF) from one out of five presets void CModDoc::CreateZxxFromType(CHAR (&szMidiZXXExt)[128][MACRO_LENGTH], enmFixedMacroType iZxxType) //-------------------------------------------------------------------------------------------------- @@ -3306,6 +3313,9 @@ { return false; } + // Global macros + // TODO + // SF0: Z00-Z7F controls cutoff if(GetMacroType(pSndFile->m_MidiCfg.szMidiSFXExt[0]) != sfx_cutoff) { Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2011-04-19 20:43:50 UTC (rev 859) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2011-04-29 21:32:29 UTC (rev 860) @@ -155,7 +155,6 @@ { memset(ChnVUMeters, 0, sizeof(ChnVUMeters)); memset(OldVUMeters, 0, sizeof(OldVUMeters)); - memset(MultiRecordMask, 0, sizeof(MultiRecordMask)); // -> CODE#0012 // -> DESC="midi keyboard split" memset(splitActiveNoteChannel, 0xFF, sizeof(splitActiveNoteChannel)); @@ -2260,9 +2259,9 @@ if (((pMainFrm->GetFollowSong(pModDoc) != m_hWnd) || (pSndFile->IsPaused()) || (!(m_dwStatus & PATSTATUS_FOLLOWSONG)))) { - DWORD sel = m_dwCursor | (m_nRow << 16); - InvalidateArea(sel, sel+5); //rewbs.fix3010 (no refresh under on last row) - SetCurrentRow(m_nRow+m_nSpacing); + DWORD sel = (nChn << 3) | (m_nRow << 16); + InvalidateArea(sel, sel + LAST_COLUMN); + SetCurrentRow(m_nRow + m_nSpacing); sel = m_dwCursor | (m_nRow << 16); SetCurSel(sel, sel); } @@ -2569,7 +2568,7 @@ if ((pModDoc = GetDocument()) == NULL || !(IsEditingEnabled_bmsg())) return; pSndFile = pModDoc->GetSoundFile(); - nChannels = pSndFile->m_nChannels; + nChannels = pSndFile->GetNumChannels(); nRows = pSndFile->Patterns[m_nPattern].GetNumRows(); pOldPattern = pSndFile->Patterns[m_nPattern]; if ((nChannels < 1) || (nRows < 1) || (!pOldPattern)) return; @@ -3978,7 +3977,7 @@ if(oldcmd != *p) { pModDoc->SetModified(); - InvalidateArea(sel, sel+5); + InvalidateArea(sel, sel + LAST_COLUMN); UpdateIndicator(); } } @@ -4053,7 +4052,7 @@ if(oldcmd != *p) { pModDoc->SetModified(); - InvalidateArea(sel, sel+5); + InvalidateArea(sel, sel + LAST_COLUMN); UpdateIndicator(); } } // end if mainframe & moddoc exist @@ -4100,7 +4099,7 @@ if(*p != oldcmd) { pModDoc->SetModified(); - InvalidateArea(sel, sel+5); + InvalidateArea(sel, sel + LAST_COLUMN); UpdateIndicator(); } } @@ -4234,7 +4233,7 @@ if(bIsLiveRecord == false) { DWORD sel = (nRow << 16) | (nChn << 3); - InvalidateArea(sel, sel+5); + InvalidateArea(sel, sel + LAST_COLUMN); UpdateIndicator(); } @@ -4314,7 +4313,7 @@ if(*p != oldcmd) { pModDoc->SetModified(); - InvalidateArea(sel, sel+5); + InvalidateArea(sel, sel + LAST_COLUMN); UpdateIndicator(); } } @@ -4372,7 +4371,7 @@ pSndFile->Patterns[m_nPattern].GetpModCommand(nRow, nChn)->note = note; const DWORD sel = (nRow << 16) | m_dwCursor; pModDoc->SetModified(); - InvalidateArea(sel, sel+5); + InvalidateArea(sel, sel + LAST_COLUMN); UpdateIndicator(); return; } @@ -4521,7 +4520,7 @@ pModDoc->SetModified(); if(bIsLiveRecord == false) { // Update only when not recording live. - InvalidateArea(sel, sel+5); + InvalidateArea(sel, sel + LAST_COLUMN); UpdateIndicator(); } } Modified: trunk/OpenMPT/mptrack/View_pat.h =================================================================== --- trunk/OpenMPT/mptrack/View_pat.h 2011-04-19 20:43:50 UTC (rev 859) +++ trunk/OpenMPT/mptrack/View_pat.h 2011-04-29 21:32:29 UTC (rev 860) @@ -54,7 +54,7 @@ LAST_COLUMN = PARAM_COLUMN }; -static_assert(MAX_CHANNELS <= 0x1FFF, "Check: Channel index in pattern editor is only 13 bits wide!"); +static_assert(MAX_BASECHANNELS <= 0x1FFF, "Check: Channel index in pattern editor is only 13 bits wide!"); //Struct for controlling selection clearing. This is used to define which data fields @@ -117,7 +117,6 @@ WORD ChnVUMeters[MAX_BASECHANNELS]; WORD OldVUMeters[MAX_BASECHANNELS]; CListBox *ChnEffectList[MAX_BASECHANNELS]; //rewbs.patPlugName - BYTE MultiRecordMask[(MAX_CHANNELS+7)/8]; UINT m_nFoundInstrument; UINT m_nMenuOnChan; DWORD m_dwLastNoteEntryTime; //rewbs.customkeys Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2011-04-19 20:43:50 UTC (rev 859) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2011-04-29 21:32:29 UTC (rev 860) @@ -234,11 +234,11 @@ static inline UINT ConvertVolParam(UINT value) //-------------------------------------------- { - return (value > 9) ? 9 : value; + return (value > 9) ? 9 : value; } -// Convert MPT's internal nvelope format into an IT/MPTM envelope. +// Convert MPT's internal envelope format into an IT/MPTM envelope. void MPTEnvToIT(const INSTRUMENTENVELOPE *mptEnv, ITENVELOPE *itEnv, const BYTE envOffset, const BYTE envDefault) //--------------------------------------------------------------------------------------------------------------- { @@ -795,7 +795,8 @@ { if (dwMemPos + sizeof(MODMIDICFG) < dwMemLength) { - memcpy(&m_MidiCfg, lpStream+dwMemPos, sizeof(MODMIDICFG)); + memcpy(&m_MidiCfg, lpStream + dwMemPos, sizeof(MODMIDICFG)); + SanitizeMacros(); dwMemPos += sizeof(MODMIDICFG); } } @@ -1173,7 +1174,7 @@ { m[ch].volcmd = VOLCMD_VIBRATODEPTH; m[ch].vol = vol - 203; // Old versions of ModPlug saved this as vibrato speed instead, so let's fix that - if(m_dwLastSavedWithVersion <= MAKE_VERSION_NUMERIC(1, 17, 02, 54) && interpretModPlugMade) + if(m_dwLastSavedWithVersion && m_dwLastSavedWithVersion <= MAKE_VERSION_NUMERIC(1, 17, 02, 54)) m[ch].volcmd = VOLCMD_VIBRATOSPEED; } else // 213-222: Unused (was velocity) @@ -1348,7 +1349,7 @@ ITFILEHEADER header; ITINSTRUMENT iti; ITSAMPLESTRUCT itss; - BYTE smpcount[(MAX_SAMPLES+7)/8]; + vector<bool>smpcount(GetNumSamples(), false); DWORD inspos[MAX_INSTRUMENTS]; vector<DWORD> patpos; DWORD smppos[MAX_SAMPLES]; @@ -1539,7 +1540,6 @@ if (Instruments[nins]) { MODINSTRUMENT *pIns = Instruments[nins]; - memset(smpcount, 0, sizeof(smpcount)); memcpy(iti.filename, pIns->filename, 12); memcpy(iti.name, pIns->name, 26); iti.mbank = pIns->wMidiBank; @@ -1570,10 +1570,10 @@ iti.nos = 0; for (UINT i=0; i<NOTE_MAX; i++) if (pIns->Keyboard[i] < MAX_SAMPLES) { - UINT smp = pIns->Keyboard[i]; - if ((smp) && (!(smpcount[smp>>3] & (1<<(smp&7))))) + const UINT smp = pIns->Keyboard[i]; + if (smp && !smpcount[smp - 1]) { - smpcount[smp>>3] |= 1 << (smp&7); + smpcount[smp - 1] = true; iti.nos++; } iti.keyboard[i*2] = (pIns->NoteMap[i] >= NOTE_MIN && pIns->NoteMap[i] <= NOTE_MAX) ? (pIns->NoteMap[i] - 1) : i; @@ -1978,7 +1978,7 @@ ITFILEHEADER header; ITINSTRUMENT iti; ITSAMPLESTRUCT itss; - BYTE smpcount[(MAX_SAMPLES+7)/8]; + vector<bool>smpcount(GetNumSamples(), false); DWORD inspos[MAX_INSTRUMENTS]; DWORD patpos[MAX_PATTERNS]; DWORD smppos[MAX_SAMPLES]; @@ -2142,7 +2142,6 @@ if (Instruments[nins]) { MODINSTRUMENT *pIns = Instruments[nins]; - memset(smpcount, 0, sizeof(smpcount)); memcpy(iti.filename, pIns->filename, 12); memcpy(iti.name, pIns->name, 26); SetNullTerminator(iti.name); @@ -2165,10 +2164,10 @@ iti.nos = 0; for (UINT i=0; i<NOTE_MAX; i++) if (pIns->Keyboard[i] < MAX_SAMPLES) { - UINT smp = pIns->Keyboard[i]; - if ((smp) && (!(smpcount[smp>>3] & (1<<(smp&7))))) + const UINT smp = pIns->Keyboard[i]; + if (smp && !smpcount[smp - 1]) { - smpcount[smp>>3] |= 1 << (smp&7); + smpcount[smp - 1] = true; iti.nos++; } iti.keyboard[i*2] = (pIns->NoteMap[i] >= NOTE_MIN && pIns->NoteMap[i] <= NOTE_MAX) ? (pIns->NoteMap[i] - 1) : i; Modified: trunk/OpenMPT/soundlib/Load_itp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp 2011-04-19 20:43:50 UTC (rev 859) +++ trunk/OpenMPT/soundlib/Load_itp.cpp 2011-04-29 21:32:29 UTC (rev 860) @@ -172,8 +172,10 @@ // midi cfg ASSERT_CAN_READ(id); - if (id<=sizeof(m_MidiCfg)) { - memcpy(&m_MidiCfg,lpStream+dwMemPos,id); + if (id <= sizeof(m_MidiCfg)) + { + memcpy(&m_MidiCfg, lpStream + dwMemPos, id); + SanitizeMacros(); dwMemPos += id; } Modified: trunk/OpenMPT/soundlib/Load_mod.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mod.cpp 2011-04-19 20:43:50 UTC (rev 859) +++ trunk/OpenMPT/soundlib/Load_mod.cpp 2011-04-29 21:32:29 UTC (rev 860) @@ -617,7 +617,7 @@ UINT nbp = 0, norders = 128; for (UINT iord=0; iord<128; iord++) { - if (Order[iord] == Order.GetInvalidPatIndex()) + if (Order[iord] == Order.GetInvalidPatIndex() || Order[iord] == Order.GetIgnoreIndex()) { norders = iord; break; @@ -644,7 +644,8 @@ } fwrite(bTab, 4, 1, f); // Writing patterns - for (UINT ipat=0; ipat<nbp; ipat++) { //for all patterns + for (UINT ipat=0; ipat<nbp; ipat++) //for all patterns + { BYTE s[64*4]; if (Patterns[ipat]) //if pattern exists { Modified: trunk/OpenMPT/soundlib/Load_xm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_xm.cpp 2011-04-19 20:43:50 UTC (rev 859) +++ trunk/OpenMPT/soundlib/Load_xm.cpp 2011-04-29 21:32:29 UTC (rev 860) @@ -615,7 +615,8 @@ dwMemPos += 8; if (len == sizeof(MODMIDICFG)) { - memcpy(&m_MidiCfg, lpStream+dwMemPos, len); + memcpy(&m_MidiCfg, lpStream + dwMemPos, len); + SanitizeMacros(); m_dwSongFlags |= SONG_EMBEDMIDICFG; dwMemPos += len; //rewbs.fix36946 } Modified: trunk/OpenMPT/soundlib/Sampleio.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sampleio.cpp 2011-04-19 20:43:50 UTC (rev 859) +++ trunk/OpenMPT/soundlib/Sampleio.cpp 2011-04-29 21:32:29 UTC (rev 860) @@ -1787,14 +1787,14 @@ ITINSTRUMENT *iti = (ITINSTRUMENT *)buffer; ITSAMPLESTRUCT itss; MODINSTRUMENT *pIns = Instruments[nInstr]; - UINT smpcount[MAX_SAMPLES], smptable[MAX_SAMPLES], smpmap[MAX_SAMPLES]; + vector<bool> smpcount(GetNumSamples(), false); + UINT smptable[MAX_SAMPLES], smpmap[MAX_SAMPLES]; DWORD dwPos; FILE *f; if ((!pIns) || (!lpszFileName)) return false; if ((f = fopen(lpszFileName, "wb")) == NULL) return false; memset(buffer, 0, sizeof(buffer)); - memset(smpcount, 0, sizeof(smpcount)); memset(smptable, 0, sizeof(smptable)); memset(smpmap, 0, sizeof(smpmap)); iti->id = LittleEndian(IT_IMPI); // "IMPI" @@ -1822,10 +1822,10 @@ iti->nos = 0; for (UINT i=0; i<NOTE_MAX; i++) if (pIns->Keyboard[i] < MAX_SAMPLES) { - UINT smp = pIns->Keyboard[i]; - if ((smp) && (!smpcount[smp])) + const UINT smp = pIns->Keyboard[i]; + if (smp && !smpcount[smp - 1]) { - smpcount[smp] = 1; + smpcount[smp - 1] = true; smptable[iti->nos] = smp; smpmap[smp] = iti->nos; iti->nos++; Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-04-19 20:43:50 UTC (rev 859) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-04-29 21:32:29 UTC (rev 860) @@ -3965,10 +3965,10 @@ } -UINT __cdecl CSoundFile::GetChannelPlugin(UINT nChn, bool respectMutes) -//-------------------------------------------------------------- +UINT __cdecl CSoundFile::GetChannelPlugin(UINT nChn, bool respectMutes) const +//--------------------------------------------------------------------------- { - MODCHANNEL *pChn= &Chn[nChn]; + const MODCHANNEL *pChn = &Chn[nChn]; // If it looks like this is an NNA channel, we need to find the master channel. // This ensures we pick up the right ChnSettings. @@ -3988,10 +3988,10 @@ } -UINT CSoundFile::GetActiveInstrumentPlugin(UINT nChn, bool respectMutes) -//----------------------------------------------------------------------- +UINT CSoundFile::GetActiveInstrumentPlugin(UINT nChn, bool respectMutes) const +//---------------------------------------------------------------------------- { - MODCHANNEL *pChn = &Chn[nChn]; + const MODCHANNEL *pChn = &Chn[nChn]; // Unlike channel settings, pModInstrument is copied from the original chan to the NNA chan, // so we don't nee to worry about finding the master chan. @@ -4007,8 +4007,8 @@ } -UINT CSoundFile::GetBestMidiChan(MODCHANNEL *pChn) -//------------------------------------------------ +UINT CSoundFile::GetBestMidiChan(const MODCHANNEL *pChn) const +//------------------------------------------------------------ { if (pChn && pChn->pModInstrument && pChn->pModInstrument->nMidiChannel) { Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2011-04-19 20:43:50 UTC (rev 859) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2011-04-29 21:32:29 UTC (rev 860) @@ -936,6 +936,25 @@ } +// Set null terminator for all MIDI macros +void CSoundFile::SanitizeMacros() +//------------------------------- +{ + for(size_t i = 0; i < CountOf(m_MidiCfg.szMidiGlb); i++) + { + SetNullTerminator(m_MidiCfg.szMidiGlb[i]); + } + for(size_t i = 0; i < CountOf(m_MidiCfg.szMidiSFXExt); i++) + { + SetNullTerminator(m_MidiCfg.szMidiSFXExt[i]); + } + for(size_t i = 0; i < CountOf(m_MidiCfg.szMidiZXXExt); i++) + { + SetNullTerminator(m_MidiCfg.szMidiZXXExt[i]); + } +} + + BOOL CSoundFile::SetWaveConfig(UINT nRate,UINT nBits,UINT nChannels,BOOL bMMX) //---------------------------------------------------------------------------- { @@ -2620,7 +2639,7 @@ return 0; } SAMPLEINDEX nRemoved = 0; - for (SAMPLEINDEX nSmp = (SAMPLEINDEX)min(GetNumSamples(), keepSamples.size() - 1); nSmp >= 1; nSmp--) + for(SAMPLEINDEX nSmp = (SAMPLEINDEX)min(GetNumSamples(), keepSamples.size() - 1); nSmp >= 1; nSmp--) { if(!keepSamples[nSmp]) { Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2011-04-19 20:43:50 UTC (rev 859) +++ trunk/OpenMPT/soundlib/Sndfile.h 2011-04-29 21:32:29 UTC (rev 860) @@ -433,7 +433,9 @@ //////////////////////////////////////////////////////////////////// -enum { +// Global MIDI macros +enum +{ MIDIOUT_START=0, MIDIOUT_STOP, MIDIOUT_TICK, @@ -454,7 +456,6 @@ CHAR szMidiSFXExt[16][MACRO_LENGTH]; CHAR szMidiZXXExt[128][MACRO_LENGTH]; }; -typedef MODMIDICFG* LPMODMIDICFG; STATIC_ASSERT(sizeof(MODMIDICFG) == 4896); // this is directly written to files, so the size must be correct! typedef VOID (__cdecl * LPSNDMIXHOOKPROC)(int *, unsigned long, unsigned long); // buffer, samples, channels @@ -990,6 +991,7 @@ // Misc functions MODSAMPLE *GetSample(UINT n) { return Samples+n; } void ResetMidiCfg(); + void SanitizeMacros(); UINT MapMidiInstrument(DWORD dwProgram, UINT nChannel, UINT nNote); long ITInstrToMPT(const void *p, MODINSTRUMENT *pIns, UINT trkvers); //change from BOOL for rewbs.modularInstData UINT LoadMixPlugins(const void *pData, UINT nLen); @@ -1051,9 +1053,9 @@ void resetEnvelopes(MODCHANNEL* pChn, enmResetEnv envToReset = ENV_RESET_ALL); void SetDefaultInstrumentValues(MODINSTRUMENT *pIns); private: - UINT __cdecl GetChannelPlugin(UINT nChan, bool respectMutes); - UINT __cdecl GetActiveInstrumentPlugin(UINT nChan, bool respectMutes); - UINT GetBestMidiChan(MODCHANNEL *pChn); + UINT __cdecl GetChannelPlugin(UINT nChan, bool respectMutes) const; + UINT __cdecl GetActiveInstrumentPlugin(UINT nChan, bool respectMutes) const; + UINT GetBestMidiChan(const MODCHANNEL *pChn) const; void HandlePatternTransitionEvents(); void BuildDefaultInstrument(); Modified: trunk/OpenMPT/soundlib/mod_specifications.h =================================================================== --- trunk/OpenMPT/soundlib/mod_specifications.h 2011-04-19 20:43:50 UTC (rev 859) +++ trunk/OpenMPT/soundlib/mod_specifications.h 2011-04-29 21:32:29 UTC (rev 860) @@ -178,7 +178,7 @@ false, // No envelope release node " 0123456789ABCD?FF?E???????????????", // Supported Effects " ???????????????", // Supported Volume Column commands - true, // Has "+++" pattern + false, // Doesn't have "+++" pattern true, // Has restart position (order) false, // Doesn't support plugins false, // No custom pattern time signatures @@ -257,7 +257,7 @@ false, // No envelope release node " 0123456789ABCDRFFTE???GHK?YXPLZ\\?#", // Supported Effects " vpcdabuhlrgfe?o", // Supported Volume Column commands - true, // Has "+++" pattern + false, // Doesn't have "+++" pattern true, // Has restart position (order) true, // Supports plugins false, // No custom pattern time signatures This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |