From: <sag...@us...> - 2010-06-25 21:00:43
|
Revision: 632 http://modplug.svn.sourceforge.net/modplug/?rev=632&view=rev Author: saga-games Date: 2010-06-25 21:00:37 +0000 (Fri, 25 Jun 2010) Log Message: ----------- [Fix] Pattern Editor: Transposing notes up/down allowed notes which were not supported by the current module format (f.e. notes below C-1 in XMs) [Imp] Instrument Editor: If an instrument is not initialized yet, this is done automatically now, so that changes done to the instrument are not lost although it looks like they are actually applied. [Fix] Added additional nullptr check in CModDoc::InitializeInstrument (nothing bad happened, but let's better sanitize this sooner than later) Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/View_pat.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2010-06-24 20:58:59 UTC (rev 631) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2010-06-25 21:00:37 UTC (rev 632) @@ -100,6 +100,15 @@ { m_pModDoc = pModDoc; if (nIns < MAX_INSTRUMENTS) m_nInstrument = nIns; + + // create missing instrument if needed + CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); + if(m_nInstrument > 0 && pSndFile && m_nInstrument <= pSndFile->GetNumInstruments() && pSndFile->Instruments[m_nInstrument] == nullptr) + { + pSndFile->Instruments[m_nInstrument] = new MODINSTRUMENT; + m_pModDoc->InitializeInstrument(pSndFile->Instruments[m_nInstrument]); + } + InvalidateRect(NULL, FALSE); } return TRUE; @@ -352,7 +361,7 @@ if (pIns) { bool bModified = false; - UINT n = pIns->NoteMap[m_nNote]; + BYTE n = pIns->NoteMap[m_nNote]; for (NOTEINDEXTYPE i = 0; i < NOTE_MAX; i++) if (pIns->NoteMap[i] != n) { pIns->NoteMap[i] = n; @@ -378,7 +387,7 @@ if (pIns) { bool bModified = false; - UINT n = pIns->Keyboard[m_nNote]; + WORD n = pIns->Keyboard[m_nNote]; for (NOTEINDEXTYPE i = 0; i < NOTE_MAX; i++) if (pIns->Keyboard[i] != n) { pIns->Keyboard[i] = n; Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2010-06-24 20:58:59 UTC (rev 631) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2010-06-25 21:00:37 UTC (rev 632) @@ -843,11 +843,13 @@ void CModDoc::InitializeInstrument(MODINSTRUMENT *pIns, UINT nsample) //------------------------------------------------------------------- { + if(pIns == nullptr) + return; memset(pIns, 0, sizeof(MODINSTRUMENT)); pIns->nFadeOut = 256; pIns->nGlobalVol = 64; pIns->nPan = 128; - pIns->nPPC = 5*12; + pIns->nPPC = NOTE_MIDDLEC - 1; m_SndFile.SetDefaultInstrumentValues(pIns); for (UINT n=0; n<128; n++) { Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2010-06-24 20:58:59 UTC (rev 631) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2010-06-25 21:00:37 UTC (rev 632) @@ -2357,10 +2357,12 @@ CModDoc *pModDoc = GetDocument(); if (pModDoc) { - UINT row0 = m_dwBeginSel >> 16, row1 = m_dwEndSel >> 16; - UINT col0 = ((m_dwBeginSel & 0xFFFF)+7) >> 3, col1 = (m_dwEndSel & 0xFFFF) >> 3; + const UINT row0 = m_dwBeginSel >> 16, row1 = m_dwEndSel >> 16; + const UINT col0 = ((m_dwBeginSel & 0xFFFF)+7) >> 3, col1 = (m_dwEndSel & 0xFFFF) >> 3; CSoundFile *pSndFile = pModDoc->GetSoundFile(); MODCOMMAND *pcmd = pSndFile->Patterns[m_nPattern]; + const MODCOMMAND::NOTE noteMin = pSndFile->GetModSpecifications().noteMin; + const MODCOMMAND::NOTE noteMax = pSndFile->GetModSpecifications().noteMax; if ((!pcmd) || (col0 > col1) || (col1 >= pSndFile->m_nChannels) || (row0 > row1) || (row1 >= pSndFile->Patterns[m_nPattern].GetNumRows())) return FALSE; @@ -2371,11 +2373,11 @@ for (UINT col=col0; col<=col1; col++) { int note = m[col].note; - if ((note) && (note <= NOTE_MAX)) + if ((note >= NOTE_MIN) && (note <= NOTE_MAX)) { note += transp; - if (note < 1) note = 1; - if (note > NOTE_MAX) note = NOTE_MAX; + if (note < noteMin) note = noteMin; + if (note > noteMax) note = noteMax; m[col].note = (BYTE)note; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |