From: <sag...@us...> - 2011-09-17 22:37:41
|
Revision: 1037 http://modplug.svn.sourceforge.net/modplug/?rev=1037&view=rev Author: saga-games Date: 2011-09-17 22:37:34 +0000 (Sat, 17 Sep 2011) Log Message: ----------- [Ref] Misc refactoring and cleanup Modified Paths: -------------- trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/ExceptionHandler.cpp trunk/OpenMPT/mptrack/Globals.cpp trunk/OpenMPT/mptrack/Globals.h trunk/OpenMPT/mptrack/KeyConfigDlg.cpp trunk/OpenMPT/mptrack/Mpt_midi.cpp trunk/OpenMPT/mptrack/mod2midi.cpp trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/Dlsbank.h trunk/OpenMPT/soundlib/LOAD_DMF.CPP trunk/OpenMPT/soundlib/Load_gdm.cpp trunk/OpenMPT/soundlib/Load_mt2.cpp trunk/OpenMPT/soundlib/Load_psm.cpp trunk/OpenMPT/soundlib/Message.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -435,7 +435,7 @@ DefineKeyCommand(kcEditCopy, 1361, _T("Copy")); DefineKeyCommand(kcEditPaste, 1362, _T("Paste")); DefineKeyCommand(kcEditMixPaste, 1363, _T("Mix Paste")); - DefineKeyCommand(kcEditSelectAll, 1364, _T("SelectAll")); + DefineKeyCommand(kcEditSelectAll, 1364, _T("Select All")); DefineKeyCommand(kcEditFind, 1365, _T("Find / Replace")); DefineKeyCommand(kcEditFindNext, 1366, _T("Find Next")); DefineKeyCommand(kcViewMain, 1367, _T("Toggle Main View")); Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -401,7 +401,7 @@ if (pIns) { bool bModified = false; - WORD n = pIns->Keyboard[m_nNote]; + SAMPLEINDEX n = pIns->Keyboard[m_nNote]; for (NOTEINDEXTYPE i = 0; i < NOTE_MAX; i++) if (pIns->Keyboard[i] != n) { pIns->Keyboard[i] = n; @@ -577,7 +577,7 @@ { UINT n = pIns->NoteMap[m_nNote]; bool bOk = false; - if ((note > 0) && (note <= NOTE_MAX)) + if ((note >= pSndFile->GetModSpecifications().noteMin) && (note <= pSndFile->GetModSpecifications().noteMax)) { n = note; bOk = true; Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -1530,15 +1530,12 @@ sztmp[32] = 0; if ((m->note) && (m->note <= NOTE_MAX)) { - UINT nsmp = pIns->Keyboard[m->note-1]; + const SAMPLEINDEX nsmp = pIns->Keyboard[m->note-1]; if ((nsmp) && (nsmp <= pSndFile->GetNumSamples())) { - CHAR sztmp2[64] = ""; - memcpy(sztmp2, pSndFile->m_szNames[nsmp], MAX_SAMPLENAME); - sztmp2[32] = 0; - if (sztmp2[0]) + if (pSndFile->m_szNames[nsmp][0]) { - wsprintf(sztmp+strlen(sztmp), " (%d: %s)", nsmp, sztmp2); + wsprintf(sztmp+strlen(sztmp), " (%d: %s)", nsmp, pSndFile->m_szNames[nsmp]); } } } Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -99,7 +99,7 @@ pDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &ExInfo, NULL, NULL); ::CloseHandle(hFile); - errorMessage.AppendFormat("\n\nDebug information have been saved to\n%s", baseRescuePath); + errorMessage.AppendFormat("\n\nDebug information has been saved to\n%s", baseRescuePath); } } ::FreeLibrary(hDll); Modified: trunk/OpenMPT/mptrack/Globals.cpp =================================================================== --- trunk/OpenMPT/mptrack/Globals.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/mptrack/Globals.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -13,7 +13,7 @@ #include "ctrl_ins.h" #include "ctrl_com.h" #include "ctrl_graph.h" //rewbs.graph -#include ".\globals.h" +#include "globals.h" #ifdef _DEBUG #define new DEBUG_NEW Modified: trunk/OpenMPT/mptrack/Globals.h =================================================================== --- trunk/OpenMPT/mptrack/Globals.h 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/mptrack/Globals.h 2011-09-17 22:37:34 UTC (rev 1037) @@ -111,9 +111,6 @@ //================================ { public: - CModTabCtrl() {} - -public: BOOL InsertItem(int nIndex, LPSTR pszText, LPARAM lParam=0, int iImage=-1); BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID); UINT GetItemData(int nIndex); Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -588,7 +588,7 @@ //detect invalid input if (!kc.code) { - CString error = "You need to say to which key you'd like to map this command."; + CString error = "You need to say to which key you'd like to map this command to."; Reporting::Warning(error, "Invalid key data"); return; } Modified: trunk/OpenMPT/mptrack/Mpt_midi.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpt_midi.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/mptrack/Mpt_midi.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -14,16 +14,15 @@ //Get Midi message(dwParam1), apply MIDI settings having effect on volume, and return //the volume value [0, 256]. In addition value -1 is used as 'use default value'-indicator. -int ApplyVolumeRelatedMidiSettings(const DWORD& dwParam1, const BYTE midivolume) -//---------------------------------------------------------------- +int ApplyVolumeRelatedMidiSettings(const DWORD &dwParam1, const BYTE midivolume) +//------------------------------------------------------------------------------ { int nVol = GetFromMIDIMsg_DataByte2(dwParam1); if (CMainFrame::GetSettings().m_dwMidiSetup & MIDISETUP_RECORDVELOCITY) { nVol = (CDLSBank::DLSMidiVolumeToLinear(nVol)+255) >> 8; if (CMainFrame::GetSettings().m_dwMidiSetup & MIDISETUP_AMPLIFYVELOCITY) nVol *= 2; - if (nVol < 1) nVol = 1; - if (nVol > 256) nVol = 256; + Limit(nVol, 1, 256); if(CMainFrame::GetSettings().m_dwMidiSetup & MIDISETUP_MIDIVOL_TO_NOTEVOL) nVol = static_cast<int>((midivolume / 127.0) * nVol); } @@ -38,8 +37,8 @@ return nVol; } -void ApplyTransposeKeyboardSetting(CMainFrame& rMainFrm, DWORD& dwParam1) -//------------------------------------------------------------------------ +void ApplyTransposeKeyboardSetting(CMainFrame &rMainFrm, DWORD &dwParam1) +//----------------------------------------------------------------------- { if ( (CMainFrame::GetSettings().m_dwMidiSetup & MIDISETUP_TRANSPOSEKEYBOARD) && (GetFromMIDIMsg_Channel(dwParam1) != 9) ) @@ -50,17 +49,12 @@ int note = GetFromMIDIMsg_DataByte1(dwParam1); if (note < 0x80) { - note += nTranspose*12; - if (note < 0) note = NOTE_NONE; - if (note > NOTE_MAX - 1) note = NOTE_MAX - 1; + note += nTranspose * 12; + Limit(note, 0, NOTE_MAX - NOTE_MIN); - // -> CODE#0011 - // -> DESC="bug fix about transpose midi keyboard option" - //dwParam1 &= 0xffffff00; dwParam1 &= 0xffff00ff; - // -! BUG_FIX#0011 - dwParam1 |= (note<<8); + dwParam1 |= (note << 8); } } } @@ -97,7 +91,7 @@ { DWORD dwTime = timeGetTime(); const DWORD timediff = dwTime - gdwLastMidiEvtTime; - if (timediff < 20*3) break; + if (timediff < 20 * 3) break; gdwLastMidiEvtTime = dwTime; // continue } @@ -119,7 +113,8 @@ //------------------------------- { if (shMidiIn) return TRUE; - try { + try + { if (midiInOpen(&shMidiIn, GetSettings().m_nMidiDevice, (DWORD)MidiInCallBack, 0, CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { shMidiIn = NULL; @@ -186,7 +181,7 @@ size_t CMIDIMapper::GetSerializationSize() const -//--------------------------------------------- +//---------------------------------------------- { size_t s = 0; for(const_iterator citer = Begin(); citer != End(); citer++) @@ -234,7 +229,7 @@ bool CMIDIMapper::Deserialize(const BYTE* ptr, const size_t size) -//---------------------------------------------------------------------------- +//--------------------------------------------------------------- { m_Directives.clear(); const BYTE* endptr = ptr + size; @@ -278,7 +273,7 @@ bool CMIDIMapper::OnMIDImsg(const DWORD midimsg, BYTE& mappedIndex, uint32& paramindex, BYTE& paramval) -//---------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------- { bool captured = false; @@ -338,4 +333,3 @@ else return true; } - Modified: trunk/OpenMPT/mptrack/mod2midi.cpp =================================================================== --- trunk/OpenMPT/mptrack/mod2midi.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/mptrack/mod2midi.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -481,18 +481,18 @@ tmp[len+1] = (pTrk->nMidiChannel==9) ? static_cast<BYTE>(pTrk->nMidiProgram) : static_cast<BYTE>(note); UINT vol = 0x7f; UINT nsmp = pTrk->nInstrument; - if (m_pSndFile->m_nInstruments) + if (m_pSndFile->GetNumInstruments()) { - if ((nsmp < MAX_INSTRUMENTS) && (m_pSndFile->Instruments[nsmp])) + if ((nsmp <= m_pSndFile->GetNumInstruments()) && (m_pSndFile->Instruments[nsmp])) { MODINSTRUMENT *pIns = m_pSndFile->Instruments[nsmp]; nsmp = pIns->Keyboard[note]; } else nsmp = 0; } - if ((nsmp) && (nsmp < MAX_SAMPLES)) vol = m_pSndFile->GetSample(nsmp).nVolume; - if (m->volcmd == VOLCMD_VOLUME) vol = m->vol*4; - if (m->command == CMD_VOLUME) vol = m->param*4; - vol = LinearToDLSMidiVolume(vol<<8); + if (nsmp && nsmp <= m_pSndFile->GetNumSamples()) vol = m_pSndFile->GetSample(nsmp).nVolume; + if (m->command == CMD_VOLUME) vol = m->param * 4; + if (m->volcmd == VOLCMD_VOLUME) vol = m->vol * 4; + vol = LinearToDLSMidiVolume(vol << 8); if (vol > 0x7f) vol = 0x7f; tmp[len+2] = (BYTE)vol; tmp[len+3] = 0; @@ -506,7 +506,7 @@ UINT param = m->param; switch(m->command) { - case CMD_SPEED: if ((param) && (param < 32)) nSpeed = param; break; + case CMD_SPEED: if (param) nSpeed = param; break; case CMD_PATTERNBREAK: pattern_break = param; break; } } Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -873,6 +873,7 @@ for (UINT i=0; i<m_nSamplesEx; i++, pDlsSmp++, p++) { memcpy(pDlsSmp->szName, p->achSampleName, 20); + StringFixer::SetNullTerminator(pDlsSmp->szName); pDlsSmp->dwLen = 0; pDlsSmp->dwSampleRate = p->dwSampleRate; pDlsSmp->byOriginalPitch = p->byOriginalPitch; @@ -1757,7 +1758,7 @@ { if ((nRgn == nRgnMin) || ((iKey >= pRgn->uKeyMin) && (iKey <= pRgn->uKeyMax))) { - pIns->Keyboard[iKey] = (BYTE)nSmp; + pIns->Keyboard[iKey] = (SAMPLEINDEX)nSmp; } } // Load the sample @@ -1901,3 +1902,25 @@ } return TRUE; } + + +const CHAR *CDLSBank::GetRegionName(UINT nIns, UINT nRgn) const +//------------------------------------------------------------- +{ + DLSINSTRUMENT *pDlsIns; + + if ((!m_pInstruments) || (nIns >= m_nInstruments)) return nullptr; + pDlsIns = &m_pInstruments[nIns]; + if (nRgn >= pDlsIns->nRegions) return nullptr; + + if (m_nType & SOUNDBANK_TYPE_SF2) + { + UINT nWaveLink = pDlsIns->Regions[nRgn].nWaveLink; + if ((nWaveLink < m_nSamplesEx) && (m_pSamplesEx)) + { + DLSSAMPLEEX *p = &m_pSamplesEx[nWaveLink]; + return p->szName; + } + } + return nullptr; +} Modified: trunk/OpenMPT/soundlib/Dlsbank.h =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.h 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/soundlib/Dlsbank.h 2011-09-17 22:37:34 UTC (rev 1037) @@ -124,6 +124,7 @@ BOOL ExtractWaveForm(UINT nIns, UINT nRgn, LPBYTE *ppWave, DWORD *pLen); BOOL ExtractSample(CSoundFile *pSndFile, SAMPLEINDEX nSample, UINT nIns, UINT nRgn, int transpose=0); BOOL ExtractInstrument(CSoundFile *pSndFile, INSTRUMENTINDEX nInstr, UINT nIns, UINT nDrumRgn); + const CHAR *GetRegionName(UINT nIns, UINT nRgn) const; // Internal Loader Functions protected: Modified: trunk/OpenMPT/soundlib/LOAD_DMF.CPP =================================================================== --- trunk/OpenMPT/soundlib/LOAD_DMF.CPP 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/soundlib/LOAD_DMF.CPP 2011-09-17 22:37:34 UTC (rev 1037) @@ -856,7 +856,7 @@ { // Special case: Last 4 bytes should be "ENDE", without a size field (WTF) ASSERT_CAN_READ(4); - if(LittleEndian(*(uint32 *)(lpStream + dwMemPos)) == DMF_ENDE) + if(*(uint32 *)(lpStream + dwMemPos) == LittleEndian(DMF_ENDE)) { break; } Modified: trunk/OpenMPT/soundlib/Load_gdm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_gdm.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/soundlib/Load_gdm.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -20,7 +20,7 @@ #pragma pack(1) -typedef struct _GDMHEADER +struct GDMHEADER { uint32 ID; // ID: 'GDM\xFE' char SongTitle[32]; // Music's title @@ -53,9 +53,9 @@ uint16 SSLength; uint32 TGOffset; // Offset of text graphic (huh?) uint16 TGLength; -} GDMHEADER, *PGDMHEADER; +}; -typedef struct _GDMSAMPLEHEADER +struct GDMSAMPLEHEADER { char SamName[32]; // sample's name char FileName[12]; // sample's filename @@ -67,11 +67,14 @@ uint16 C4Hertz; // frequency uint8 Volume; // default volume uint8 Pan; // default pan -} GDMSAMPLEHEADER, *PGDMSAMPLEHEADER; +}; #pragma pack() -static MODTYPE GDMHeader_Origin[] = +#define GDMHEAD_GDM_ 0xFE4D4447 +#define GDMHEAD_GMFS 0x53464D47 + +static const MODTYPE GDMHeader_Origin[] = { MOD_TYPE_NONE, MOD_TYPE_MOD, MOD_TYPE_MTM, MOD_TYPE_S3M, MOD_TYPE_669, MOD_TYPE_FAR, MOD_TYPE_ULT, MOD_TYPE_STM, MOD_TYPE_MED }; @@ -81,55 +84,55 @@ { if ((!lpStream) || (dwMemLength < sizeof(GDMHEADER))) return false; - const PGDMHEADER pHeader = (PGDMHEADER)lpStream; + const GDMHEADER *pHeader = (GDMHEADER *)lpStream; - // is it a valid GDM file? - if( (LittleEndian(pHeader->ID) != 0xFE4D4447) || //GDM\xFE + // Is it a valid GDM file? + if( (pHeader->ID != LittleEndian(GDMHEAD_GDM_)) || //GDM\xFE (pHeader->DOSEOF[0] != 13 || pHeader->DOSEOF[1] != 10 || pHeader->DOSEOF[2] != 26) || //CR+LF+EOF - (LittleEndian(pHeader->ID2) != 0x53464D47)) return false; //GMFS + (pHeader->ID2 != LittleEndian(GDMHEAD_GMFS))) return false; //GMFS - // there are no other format versions... + // There are no other format versions... if(pHeader->FormMajorVer != 1 || pHeader->FormMinorVer != 0) return false; // 1-MOD, 2-MTM, 3-S3M, 4-669, 5-FAR, 6-ULT, 7-STM, 8-MED - m_nType = GDMHeader_Origin[pHeader->FormOrigin % ARRAYELEMCOUNT(GDMHeader_Origin)]; + m_nType = GDMHeader_Origin[pHeader->FormOrigin % CountOf(GDMHeader_Origin)]; if(m_nType == MOD_TYPE_NONE) return false; - // interesting question: Is TrackID, TrackMajorVer, TrackMinorVer relevant? The only TrackID should be 0 - 2GDM.exe, so the answer would be no. + // Interesting question: Is TrackID, TrackMajorVer, TrackMinorVer relevant? The only TrackID should be 0 - 2GDM.exe, so the answer would be no. - // song name + // Song name MemsetZero(m_szNames); memcpy(m_szNames[0], pHeader->SongTitle, 32); StringFixer::SpaceToNullStringFixed<31>(m_szNames[0]); - // read channel pan map... 0...15 = channel panning, 16 = surround channel, 255 = channel does not exist + // Read channel pan map... 0...15 = channel panning, 16 = surround channel, 255 = channel does not exist m_nChannels = 32; for(CHANNELINDEX i = 0; i < 32; i++) { if(pHeader->PanMap[i] < 16) { - ChnSettings[i].nPan = min((pHeader->PanMap[i] << 4) + 8, 256); + ChnSettings[i].nPan = min((pHeader->PanMap[i] * 16) + 8, 256); } else if(pHeader->PanMap[i] == 16) { ChnSettings[i].nPan = 128; ChnSettings[i].dwFlags |= CHN_SURROUND; } - else if(pHeader->PanMap[i] == 0xff) + else if(pHeader->PanMap[i] == 0xFF) { m_nChannels = i; break; } } - m_nDefaultGlobalVolume = min(pHeader->MastVol << 2, 256); + m_nDefaultGlobalVolume = min(pHeader->MastVol * 4, 256); m_nDefaultSpeed = pHeader->Tempo; m_nDefaultTempo = pHeader->BPM; - m_nRestartPos = 0; // not supported in this format, so use the default value - m_nSamplePreAmp = 48; // dito - m_nVSTiVolume = 48; // dito + m_nRestartPos = 0; // Not supported in this format, so use the default value + m_nSamplePreAmp = 48; // Dito + m_nVSTiVolume = 48; // Dito uint32 iSampleOffset = LittleEndian(pHeader->SamOffset), iPatternsOffset = LittleEndian(pHeader->PatOffset); @@ -140,7 +143,7 @@ iTGOffset = LittleEndian(pHeader->TGOffset), iTGLength = LittleEndianW(pHeader->TGLength); - // check if offsets are valid. we won't read the scrolly text or text graphics, but invalid pointers would probably indicate a broken file... + // Check if offsets are valid. we won't read the scrolly text or text graphics, but invalid pointers would probably indicate a broken file... if( dwMemLength < iOrdOffset || dwMemLength - iOrdOffset < pHeader->NOO || dwMemLength < iPatternsOffset || dwMemLength < iSamHeadOffset || dwMemLength - iSamHeadOffset < (pHeader->NOS + 1) * sizeof(GDMSAMPLEHEADER) @@ -150,17 +153,17 @@ || dwMemLength < iTGOffset || dwMemLength - iTGOffset < iTGLength) return false; - // read orders + // Read orders Order.ReadAsByte(lpStream + iOrdOffset, pHeader->NOO + 1, dwMemLength - iOrdOffset); - // read samples + // Read samples m_nSamples = pHeader->NOS + 1; for(SAMPLEINDEX iSmp = 1; iSmp <= m_nSamples; iSmp++) { - const PGDMSAMPLEHEADER pSample = (PGDMSAMPLEHEADER)(lpStream + iSamHeadOffset + (iSmp - 1) * sizeof(GDMSAMPLEHEADER)); + const GDMSAMPLEHEADER *pSample = (GDMSAMPLEHEADER *)(lpStream + iSamHeadOffset + (iSmp - 1) * sizeof(GDMSAMPLEHEADER)); - // sample header + // Sample header memcpy(m_szNames[iSmp], pSample->SamName, 32); StringFixer::SpaceToNullStringFixed<31>(m_szNames[iSmp]); @@ -174,7 +177,7 @@ Samples[iSmp].nLoopEnd = min(LittleEndian(pSample->LoopEnd) - 1, Samples[iSmp].nLength); // dito FrequencyToTranspose(&Samples[iSmp]); // set transpose + finetune for mod files - // fix transpose + finetune for some rare cases where transpose is not C-5 (e.g. sample 4 in wander2.gdm) + // Fix transpose + finetune for some rare cases where transpose is not C-5 (e.g. sample 4 in wander2.gdm) if(m_nType == MOD_TYPE_MOD) { while(Samples[iSmp].RelativeTone != 0) @@ -192,7 +195,7 @@ } } - if(pSample->Flags & 0x01) Samples[iSmp].uFlags |= CHN_LOOP; // loop sample + if(pSample->Flags & 0x01) Samples[iSmp].uFlags |= CHN_LOOP; // Loop sample if(pSample->Flags & 0x04) { @@ -200,10 +203,10 @@ } else { - Samples[iSmp].nVolume = 256; // default volume + Samples[iSmp].nVolume = 256; // Default volume } - if(pSample->Flags & 0x08) // default panning is used + if(pSample->Flags & 0x08) // Default panning is used { Samples[iSmp].uFlags |= CHN_PANNING; Samples[iSmp].nPan = (pSample->Pan > 15) ? 128 : min((pSample->Pan * 16) + 8, 256); // 0...15, 16 = surround (not supported), 255 = no default panning @@ -213,8 +216,8 @@ Samples[iSmp].nPan = 128; } - /* note: apparently (and according to zilym), 2GDM doesn't handle 16 bit or stereo samples properly. - so those flags are pretty much meaningless and we will ignore them... in fact, samples won't load as expected if we don't! */ + // Note: apparently (and according to zilym), 2GDM doesn't handle 16 bit or stereo samples properly. + // so those flags are pretty much meaningless and we will ignore them... in fact, samples won't load as expected if we don't! UINT iSampleFormat; if(pSample->Flags & 0x02) // 16 bit @@ -232,60 +235,60 @@ iSampleFormat = RS_PCM8U; } - // according to zilym, LZW support has never been finished, so this is also practically useless. Just ignore the flag. + // According to zilym, LZW support has never been finished, so this is also practically useless. Just ignore the flag. // if(pSample->Flags & 0x10) {...} - // read sample data + // Read sample data ReadSample(&Samples[iSmp], iSampleFormat, reinterpret_cast<LPCSTR>(lpStream + iSampleOffset), dwMemLength - iSampleOffset); iSampleOffset += min(LittleEndian(pSample->Length), dwMemLength - iSampleOffset); } - // read patterns + // Read patterns Patterns.ResizeArray(max(MAX_PATTERNS, pHeader->NOP + 1)); - bool bS3MCommandSet = (GetBestSaveFormat() & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT)) != 0 ? true : false; + const bool bS3MCommandSet = (GetBestSaveFormat() & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT)) != 0; - // we'll start at position iPatternsOffset and decode all patterns - for (PATTERNINDEX iPat = 0; iPat < pHeader->NOP + 1; iPat++) + // We'll start at position iPatternsOffset and decode all patterns + for(PATTERNINDEX iPat = 0; iPat < pHeader->NOP + 1; iPat++) { if(iPatternsOffset + 2 > dwMemLength) break; - uint16 iPatternLength = LittleEndianW(*(uint16 *)(lpStream + iPatternsOffset)); // pattern length including the two "length" bytes + uint16 iPatternLength = LittleEndianW(*(uint16 *)(lpStream + iPatternsOffset)); // Pattern length including the two "length" bytes if(iPatternLength > dwMemLength || iPatternsOffset > dwMemLength - iPatternLength) break; if(Patterns.Insert(iPat, 64)) break; - // position in THIS pattern + // Position in THIS pattern DWORD iPatternPos = iPatternsOffset + 2; - MODCOMMAND *p = Patterns[iPat]; + for(ROWINDEX iRow = 0; iRow < 64; iRow++) + { + MODCOMMAND *p = Patterns[iPat].GetRow(iRow); - for(UINT iRow = 0; iRow < 64; iRow++) - { - while(true) // zero byte = next row + while(true) // Zero byte = next row { if(iPatternPos + 1 > dwMemLength) break; BYTE bChannel = lpStream[iPatternPos++]; - if(bChannel == 0) break; // next row, please! + if(bChannel == 0) break; // Next row, please! - UINT channel = bChannel & 0x1f; - if(channel >= m_nChannels) break; // better safe than sorry! + const UINT channel = bChannel & 0x1F; + if(channel >= m_nChannels) break; // Better safe than sorry! - MODCOMMAND *m = &p[iRow * m_nChannels + channel]; + MODCOMMAND *m = &p[channel]; if(bChannel & 0x20) { - // note and sample follows + // Note and sample follows if(iPatternPos + 2 > dwMemLength) break; BYTE bNote = lpStream[iPatternPos++]; BYTE bSample = lpStream[iPatternPos++]; - bNote = (bNote & 0x7F) - 1; // this format doesn't have note cuts + bNote = (bNote & 0x7F) - 1; // This format doesn't have note cuts if(bNote < 0xF0) bNote = (bNote & 0x0F) + 12 * (bNote >> 4) + 13; if(bNote == 0xFF) bNote = NOTE_NONE; m->note = bNote; @@ -295,7 +298,7 @@ if(bChannel & 0x40) { - // effect(s) follow + // Effect(s) follow(s) m->command = CMD_NONE; m->volcmd = CMD_NONE; @@ -336,11 +339,11 @@ } break; case 0x0D: command = CMD_PATTERNBREAK; break; - case 0x0E: + case 0x0E: if(bS3MCommandSet) { command = CMD_S3MCMDEX; - // need to do some remapping + // Need to do some remapping switch(param >> 4) { case 0x0: @@ -473,7 +476,7 @@ if(m->command == CMD_S3MCMDEX && ((m->param >> 4) == 0x8) && volcommand == CMD_NONE) { volcommand = VOLCMD_PANNING; - volparam = ((param & 0x0F) << 2) + 2; + volparam = ((param & 0x0F) * 4) + 2; } m->command = command; Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mt2.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -561,7 +561,7 @@ if (pmi->GroupsMapping[i] == iGrp) { UINT nSmp = pmg->nSmpNo+1; - pIns->Keyboard[i+12] = (BYTE)nSmp; + pIns->Keyboard[i + 12] = (SAMPLEINDEX)nSmp; if (nSmp <= m_nSamples) { Samples[nSmp].nVibType = pmi->bVibType; Modified: trunk/OpenMPT/soundlib/Load_psm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_psm.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/soundlib/Load_psm.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -155,7 +155,7 @@ dwMemPos += 12; - memset(m_szNames, 0, sizeof(m_szNames)); + MemsetZero(m_szNames); m_nVSTiVolume = m_nSamplePreAmp = 48; // not supported in this format, so use a good default value Modified: trunk/OpenMPT/soundlib/Message.cpp =================================================================== --- trunk/OpenMPT/soundlib/Message.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/soundlib/Message.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -183,8 +183,8 @@ // [in] lineEnding: line ending formatting of the text in memory. // [in] pTextConverter: Pointer to a callback function which can be used to post-process the written characters, if necessary (nullptr otherwise). // [out] returns formatted song message. -CString CSoundFile::GetSongMessage(const enmLineEndings lineEnding, void (*pTextConverter)(char &)) -//------------------------------------------------------------------------------------------------- +CString CSoundFile::GetSongMessage(const enmLineEndings lineEnding, void (*pTextConverter)(char &)) const +//------------------------------------------------------------------------------------------------------- { CString comments; Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -1255,7 +1255,7 @@ //I'd like to copy other flags too, but this would change playback behaviour. p->dwFlags |= (pChn->dwFlags & (CHN_MUTE|CHN_NOFX)); - p->nMasterChn = nChn+1; + p->nMasterChn = nChn + 1; p->nCommand = 0; //rewbs.VSTiNNA if (applyNNAtoPlug && pPlugin) @@ -1278,10 +1278,14 @@ // Key Off the note switch(pChn->nNNA) { - case NNA_NOTEOFF: KeyOff(n); break; + case NNA_NOTEOFF: + KeyOff(n); + break; case NNA_NOTECUT: p->nFadeOutVol = 0; - case NNA_NOTEFADE: p->dwFlags |= CHN_NOTEFADE; break; + case NNA_NOTEFADE: + p->dwFlags |= CHN_NOTEFADE; + break; } if (!p->nVolume) { @@ -3754,7 +3758,7 @@ if (pIns->VolEnv.nReleaseNode != ENV_RELEASE_NODE_UNSET) { pChn->VolEnv.nEnvValueAtReleaseJump = GetVolEnvValueFromPosition(pChn->VolEnv.nEnvPosition, pIns); - pChn->VolEnv.nEnvPosition= pIns->VolEnv.Ticks[pIns->VolEnv.nReleaseNode]; + pChn->VolEnv.nEnvPosition = pIns->VolEnv.Ticks[pIns->VolEnv.nReleaseNode]; } } @@ -4353,8 +4357,8 @@ // Get the needed vector size for pattern nPat. -size_t CSoundFile::GetVisitedRowsVectorSize(const PATTERNINDEX nPat) -//------------------------------------------------------------------ +size_t CSoundFile::GetVisitedRowsVectorSize(const PATTERNINDEX nPat) const +//------------------------------------------------------------------------ { if(Patterns.IsValidPat(nPat)) { Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/soundlib/Sndfile.h 2011-09-17 22:37:34 UTC (rev 1037) @@ -1116,7 +1116,7 @@ // [in] lineEnding: line ending formatting of the text in memory. // [in] pTextConverter: Pointer to a callback function which can be used to post-process the written characters, if necessary (nullptr otherwise). // [out] returns formatted song message. - CString GetSongMessage(const enmLineEndings lineEnding, void (*pTextConverter)(char &) = nullptr); + CString GetSongMessage(const enmLineEndings lineEnding, void (*pTextConverter)(char &) = nullptr) const; protected: // Read song message from a mapped file. @@ -1157,7 +1157,7 @@ private: void SetRowVisited(const ORDERINDEX nOrd, const ROWINDEX nRow, const bool bVisited = true, VisitedRowsType *pRowVector = nullptr); bool IsRowVisited(const ORDERINDEX nOrd, const ROWINDEX nRow, const bool bAutoSet = true, VisitedRowsType *pRowVector = nullptr); - size_t GetVisitedRowsVectorSize(const PATTERNINDEX nPat); + size_t GetVisitedRowsVectorSize(const PATTERNINDEX nPat) const; public: // "importance" of every FX command. Table is used for importing from formats with multiple effect columns This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |