From: <sag...@us...> - 2009-07-27 21:02:47
|
Revision: 307 http://modplug.svn.sourceforge.net/modplug/?rev=307&view=rev Author: saga-games Date: 2009-07-27 21:02:38 +0000 (Mon, 27 Jul 2009) Log Message: ----------- [Imp] Mod Specs: It is now possible to have modules with 1-3 channels, as this only seems to cause trouble with MOD files (so they still have 4 channels minimum of course). Adjusted some of the module readers for that reason. [Imp] IT Loading: Setting the "last saved with" version to 1.16 (instead of "created with") if module seems to be made with the old MPT [Imp] XM Loading: Doing the same for XM files now [Imp] XM Loading: Less hacky implementation of the instrument loader. Still works correctly with "normal" XM modules and BoobieSqueezed XMs. [Imp] XM Saving: Setting "Open ModPlug Tracker" in the "made with" field (as any other tracker put their signature in here as well) Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_gen.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/soundlib/LOAD_AMF.CPP trunk/OpenMPT/soundlib/LOAD_DBM.CPP trunk/OpenMPT/soundlib/LOAD_DMF.CPP trunk/OpenMPT/soundlib/LOAD_DSM.CPP trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_s3m.cpp trunk/OpenMPT/soundlib/Load_xm.cpp trunk/OpenMPT/soundlib/mod_specifications.h Modified: trunk/OpenMPT/mptrack/Ctrl_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2009-07-27 17:27:59 UTC (rev 306) +++ trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2009-07-27 21:02:38 UTC (rev 307) @@ -235,7 +235,7 @@ // -! NEW_FEATURE#0023 } - wsprintf(s, "%s, %d channels", pszModType, m_pSndFile->m_nChannels); + wsprintf(s, "%s, %d channel%s", pszModType, m_pSndFile->m_nChannels, (m_pSndFile->m_nChannels != 1) ? "s" : ""); m_EditModType.SetWindowText(s); } if (dwHint & HINT_MPTSETUP) Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2009-07-27 17:27:59 UTC (rev 306) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2009-07-27 21:02:38 UTC (rev 307) @@ -3349,10 +3349,13 @@ if (!ChangeModType(dlg.m_nType)) return; bShowLog = TRUE; } - if ((dlg.m_nChannels >= 4) && (dlg.m_nChannels != GetSoundFile()->m_nChannels)) + + UINT nNewChannels = CLAMP(dlg.m_nChannels, m_SndFile.GetModSpecifications().channelsMin, m_SndFile.GetModSpecifications().channelsMax); + + if (nNewChannels != GetSoundFile()->m_nChannels) { const bool showCancelInRemoveDlg = m_SndFile.GetModSpecifications().channelsMax >= m_SndFile.GetNumChannels(); - if(ChangeNumChannels(dlg.m_nChannels, showCancelInRemoveDlg)) bShowLog = TRUE; + if(ChangeNumChannels(nNewChannels, showCancelInRemoveDlg)) bShowLog = TRUE; } if (bShowLog) ShowLog("Conversion Status", CMainFrame::GetMainFrame()); Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2009-07-27 17:27:59 UTC (rev 306) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2009-07-27 21:02:38 UTC (rev 307) @@ -2516,7 +2516,7 @@ CSoundFile* pSndFile; if (pModDoc == 0 || (pSndFile = pModDoc->GetSoundFile()) == 0) return; - if(pSndFile->m_nChannels <= 4) + if(pSndFile->m_nChannels <= pSndFile->GetModSpecifications().channelsMin) { CMainFrame::GetMainFrame()->MessageBox("No channel removed - channel number already at minimum.", "Remove channel", MB_OK | MB_ICONINFORMATION); return; Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2009-07-27 17:27:59 UTC (rev 306) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2009-07-27 21:02:38 UTC (rev 307) @@ -229,7 +229,7 @@ m_ChannelsBox.ResetContent(); for (CHANNELINDEX i=minChans; i<=maxChans; i++) { - wsprintf(s, "%d Channels", i); + wsprintf(s, "%d Channel%s", i, (i != 1) ? "s" : ""); m_ChannelsBox.SetItemData(m_ChannelsBox.AddString(s), i); } if(currChanSel > maxChans) @@ -581,7 +581,7 @@ } if (m_nRemove > 0) { - wsprintf(label, "Select %d channels to remove:", m_nRemove); + wsprintf(label, "Select %d channel%s to remove:", m_nRemove, (m_nRemove != 1) ? "s" : ""); } else { wsprintf(label, "Select channels to remove (the minimum number of remaining channels is %d)", m_pSndFile->GetModSpecifications().channelsMin); } Modified: trunk/OpenMPT/soundlib/LOAD_AMF.CPP =================================================================== --- trunk/OpenMPT/soundlib/LOAD_AMF.CPP 2009-07-27 17:27:59 UTC (rev 306) +++ trunk/OpenMPT/soundlib/LOAD_AMF.CPP 2009-07-27 21:02:38 UTC (rev 307) @@ -268,7 +268,7 @@ || (pfh->version < 10) || (pfh->version > 14) || (!LittleEndianW(pfh->numtracks)) || (!pfh->numorders) || (pfh->numorders > MAX_PATTERNS) || (!pfh->numsamples) || (pfh->numsamples > MAX_SAMPLES) - || (pfh->numchannels < 4) || (pfh->numchannels > 32)) + || (pfh->numchannels < 1) || (pfh->numchannels > 32)) return FALSE; memcpy(m_szNames[0], pfh->title, 31); dwMemPos = sizeof(AMFFILEHEADER); Modified: trunk/OpenMPT/soundlib/LOAD_DBM.CPP =================================================================== --- trunk/OpenMPT/soundlib/LOAD_DBM.CPP 2009-07-27 17:27:59 UTC (rev 306) +++ trunk/OpenMPT/soundlib/LOAD_DBM.CPP 2009-07-27 21:02:38 UTC (rev 307) @@ -116,7 +116,7 @@ nPatterns = BigEndianW(pfh->patterns); m_nType = MOD_TYPE_DBM; m_nChannels = BigEndianW(pfh->channels); - if (m_nChannels < 4) m_nChannels = 4; + if (m_nChannels < 1) m_nChannels = 1; if (m_nChannels > 64) m_nChannels = 64; memcpy(m_szNames[0], (pfh->songname[0]) ? pfh->songname : pfh->songname2, 32); m_szNames[0][31] = 0; Modified: trunk/OpenMPT/soundlib/LOAD_DMF.CPP =================================================================== --- trunk/OpenMPT/soundlib/LOAD_DMF.CPP 2009-07-27 17:27:59 UTC (rev 306) +++ trunk/OpenMPT/soundlib/LOAD_DMF.CPP 2009-07-27 21:02:38 UTC (rev 307) @@ -164,7 +164,7 @@ m_nChannels = patt->tracks; if (m_nChannels < patt->firstpatinfo) m_nChannels = patt->firstpatinfo; if (m_nChannels > 32) m_nChannels = 32; - if (m_nChannels < 4) m_nChannels = 4; + if (m_nChannels < 1) m_nChannels = 1; for (UINT npat=0; npat<numpat; npat++) { DMFTRACK *pt = (DMFTRACK *)(lpStream+dwPos); Modified: trunk/OpenMPT/soundlib/LOAD_DSM.CPP =================================================================== --- trunk/OpenMPT/soundlib/LOAD_DSM.CPP 2009-07-27 17:27:59 UTC (rev 306) +++ trunk/OpenMPT/soundlib/LOAD_DSM.CPP 2009-07-27 21:02:38 UTC (rev 307) @@ -101,7 +101,7 @@ dwMemPos = sizeof(DSMFILEHEADER) + pfh->song_len; m_nType = MOD_TYPE_DSM; m_nChannels = psong->numtrk; - if (m_nChannels < 4) m_nChannels = 4; + if (m_nChannels < 1) m_nChannels = 1; if (m_nChannels > 16) m_nChannels = 16; m_nSamples = psong->numsmp; if (m_nSamples > MAX_SAMPLES) m_nSamples = MAX_SAMPLES; Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2009-07-27 17:27:59 UTC (rev 306) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2009-07-27 21:02:38 UTC (rev 307) @@ -963,7 +963,7 @@ //TODO: Check whether above interpretation is reasonable especially for //values 0x217 and 0x200 which are the values used in 1.16. if(pifh->cwtv == 0x217 && pifh->cmwt == 0x200) - m_dwCreatedWithVersion = MAKE_VERSION_NUMERIC(1, 16, 0, 0); + m_dwLastSavedWithVersion = MAKE_VERSION_NUMERIC(1, 16, 0, 0); } } Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_s3m.cpp 2009-07-27 17:27:59 UTC (rev 306) +++ trunk/OpenMPT/soundlib/Load_s3m.cpp 2009-07-27 21:02:38 UTC (rev 307) @@ -291,7 +291,7 @@ ChnSettings[ich].dwFlags = 0; } } - if (m_nChannels < 4) m_nChannels = 4; + if (m_nChannels < 1) m_nChannels = 1; if ((psfh.cwtv < 0x1320) || (psfh.flags & 0x40)) m_dwSongFlags |= SONG_FASTVOLSLIDES; // Reading pattern order UINT iord = psfh.ordnum; Modified: trunk/OpenMPT/soundlib/Load_xm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_xm.cpp 2009-07-27 17:27:59 UTC (rev 306) +++ trunk/OpenMPT/soundlib/Load_xm.cpp 2009-07-27 21:02:38 UTC (rev 307) @@ -39,16 +39,16 @@ typedef struct tagXMINSTRUMENTHEADER { - DWORD size; + DWORD size; // size of XMINSTRUMENTHEADER + XMSAMPLEHEADER CHAR name[22]; - BYTE type; + BYTE type; // should always be 0 WORD samples; } XMINSTRUMENTHEADER; typedef struct tagXMSAMPLEHEADER { - DWORD shsize; + DWORD shsize; // size of XMSAMPLESTRUCT BYTE snum[96]; WORD venv[24]; WORD penv[24]; @@ -315,21 +315,18 @@ if ((nsamples = pih->samples) > 0) { - if (dwMemPos + sizeof(XMINSTRUMENTHEADER) + sizeof(DWORD) >= dwMemLength) return TRUE; - DWORD shsize = LittleEndian(*((DWORD *)(lpStream + dwMemPos + sizeof(XMINSTRUMENTHEADER)))); + /* we have sample, so let's read the rest of this instrument + the header that is being read here is not the sample header, though, + it's rather the instrument settings. */ + if (dwMemPos + ihsize >= dwMemLength) + return TRUE; + memset(&xmsh, 0, sizeof(XMSAMPLEHEADER)); - - // *very* dirty, but it works! - DWORD dwReadLength = sizeof(XMSAMPLEHEADER); - if(ihsize == 38 && (int)(shsize - ihsize) >= 0) // BoobieSqueezer compressed - ihsize = 38, shsize = 40 - dwReadLength = shsize - ihsize; + memcpy(&xmsh, + lpStream + dwMemPos + sizeof(XMINSTRUMENTHEADER), + min(ihsize - sizeof(XMINSTRUMENTHEADER), sizeof(XMSAMPLEHEADER))); - if (dwMemPos + sizeof(XMINSTRUMENTHEADER) + dwReadLength >= dwMemLength || shsize > sizeof(XMSAMPLEHEADER)) - return TRUE; - else - memcpy(&xmsh, lpStream + dwMemPos + sizeof(XMINSTRUMENTHEADER), dwReadLength); - xmsh.shsize = LittleEndian(xmsh.shsize); for (int i = 0; i < 24; ++i) { @@ -628,7 +625,11 @@ bMadeWithModPlug = true; } - SetModFlag(MSF_COMPATIBLE_PLAY, !bMadeWithModPlug); + if(bMadeWithModPlug) + { + SetModFlag(MSF_COMPATIBLE_PLAY, false); + m_dwLastSavedWithVersion = MAKE_VERSION_NUMERIC(1, 16, 0, 0); + } // -> CODE#0027 // -> DESC="per-instrument volume ramping setup (refered as attack)" @@ -670,7 +671,7 @@ fwrite("Extended Module: ", 17, 1, f); fwrite(m_szNames[0], 20, 1, f); s[0] = 0x1A; - lstrcpy((LPSTR)&s[1], (nPacking) ? "MOD Plugin packed " : "Open ModPlugTracker "); + lstrcpy((LPSTR)&s[1], (nPacking) ? "MOD Plugin packed " : "Open ModPlug Tracker"); s[21] = 0x04; s[22] = 0x01; fwrite(&s[0], 23, 1, f); Modified: trunk/OpenMPT/soundlib/mod_specifications.h =================================================================== --- trunk/OpenMPT/soundlib/mod_specifications.h 2009-07-27 17:27:59 UTC (rev 306) +++ trunk/OpenMPT/soundlib/mod_specifications.h 2009-07-27 21:02:38 UTC (rev 307) @@ -9,15 +9,15 @@ struct CModSpecifications //======================= { - // Return true iff format supports given note. + // Return true if format supports given note. bool HasNote(MODCOMMAND::NOTE note) const; //NOTE: If changing order, update all initializations below. char fileExtension[6]; // File extension without dot. MODCOMMAND::NOTE noteMin; // Minimum note index (index starts from 1) MODCOMMAND::NOTE noteMax; // Maximum note index (index starts from 1) - bool hasNoteCut; // True iff format has notecut. - bool hasNoteOff; // True iff format has noteoff. + bool hasNoteCut; // True if format has notecut. + bool hasNoteOff; // True if format has noteoff. PATTERNINDEX patternsMax; ORDERINDEX ordersMax; CHANNELINDEX channelsMin; // Minimum number of editable channels in pattern. @@ -53,7 +53,7 @@ true, //Has noteoff. 4000, //Pattern max. 4000, //Order max. - 4, //Channel min + 1, //Channel min 127, //Channel max 32, //Min tempo 512, //Max tempo @@ -132,7 +132,7 @@ true, //Has noteoff. 64, //Pattern max. 128, //Order max. - 4, //Channel min + 1, //Channel min 32, //Channel max 32, //Min tempo 255, //Max tempo @@ -158,7 +158,7 @@ true, //Has noteoff. 240, //Pattern max. 256, //Order max. - 4, //Channel min + 1, //Channel min 127, //Channel max 32, //Min tempo 512, //Max tempo @@ -183,7 +183,7 @@ false, //No noteoff. 240, //Pattern max. 256, //Order max. - 4, //Channel min + 1, //Channel min 32, //Channel max 32, //Min tempo 255, //Max tempo @@ -209,7 +209,7 @@ false, //No noteoff. 240, //Pattern max. 256, //Order max. - 4, //Channel min + 1, //Channel min 32, //Channel max 32, //Min tempo 255, //Max tempo @@ -234,7 +234,7 @@ true, //Has noteoff. 240, //Pattern max. 200, //Order max. - 4, //Channel min + 1, //Channel min 64, //Channel max 32, //Min tempo 255, //Max tempo @@ -259,7 +259,7 @@ true, //Has noteoff. 240, //Pattern max. 256, //Order max. - 4, //Channel min + 1, //Channel min 127, //Channel max 32, //Min tempo 512, //Max tempo This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |