From: <rel...@us...> - 2009-06-06 19:11:22
|
Revision: 263 http://modplug.svn.sourceforge.net/modplug/?rev=263&view=rev Author: relabsoluness Date: 2009-06-06 19:11:18 +0000 (Sat, 06 Jun 2009) Log Message: ----------- + IT/MTPM: Channel settings(vol&pan) for channels after 64 will now be saved in the file. . XM/IT/MPTM: Fixed a bug in reading an extension. This broke the extension search after reading that entry, although the affected entry has been the last extension in the write order. ? Minor tweaks. Modified Paths: -------------- trunk/OpenMPT/mptrack/View_gen.cpp trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Sndfile.cpp Modified: trunk/OpenMPT/mptrack/View_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_gen.cpp 2009-06-06 18:49:52 UTC (rev 262) +++ trunk/OpenMPT/mptrack/View_gen.cpp 2009-06-06 19:11:18 UTC (rev 263) @@ -656,13 +656,14 @@ pModDoc = GetDocument(); nChn = m_nActiveTab * 4; - if ((pModDoc) && (!IsLocked()) && (nChn < 64)) + if ((pModDoc) && (!IsLocked()) && (nChn < MAX_BASECHANNELS)) { BOOL bUpdate = FALSE; short int pos; LockControls(); - for (UINT iCh=0; iCh<4; iCh++) + const UINT nLoopLimit = pModDoc->GetSoundFile()->GetNumChannels() - nChn; + for (UINT iCh=0; iCh<nLoopLimit; iCh++) { // Volume sliders pos = (short int)m_sbVolume[iCh].GetPos(); Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2009-06-06 18:49:52 UTC (rev 262) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2009-06-06 19:11:18 UTC (rev 263) @@ -917,8 +917,8 @@ } // -! NEW_FEATURE#0023 -BOOL CSoundFile::ReadIT(const BYTE *lpStream, const DWORD dwMemLength) -//-------------------------------------------------------------- +BOOL CSoundFile::ReadIT(const LPCBYTE lpStream, const DWORD dwMemLength) +//---------------------------------------------------------------------- { ITFILEHEADER *pifh = (ITFILEHEADER *)lpStream; @@ -3595,6 +3595,23 @@ fwrite(&size, 1, sizeof(__int16), f); fwrite(&m_nChannels, 1, size, f); + if(TypeIsIT_MPT() && m_nChannels > 64) //IT header has room only for 64 channels. Save the + { //settings that do not fit to the header here as an extension. + code = 'ChnS'; + fwrite(&code, 1, sizeof(__int32), f); + size = (m_nChannels - 64)*2; + fwrite(&size, 1, sizeof(__int16), f); + for(UINT ich = 64; ich < m_nChannels; ich++) + { + BYTE panvol[2]; + panvol[0] = ChnSettings[ich].nPan >> 2; + if (ChnSettings[ich].dwFlags & CHN_SURROUND) panvol[0] = 100; + if (ChnSettings[ich].dwFlags & CHN_MUTE) panvol[0] |= 0x80; + panvol[1] = ChnSettings[ich].nVolume; + fwrite(&panvol, sizeof(panvol), 1, f); + } + } + code = 'TM..'; //write m_nTempoMode fwrite(&code, 1, sizeof(__int32), f); size = sizeof(m_nTempoMode); @@ -3675,13 +3692,13 @@ } -void CSoundFile::LoadExtendedSongProperties(const MODTYPE modtype, BYTE*& ptr, const BYTE* lpStream, const size_t searchlimit) +void CSoundFile::LoadExtendedSongProperties(const MODTYPE modtype, BYTE*& ptr, const LPCBYTE lpStream, const size_t searchlimit) //-------------------------------------------------- { int32 code = 0; int16 size = 0; ptr += sizeof(int32); // jump extension header code - while( (DWORD)(ptr + 6 - lpStream) <= searchlimit ) //Loop until given limit. + while( (DWORD)((ptr + 6) - lpStream) <= searchlimit ) //Loop until given limit. { code = (*((__int32 *)ptr)); // read field code ptr += sizeof(__int32); // jump field code @@ -3708,15 +3725,27 @@ if(DWORD(ptr - lpStream + DWORD(size)) > searchlimit) MessageBox(NULL, "Error: Bad MIMA datasizefield", NULL, MB_ICONERROR); else + GetMIDIMapper().Unserialize(ptr, size); + break; + case 'ChnS': + if( ((ptr - lpStream) + DWORD(size) <= searchlimit) && (size <= 63*2) && (size % 2 == 0) ) { - GetMIDIMapper().Unserialize(ptr, size); - ptr += size; + const BYTE* pData = ptr; + for(__int16 i = 0; i<size/2; i++, pData += 2) if(pData[0] != 0xFF) + { + ChnSettings[i+64].nVolume = pData[1]; + ChnSettings[i+64].nPan = 128; + if (pData[0] & 0x80) ChnSettings[i+64].dwFlags |= CHN_MUTE; + const UINT n = pData[0] & 0x7F; + if (n <= 64) ChnSettings[i+64].nPan = n << 2; + if (n == 100) ChnSettings[i+64].dwFlags |= CHN_SURROUND; + } } break; } - if (fadr != NULL && ptr - lpStream + DWORD(size) <= searchlimit) { // if field code recognized + if (fadr != NULL && (ptr - lpStream) + DWORD(size) <= searchlimit) { // if field code recognized memcpy(fadr,ptr,size); // read field data } ptr += size; // jump field data Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2009-06-06 18:49:52 UTC (rev 262) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2009-06-06 19:11:18 UTC (rev 263) @@ -136,6 +136,7 @@ [EXT] means external (not related) to INSTRUMENTHEADER content C... [EXT] nChannels +ChnS [EXT] IT/MPTM: Channel settings for channels 65-127 if needed (doesn't fit to IT header). CS.. nCutSwing CWV. [EXT] dwCreatedWithVersion DCT. nDCT; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |