From: <sag...@us...> - 2009-09-01 22:08:51
|
Revision: 352 http://modplug.svn.sourceforge.net/modplug/?rev=352&view=rev Author: saga-games Date: 2009-09-01 22:08:43 +0000 (Tue, 01 Sep 2009) Log Message: ----------- [Imp] S3M saver: Orderlist is now as small as possible (multiple of 2 instead of multiple of 16); Using ST3's default UltraClick value [Imp] PSM loader: "Cosmetic" changes (use default values of first subtune for default speed/tempo/panning/etc., don't touch patterns if only one subtune is present. Modified Paths: -------------- trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/soundlib/Load_psm.cpp trunk/OpenMPT/soundlib/Load_s3m.cpp Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2009-09-01 18:50:33 UTC (rev 351) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2009-09-01 22:08:43 UTC (rev 352) @@ -2077,7 +2077,7 @@ #define MOD_TYPE_XMIT (MOD_TYPE_XM|MOD_TYPE_IT) #define MOD_TYPE_XMITMPT (MOD_TYPE_XM|MOD_TYPE_IT|MOD_TYPE_MPT) #define MOD_TYPE_ITMPT (MOD_TYPE_IT|MOD_TYPE_MPT) -#define MAX_FXINFO 66 //rewbs.smoothVST, increased from 64... I wonder what this will break? +#define MAX_FXINFO 68 //rewbs.smoothVST, increased from 64... I wonder what this will break? const MPTEFFECTINFO gFXInfo[MAX_FXINFO] = @@ -2153,8 +2153,10 @@ {CMD_S3MCMDEX, 0xF0,0x70, 0, MOD_TYPE_ITMPT, "Instr. control"}, // -> CODE#0010 // -> DESC="add extended parameter mechanism to pattern effects" - {CMD_XPARAM, 0x00,0x00, 0, MOD_TYPE_XMITMPT, "X param"} + {CMD_XPARAM, 0x00,0x00, 0, MOD_TYPE_XMITMPT, "X param"}, // -! NEW_FEATURE#0010 + {CMD_NOTESLIDEUP, 0x00,0x00, 0, 0, "Note Slide Up"}, // .IMF effect + {CMD_NOTESLIDEDOWN, 0x00,0x00, 0, 0, "Note Slide Down"}, // .IMF effect }; Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2009-09-01 18:50:33 UTC (rev 351) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2009-09-01 22:08:43 UTC (rev 352) @@ -1689,6 +1689,7 @@ "coda for sample drawing code|" "http://coda.s3m.us/|" "Storlek for all the IT compatibility hints and testcases|" + "as well as the IMF loader|" "http://schismtracker.org/|" "Pel K. Txnder for the scrolling credits control :)|" "http://tinyurl.com/4yze8|" Modified: trunk/OpenMPT/soundlib/Load_psm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_psm.cpp 2009-09-01 18:50:33 UTC (rev 351) +++ trunk/OpenMPT/soundlib/Load_psm.cpp 2009-09-01 22:08:43 UTC (rev 352) @@ -283,13 +283,13 @@ case 0x07: // Default Speed if(dwSettingsOffset - dwChunkPos + 2 > subChunkSize) break; - m_nDefaultSpeed = subsong.defaultSpeed = lpStream[dwSettingsOffset + 1]; + subsong.defaultSpeed = lpStream[dwSettingsOffset + 1]; dwSettingsOffset += 2; break; case 0x08: // Default Tempo if(dwSettingsOffset - dwChunkPos + 2 > subChunkSize) break; - m_nDefaultTempo = subsong.defaultTempo = lpStream[dwSettingsOffset + 1]; + subsong.defaultTempo = lpStream[dwSettingsOffset + 1]; dwSettingsOffset += 2; break; @@ -313,20 +313,17 @@ switch(lpStream[dwSettingsOffset + 3]) { case 0: // use panning - ChnSettings[nChn].nPan = subsong.channelPanning[nChn] = lpStream[dwSettingsOffset + 2] ^ 128; - ChnSettings[nChn].dwFlags &= ~CHN_SURROUND; + subsong.channelPanning[nChn] = lpStream[dwSettingsOffset + 2] ^ 128; subsong.channelSurround[nChn] = false; break; case 2: // surround - ChnSettings[nChn].nPan = subsong.channelPanning[nChn] = 128; - ChnSettings[nChn].dwFlags |= CHN_SURROUND; + subsong.channelPanning[nChn] = 128; subsong.channelSurround[nChn] = true; break; case 4: // center - ChnSettings[nChn].nPan = subsong.channelPanning[nChn] = 128; - ChnSettings[nChn].dwFlags &= ~CHN_SURROUND; + subsong.channelPanning[nChn] = 128; subsong.channelSurround[nChn] = false; break; @@ -341,10 +338,10 @@ dwSettingsOffset += 4; break; - case 0x0E: // Channel volume table (0...255) + case 0x0E: // Channel volume table (0...255) - apparently always 255 if(dwSettingsOffset - dwChunkPos + 3 > subChunkSize) break; if(lpStream[dwSettingsOffset + 1] < MAX_BASECHANNELS) - ChnSettings[lpStream[dwSettingsOffset + 1]].nVolume = subsong.channelVolume[lpStream[dwSettingsOffset + 1]] = (lpStream[dwSettingsOffset + 2] >> 2) + 1; + subsong.channelVolume[lpStream[dwSettingsOffset + 1]] = (lpStream[dwSettingsOffset + 2] >> 2) + 1; dwSettingsOffset += 3; break; @@ -375,20 +372,17 @@ switch(lpStream[dwChunkPos + i]) { case 0: // use panning - ChnSettings[nChn].nPan = subsong.channelPanning[nChn] = lpStream[dwChunkPos + i + 1] ^ 128; - ChnSettings[nChn].dwFlags &= ~CHN_SURROUND; + subsong.channelPanning[nChn] = lpStream[dwChunkPos + i + 1] ^ 128; subsong.channelSurround[nChn] = false; break; case 2: // surround - ChnSettings[nChn].nPan = subsong.channelPanning[nChn] = 128; - ChnSettings[nChn].dwFlags |= CHN_SURROUND; + subsong.channelPanning[nChn] = 128; subsong.channelSurround[nChn] = true; break; case 4: // center - ChnSettings[nChn].nPan = subsong.channelPanning[nChn] = 128; - ChnSettings[nChn].dwFlags &= ~CHN_SURROUND; + subsong.channelPanning[nChn] = 128; subsong.channelSurround[nChn] = false; break; } @@ -478,9 +472,23 @@ dwMemPos += chunkSize; } - if(m_nChannels == 0) + if(m_nChannels == 0 || subsongs.size() == 0) return false; + // Make the default variables of the first subsong global + m_nDefaultSpeed = subsongs[0].defaultSpeed; + m_nDefaultTempo = subsongs[0].defaultTempo; + m_nRestartPos = subsongs[0].restartPos; + for(CHANNELINDEX nChn = 0; nChn < m_nChannels; nChn++) + { + ChnSettings[nChn].nVolume = subsongs[0].channelVolume[nChn]; + ChnSettings[nChn].nPan = subsongs[0].channelPanning[nChn]; + if(subsongs[0].channelSurround[nChn]) + ChnSettings[nChn].dwFlags |= CHN_SURROUND; + else + ChnSettings[nChn].dwFlags &= ~CHN_SURROUND; + } + // Now that we know the number of channels, we can go through all the patterns. // This is a bit stupid since we will even read duplicate patterns twice, but hey, we do this just once... so who cares? PATTERNINDEX nPat = 0; @@ -582,7 +590,7 @@ case 0x04: // volslide down command = CMD_VOLUMESLIDE; if (bNewFormat) param &= 0x0F; - else param = (param >> 1) & 0x0F; + else if(param < 2) param |= 0xF0; else param = (param >> 1) & 0x0F; break; // Portamento @@ -728,48 +736,51 @@ nPat++; } - // write subsong "configuration" to patterns - for(uint32 i = 0; i < subsongs.size(); i++) + if(subsongs.size() > 1) { - PATTERNINDEX startPattern = Order[subsongs[i].startOrder], endPattern = Order[subsongs[i].endOrder]; - if(startPattern == PATTERNINDEX_INVALID || endPattern == PATTERNINDEX_INVALID) continue; // what, invalid subtune? + // write subsong "configuration" to patterns (only if there are multiple subsongs) + for(uint32 i = 0; i < subsongs.size(); i++) + { + PATTERNINDEX startPattern = Order[subsongs[i].startOrder], endPattern = Order[subsongs[i].endOrder]; + if(startPattern == PATTERNINDEX_INVALID || endPattern == PATTERNINDEX_INVALID) continue; // what, invalid subtune? - // set the subsong name to all pattern names - for(PATTERNINDEX nPat = startPattern; nPat <= endPattern; nPat++) - { - SetPatternName(nPat, subsongs[i].songName); - } - - // subsongs with different panning setup -> write to pattern (MUSIC_C.PSM) - if(bSubsongPanningDiffers) - { - for(CHANNELINDEX nChn = 0; nChn < m_nChannels; nChn++) + // set the subsong name to all pattern names + for(PATTERNINDEX nPat = startPattern; nPat <= endPattern; nPat++) { - if(subsongs[i].channelSurround[nChn] == true) - TryWriteEffect(startPattern, 0, CMD_S3MCMDEX, 0x91, false, nChn, false, true); - else - TryWriteEffect(startPattern, 0, CMD_PANNING8, subsongs[i].channelPanning[nChn], false, nChn, false, true); + SetPatternName(nPat, subsongs[i].songName); } - } - // write default tempo/speed to pattern - TryWriteEffect(startPattern, 0, CMD_SPEED, subsongs[i].defaultSpeed, false, CHANNELINDEX_INVALID, false, true); - TryWriteEffect(startPattern, 0, CMD_TEMPO, subsongs[i].defaultTempo, false, CHANNELINDEX_INVALID, false, true); - // don't write channel volume for now, as it's always set to 100% anyway + // subsongs with different panning setup -> write to pattern (MUSIC_C.PSM) + if(bSubsongPanningDiffers) + { + for(CHANNELINDEX nChn = 0; nChn < m_nChannels; nChn++) + { + if(subsongs[i].channelSurround[nChn] == true) + TryWriteEffect(startPattern, 0, CMD_S3MCMDEX, 0x91, false, nChn, false, true); + else + TryWriteEffect(startPattern, 0, CMD_PANNING8, subsongs[i].channelPanning[nChn], false, nChn, false, true); + } + } + // write default tempo/speed to pattern + TryWriteEffect(startPattern, 0, CMD_SPEED, subsongs[i].defaultSpeed, false, CHANNELINDEX_INVALID, false, true); + TryWriteEffect(startPattern, 0, CMD_TEMPO, subsongs[i].defaultTempo, false, CHANNELINDEX_INVALID, false, true); - // there's a restart pos, so let's try to insert a Bxx command in the last pattern - if(subsongs[i].restartPos != ORDERINDEX_INVALID) - { - ROWINDEX lastRow = Patterns[endPattern].GetNumRows() - 1; - MODCOMMAND *row_data; - row_data = Patterns[endPattern]; - for(uint32 nCell = 0; nCell < m_nChannels * Patterns[endPattern].GetNumRows(); nCell++) + // don't write channel volume for now, as it's always set to 100% anyway + + // there's a restart pos, so let's try to insert a Bxx command in the last pattern + if(subsongs[i].restartPos != ORDERINDEX_INVALID) { - if(row_data->command == CMD_PATTERNBREAK || row_data->command == CMD_POSITIONJUMP) - lastRow = nCell / m_nChannels; - row_data++; + ROWINDEX lastRow = Patterns[endPattern].GetNumRows() - 1; + MODCOMMAND *row_data; + row_data = Patterns[endPattern]; + for(uint32 nCell = 0; nCell < m_nChannels * Patterns[endPattern].GetNumRows(); nCell++) + { + if(row_data->command == CMD_PATTERNBREAK || row_data->command == CMD_POSITIONJUMP) + lastRow = nCell / m_nChannels; + row_data++; + } + TryWriteEffect(endPattern, lastRow, CMD_POSITIONJUMP, (BYTE)subsongs[i].restartPos, false, CHANNELINDEX_INVALID, false, true); } - TryWriteEffect(endPattern, lastRow, CMD_POSITIONJUMP, (BYTE)subsongs[i].restartPos, false, CHANNELINDEX_INVALID, false, true); } } Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_s3m.cpp 2009-09-01 18:50:33 UTC (rev 351) +++ trunk/OpenMPT/soundlib/Load_s3m.cpp 2009-09-01 22:08:43 UTC (rev 352) @@ -527,7 +527,6 @@ nbo = 2; else if (nbo & 1) // number of orders must be even nbo++; - nbo = (nbo + 15) & 0xF0; // TODO why does it not work otherwise? nbo should be multiple of 2, not 16! if(nbo > 0xF0) nbo = 0xF0; // sequence too long header[0x20] = nbo & 0xFF; header[0x21] = nbo >> 8; @@ -560,7 +559,7 @@ header[0x31] = CLAMP(m_nDefaultSpeed, 1, 255); header[0x32] = CLAMP(m_nDefaultTempo, 32, 255); header[0x33] = CLAMP(m_nSamplePreAmp, 0x10, 0x7F) | 0x80; // Bit 8 = Stereo - header[0x34] = 0x10; // 16 Channels for UltraClick removal + header[0x34] = 0x08; // 8 Channels for UltraClick removal (default) header[0x35] = 0xFC; // Write pan positions for (i=0; i<32; i++) { @@ -571,7 +570,7 @@ } else header[0x40+i] = 0xFF; } fwrite(header, 0x60, 1, f); - Order.WriteAsByte(f, nbo); + nbo = Order.WriteAsByte(f, nbo); memset(patptr, 0, sizeof(patptr)); memset(insptr, 0, sizeof(insptr)); UINT ofs0 = 0x60 + nbo; @@ -595,6 +594,7 @@ { fwrite(S3MFiller, 0x10 - ((nbi*2+nbp*2) & 0x0F), 1, f); } + fseek(f, ofs1, SEEK_SET); ofs1 = ftell(f); fwrite(insex, nbi, 0x50, f); // Packing patterns This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |