You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
(1) |
Apr
(1) |
May
|
Jun
(1) |
Jul
|
Aug
(10) |
Sep
|
Oct
|
Nov
|
Dec
(3) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(1) |
Feb
(2) |
Mar
(3) |
Apr
(2) |
May
(10) |
Jun
(2) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
|
| 2008 |
Jan
(6) |
Feb
(4) |
Mar
(5) |
Apr
(2) |
May
(1) |
Jun
(1) |
Jul
(4) |
Aug
(6) |
Sep
(2) |
Oct
(9) |
Nov
(1) |
Dec
(4) |
| 2009 |
Jan
(9) |
Feb
(2) |
Mar
(2) |
Apr
(2) |
May
(6) |
Jun
(18) |
Jul
(33) |
Aug
(39) |
Sep
(33) |
Oct
(24) |
Nov
(23) |
Dec
(22) |
| 2010 |
Jan
(29) |
Feb
(32) |
Mar
(51) |
Apr
(17) |
May
(31) |
Jun
(21) |
Jul
(32) |
Aug
(28) |
Sep
(35) |
Oct
(27) |
Nov
(11) |
Dec
(13) |
| 2011 |
Jan
(14) |
Feb
(13) |
Mar
(27) |
Apr
(27) |
May
(28) |
Jun
(20) |
Jul
(43) |
Aug
(52) |
Sep
(66) |
Oct
(61) |
Nov
(11) |
Dec
(8) |
| 2012 |
Jan
(20) |
Feb
(30) |
Mar
(38) |
Apr
(21) |
May
(33) |
Jun
(21) |
Jul
(25) |
Aug
(9) |
Sep
(24) |
Oct
(42) |
Nov
(27) |
Dec
(41) |
| 2013 |
Jan
(20) |
Feb
(35) |
Mar
(156) |
Apr
(298) |
May
(258) |
Jun
(201) |
Jul
(105) |
Aug
(60) |
Sep
(193) |
Oct
(245) |
Nov
(280) |
Dec
(194) |
| 2014 |
Jan
(63) |
Feb
(202) |
Mar
(200) |
Apr
(23) |
May
(53) |
Jun
(105) |
Jul
(18) |
Aug
(26) |
Sep
(110) |
Oct
(187) |
Nov
(97) |
Dec
(74) |
| 2015 |
Jan
(45) |
Feb
(55) |
Mar
(116) |
Apr
(116) |
May
(193) |
Jun
(164) |
Jul
(50) |
Aug
(111) |
Sep
(98) |
Oct
(71) |
Nov
(103) |
Dec
(63) |
| 2016 |
Jan
(33) |
Feb
(101) |
Mar
(182) |
Apr
(139) |
May
(140) |
Jun
(103) |
Jul
(165) |
Aug
(286) |
Sep
(208) |
Oct
(127) |
Nov
(97) |
Dec
(54) |
| 2017 |
Jan
(64) |
Feb
(335) |
Mar
(202) |
Apr
(212) |
May
(139) |
Jun
(127) |
Jul
(294) |
Aug
(154) |
Sep
(170) |
Oct
(152) |
Nov
(156) |
Dec
(62) |
| 2018 |
Jan
(168) |
Feb
(237) |
Mar
(196) |
Apr
(174) |
May
(174) |
Jun
(161) |
Jul
(127) |
Aug
(88) |
Sep
(149) |
Oct
(66) |
Nov
(52) |
Dec
(135) |
| 2019 |
Jan
(146) |
Feb
(126) |
Mar
(104) |
Apr
(58) |
May
(60) |
Jun
(28) |
Jul
(197) |
Aug
(129) |
Sep
(141) |
Oct
(148) |
Nov
(63) |
Dec
(100) |
| 2020 |
Jan
(74) |
Feb
(37) |
Mar
(59) |
Apr
(154) |
May
(194) |
Jun
(133) |
Jul
(313) |
Aug
(197) |
Sep
(49) |
Oct
(162) |
Nov
(143) |
Dec
(57) |
| 2021 |
Jan
(120) |
Feb
(107) |
Mar
(314) |
Apr
(157) |
May
(524) |
Jun
(169) |
Jul
(72) |
Aug
(133) |
Sep
(135) |
Oct
(146) |
Nov
(198) |
Dec
(325) |
| 2022 |
Jan
(409) |
Feb
(249) |
Mar
(138) |
Apr
(95) |
May
(102) |
Jun
(221) |
Jul
(66) |
Aug
(120) |
Sep
(192) |
Oct
(131) |
Nov
(53) |
Dec
(171) |
| 2023 |
Jan
(357) |
Feb
(82) |
Mar
(168) |
Apr
(218) |
May
(196) |
Jun
(86) |
Jul
(115) |
Aug
(49) |
Sep
(190) |
Oct
(102) |
Nov
(45) |
Dec
(76) |
| 2024 |
Jan
(86) |
Feb
(50) |
Mar
(324) |
Apr
(209) |
May
(197) |
Jun
(232) |
Jul
(194) |
Aug
(247) |
Sep
(219) |
Oct
(266) |
Nov
(328) |
Dec
(304) |
| 2025 |
Jan
(191) |
Feb
(115) |
Mar
(137) |
Apr
(32) |
May
(126) |
Jun
(403) |
Jul
(213) |
Aug
(203) |
Sep
(148) |
Oct
(109) |
Nov
(191) |
Dec
(209) |
| 2026 |
Jan
(127) |
Feb
(123) |
Mar
(160) |
Apr
(141) |
May
(45) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <sag...@us...> - 2010-07-16 23:18:47
|
Revision: 651
http://modplug.svn.sourceforge.net/modplug/?rev=651&view=rev
Author: saga-games
Date: 2010-07-16 23:18:40 +0000 (Fri, 16 Jul 2010)
Log Message:
-----------
[Imp] Small improvements to PSM loader.
[Mod] Added new formats to GetPeriodFromNote(). (Since they are automatically converted to something usesable, this doesn't change anything in OpenMPT).
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_psm.cpp
trunk/OpenMPT/soundlib/Snd_fx.cpp
Modified: trunk/OpenMPT/soundlib/Load_psm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_psm.cpp 2010-07-16 21:46:18 UTC (rev 650)
+++ trunk/OpenMPT/soundlib/Load_psm.cpp 2010-07-16 23:18:40 UTC (rev 651)
@@ -7,7 +7,7 @@
* gave me a few clues. :)
*
* What's playing?
- * - Epic Pinball - Perfect! (I don't have an old version with the PSM16 tunes to compare, though - some of them differ from the new PSM tunes)
+ * - Epic Pinball - Perfect! (menu and order song are pitched up a bit in the PSM16 format for unknown reasons, but that shouldn't bother anyone)
* - Extreme Pinball - Perfect! (subtunes included!)
* - Jazz Jackrabbit - Perfect!
* - One Must Fall! - Perfect! (it helped a lot to have the original MTM files...)
@@ -31,7 +31,22 @@
// New PSM support starts here. PSM16 structs are below.
//
+// 32-Bit PSM header identifiers
+#define PSM16HEAD_PSM_ 0xFE4D5350
+#define PSMHEAD_PSM_ 0x204D5350
+#define PSMHEAD_FILE 0x454C4946
+// 32-Bit chunk identifiers
+#define PSMCHUNKID_TITL 0x4C544954
+#define PSMCHUNKID_SDFT 0x54464453
+#define PSMCHUNKID_PBOD 0x444F4250
+#define PSMCHUNKID_SONG 0x474E4F53
+#define PSMCHUNKID_DATE 0x45544144
+#define PSMCHUNKID_OPLH 0x484C504F
+#define PSMCHUNKID_PPAN 0x4E415050
+#define PSMCHUNKID_PATT 0x54544150
+#define PSMCHUNKID_DSAM 0x4D415344
+#define PSMCHUNKID_DSMP 0x504D5344
struct PSMNEWHEADER
{
@@ -126,17 +141,18 @@
ASSERT_CAN_READ(sizeof(PSMNEWHEADER));
PSMNEWHEADER *shdr = (PSMNEWHEADER *)lpStream;
- if(LittleEndian(shdr->formatID) == 0xFE4D5350) // "PSM\xFE" - PSM16 format
+ if(LittleEndian(shdr->formatID) == PSM16HEAD_PSM_) // "PSM\xFE" - PSM16 format
return ReadPSM16(lpStream, dwMemLength);
// Check header
- if(LittleEndian(shdr->formatID) != 0x204D5350 // "PSM "
+ if(LittleEndian(shdr->formatID) != PSMHEAD_PSM_ // "PSM "
|| LittleEndian(shdr->fileSize) != dwMemLength - 12
- || LittleEndian(shdr->fileInfoID) != 0x454C4946 // "FILE"
+ || LittleEndian(shdr->fileInfoID) != PSMHEAD_FILE // "FILE"
) return false;
// Yep, this seems to be a valid file.
m_nType = MOD_TYPE_PSM;
+ m_dwSongFlags = SONG_ITOLDEFFECTS | SONG_ITCOMPATMODE;
SetModFlag(MSF_COMPATIBLE_PLAY, true);
m_nChannels = 0;
@@ -171,16 +187,16 @@
switch(chunkID)
{
- case 0x4C544954: // "TITL" - Song Title
+ case PSMCHUNKID_TITL: // "TITL" - Song Title
memcpy(m_szNames[0], lpStream + dwMemPos, (chunkSize < 31) ? chunkSize : 31);
SpaceToNullStringFixed(m_szNames[0], 31);
break;
- case 0x54464453: // "SDFT" - Format info (song data starts here)
+ case PSMCHUNKID_SDFT: // "SDFT" - Format info (song data starts here)
if(chunkSize != 8 || memcmp(lpStream + dwMemPos, "MAINSONG", 8)) return false;
break;
- case 0x444F4250: // "PBOD" - Pattern data of a single pattern
+ case PSMCHUNKID_PBOD: // "PBOD" - Pattern data of a single pattern
if(chunkSize < 8 || chunkSize != LittleEndian(*(uint32 *)(lpStream + dwMemPos))) return false; // same value twice
// Pattern ID (something like "P0 " or "P13 ", or "PATT0 " in Sinaria) follows
@@ -197,7 +213,7 @@
// Convert later as we have to know how many channels there are.
break;
- case 0x474E4F53: // "SONG" - Subsong information (channel count etc)
+ case PSMCHUNKID_SONG: // "SONG" - Subsong information (channel count etc)
{
if(chunkSize < sizeof(PSMSONGHEADER)) return false;
PSMSONGHEADER *pSong = (PSMSONGHEADER *)(lpStream + dwMemPos);
@@ -220,7 +236,7 @@
switch(subChunkID)
{
- case 0x45544144: // "DATE" - Conversion date (YYMMDD)
+ case PSMCHUNKID_DATE: // "DATE" - Conversion date (YYMMDD)
if(subChunkSize != 6) break;
{
@@ -235,11 +251,11 @@
}
break;
- case 0x484C504F: // "OPLH" - Order list, channel + module settings
+ case PSMCHUNKID_OPLH: // "OPLH" - Order list, channel + module settings
{
if(subChunkSize < 9) return false;
// First two bytes = Number of chunks that follow
- //WORD nTotalChunks = LittleEndian(*(WORD *)(lpStream + dwChunkPos));
+ //uint16 nTotalChunks = LittleEndian(*(uint16 *)(lpStream + dwChunkPos));
// Now, the interesting part begins!
DWORD dwSettingsOffset = dwChunkPos + 2;
@@ -292,7 +308,6 @@
ORDERINDEX nRestartPosition = 0;
if(nRestartChunk >= nFirstOrderChunk) nRestartPosition = (ORDERINDEX)(nRestartChunk - nFirstOrderChunk);
subsong.restartPos += nRestartPosition;
- m_nRestartPos = subsong.restartPos;
}
dwSettingsOffset += 3;
break;
@@ -363,11 +378,6 @@
break;
default: // How the hell should this happen? I've listened through almost all existing (original) PSM files. :)
-#ifdef MODPLUG_TRACKER
- CString s;
- s.Format("Report to the OpenMPT team: Unknown chunk %d found at position %d (in the OPLH chunk of this PSM file)", lpStream[dwSettingsOffset], dwSettingsOffset);
- if(m_pModDoc != nullptr) m_pModDoc->AddToLog(s);
-#endif // MODPLUG_TRACKER
// anyway, in such cases, we have to quit as we don't know how big the chunk really is.
return false;
break;
@@ -381,7 +391,7 @@
}
break;
- case 0x4E415050: // PPAN - Channel panning table (used in Sinaria)
+ case PSMCHUNKID_PPAN: // PPAN - Channel panning table (used in Sinaria)
if(subChunkSize & 1) return false;
for(uint32 i = 0; i < subChunkSize; i += 2)
{
@@ -407,11 +417,11 @@
}
break;
- case 0x54544150: // PATT - Pattern list
+ case PSMCHUNKID_PATT: // PATT - Pattern list
// We don't really need this.
break;
- case 0x4D415344: // DSAM - Sample list
+ case PSMCHUNKID_DSAM: // DSAM - Sample list
// We don't need this either.
break;
@@ -429,7 +439,7 @@
break;
- case 0x504D5344: // DSMP - Samples
+ case PSMCHUNKID_DSMP: // DSMP - Samples
if(!bNewFormat)
{
// original header
@@ -792,14 +802,13 @@
ROWINDEX lastRow = Patterns[endPattern].GetNumRows() - 1;
MODCOMMAND *row_data;
row_data = Patterns[endPattern];
- for(uint32 nCell = 0; nCell < m_nChannels * Patterns[endPattern].GetNumRows(); nCell++)
+ for(uint32 nCell = 0; nCell < m_nChannels * Patterns[endPattern].GetNumRows(); nCell++, row_data++)
{
if(row_data->command == CMD_PATTERNBREAK || row_data->command == CMD_POSITIONJUMP)
{
lastRow = nCell / m_nChannels;
break;
}
- row_data++;
}
TryWriteEffect(endPattern, lastRow, CMD_POSITIONJUMP, (BYTE)subsongs[i].restartPos, false, CHANNELINDEX_INVALID, false, true);
}
@@ -882,7 +891,7 @@
PSM16HEADER *shdr = (PSM16HEADER *)lpStream;
// Check header
- if((LittleEndian(shdr->formatID) != 0xFE4D5350) // "PSM\xFE"
+ if((LittleEndian(shdr->formatID) != PSM16HEAD_PSM_) // "PSM\xFE"
|| (shdr->lineEnd != 0x1A)
|| (shdr->formatVersion != 0x10 && shdr->formatVersion != 0x01) // why is this sometimes 0x01?
|| (shdr->patternVersion != 0) // 255ch pattern version not supported (did anyone use this?)
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2010-07-16 21:46:18 UTC (rev 650)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2010-07-16 23:18:40 UTC (rev 651)
@@ -3850,7 +3850,7 @@
{
if ((!note) || (note >= NOTE_MIN_SPECIAL)) return 0;
if (m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT|MOD_TYPE_S3M|MOD_TYPE_STM|MOD_TYPE_MDL|MOD_TYPE_ULT|MOD_TYPE_WAV
- |MOD_TYPE_FAR|MOD_TYPE_DMF|MOD_TYPE_PTM|MOD_TYPE_AMS|MOD_TYPE_DBM|MOD_TYPE_AMF|MOD_TYPE_PSM))
+ |MOD_TYPE_FAR|MOD_TYPE_DMF|MOD_TYPE_PTM|MOD_TYPE_AMS|MOD_TYPE_DBM|MOD_TYPE_AMF|MOD_TYPE_PSM|MOD_TYPE_J2B|MOD_TYPE_IMF))
{
note--;
if (m_dwSongFlags & SONG_LINEARSLIDES)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-07-16 21:46:25
|
Revision: 650
http://modplug.svn.sourceforge.net/modplug/?rev=650&view=rev
Author: saga-games
Date: 2010-07-16 21:46:18 +0000 (Fri, 16 Jul 2010)
Log Message:
-----------
[Fix] PSM16 loader: Since the control channels were muted, tempo commands were ignored, effectively slowing down some PSM16 tracks.
[Imp] Improved handling of automatic modtype conversion of non-native formats. Compatibility flag is now always preserved.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/Moddoc.cpp
trunk/OpenMPT/soundlib/Load_imf.cpp
trunk/OpenMPT/soundlib/Load_psm.cpp
trunk/OpenMPT/soundlib/Snd_defs.h
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/Tables.cpp
trunk/OpenMPT/soundlib/load_j2b.cpp
Modified: trunk/OpenMPT/mptrack/Moddoc.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Moddoc.cpp 2010-07-16 21:43:14 UTC (rev 649)
+++ trunk/OpenMPT/mptrack/Moddoc.cpp 2010-07-16 21:46:18 UTC (rev 650)
@@ -364,7 +364,9 @@
case MOD_TYPE_AMF:
m_SndFile.ChangeModTypeTo(MOD_TYPE_S3M);
break;
+ case MOD_TYPE_IMF:
case MOD_TYPE_PSM:
+ case MOD_TYPE_J2B:
case MOD_TYPE_ULT:
case MOD_TYPE_OKT:
case MOD_TYPE_MT2:
Modified: trunk/OpenMPT/soundlib/Load_imf.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_imf.cpp 2010-07-16 21:43:14 UTC (rev 649)
+++ trunk/OpenMPT/soundlib/Load_imf.cpp 2010-07-16 21:46:18 UTC (rev 650)
@@ -288,7 +288,7 @@
if (memcmp(hdr.im10, "IM10", 4) != 0)
return false;
- ChangeModTypeTo(MOD_TYPE_IT);
+ m_nType = MOD_TYPE_IMF;
SetModFlag(MSF_COMPATIBLE_PLAY, true);
// song name
Modified: trunk/OpenMPT/soundlib/Load_psm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_psm.cpp 2010-07-16 21:43:14 UTC (rev 649)
+++ trunk/OpenMPT/soundlib/Load_psm.cpp 2010-07-16 21:46:18 UTC (rev 650)
@@ -136,7 +136,7 @@
) return false;
// Yep, this seems to be a valid file.
- m_nType = MOD_TYPE_IT;
+ m_nType = MOD_TYPE_PSM;
SetModFlag(MSF_COMPATIBLE_PLAY, true);
m_nChannels = 0;
@@ -920,7 +920,7 @@
{
ChnSettings[i].nPan = lpStream[dwMemPos + i] << 4;
ChnSettings[i].nVolume = 64;
- ChnSettings[i].dwFlags = (i >= shdr->numChannelsPlay) ? CHN_MUTE : 0;
+ ChnSettings[i].dwFlags = 0; // (i >= shdr->numChannelsPlay) ? CHN_MUTE : 0; // don't mute channels, as muted channels are completely ignored in S3M
}
}
Modified: trunk/OpenMPT/soundlib/Snd_defs.h
===================================================================
--- trunk/OpenMPT/soundlib/Snd_defs.h 2010-07-16 21:43:14 UTC (rev 649)
+++ trunk/OpenMPT/soundlib/Snd_defs.h 2010-07-16 21:46:18 UTC (rev 650)
@@ -113,8 +113,8 @@
#define MOD_TYPE_PSM 0x400000
#define MOD_TYPE_J2B 0x800000
#define MOD_TYPE_MPT 0x1000000
+#define MOD_TYPE_IMF 0x2000000
#define MOD_TYPE_UMX 0x80000000 // Fake type
-#define MAX_MODTYPE 24
// For compatibility mode
#define TRK_IMPULSETRACKER MOD_TYPE_IT | MOD_TYPE_MPT
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2010-07-16 21:43:14 UTC (rev 649)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2010-07-16 21:46:18 UTC (rev 650)
@@ -3013,13 +3013,13 @@
// XM <-> IT/MPT conversion.
if(combined == (MOD_TYPE_IT|MOD_TYPE_XM) || combined == (MOD_TYPE_MPT|MOD_TYPE_XM))
- return (1 << MSF_COMPATIBLE_PLAY) + (1 << MSF_MIDICC_BUGEMULATION);
+ return (1 << MSF_COMPATIBLE_PLAY) | (1 << MSF_MIDICC_BUGEMULATION);
// IT <-> MPT conversion.
if(combined == (MOD_TYPE_IT|MOD_TYPE_MPT))
return uint16_max;
- return 0;
+ return (1 << MSF_COMPATIBLE_PLAY);
}
void CSoundFile::ChangeModTypeTo(const MODTYPE& newType)
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2010-07-16 21:43:14 UTC (rev 649)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2010-07-16 21:46:18 UTC (rev 650)
@@ -1199,7 +1199,7 @@
DWORD dwPadding;
} MODFORMATINFO;
-extern MODFORMATINFO gModFormatInfo[MAX_MODTYPE];
+extern MODFORMATINFO gModFormatInfo[];
#endif
Modified: trunk/OpenMPT/soundlib/Tables.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Tables.cpp 2010-07-16 21:43:14 UTC (rev 649)
+++ trunk/OpenMPT/soundlib/Tables.cpp 2010-07-16 21:46:18 UTC (rev 650)
@@ -25,7 +25,7 @@
///////////////////////////////////////////////////////////////////////
#ifndef FASTSOUNDLIB
-MODFORMATINFO gModFormatInfo[MAX_MODTYPE] =
+MODFORMATINFO gModFormatInfo[] =
{
{ MOD_TYPE_MOD, "ProTracker", ".mod", 0 },
{ MOD_TYPE_S3M, "ScreamTracker III", ".s3m", 0 },
@@ -42,15 +42,17 @@
{ MOD_TYPE_PTM, "PolyTracker", ".ptm", 0 },
{ MOD_TYPE_WAV, "Wave", ".wav", 0 },
{ MOD_TYPE_MID, "Midi", ".mid", 0 },
- { MOD_TYPE_AMS, "Extreme Tracker", ".ams", 0 },
+ { MOD_TYPE_AMS, "Extreme's Tracker", ".ams", 0 },
{ MOD_TYPE_AMF|MOD_TYPE_AMF0,"Asylum / DSMI", ".amf", 0 },
{ MOD_TYPE_DSM, "DSIK Format", ".dsm", 0 },
{ MOD_TYPE_DMF, "X-Tracker", ".dmf", 0 },
{ MOD_TYPE_DBM, "DigiBooster Pro", ".dbm", 0 },
- { MOD_TYPE_PSM, "Protracker Studio", ".psm", 0 },
+ { MOD_TYPE_PSM, "Epic Megagames MASI", ".psm", 0 },
{ MOD_TYPE_UMX, "Unreal Music", ".umx", 0 },
{ MOD_TYPE_MT2, "MadTracker 2", ".mt2", 0 },
- { MOD_TYPE_MPT, "OpenMPT", ".mptm", 0 },
+ { MOD_TYPE_MPT, "OpenMPT", ".mptm", 0 },
+ { MOD_TYPE_J2B, "Galaxy Sound System", ".j2b", 0 },
+ { MOD_TYPE_IMF, "Imago Orpheus", ".imf", 0 },
};
#endif
Modified: trunk/OpenMPT/soundlib/load_j2b.cpp
===================================================================
--- trunk/OpenMPT/soundlib/load_j2b.cpp 2010-07-16 21:43:14 UTC (rev 649)
+++ trunk/OpenMPT/soundlib/load_j2b.cpp 2010-07-16 21:46:18 UTC (rev 650)
@@ -502,7 +502,7 @@
m_nDefaultTempo = mainchunk->tempo;
m_nDefaultGlobalVolume = mainchunk->globalvolume << 1;
m_nSamplePreAmp = m_nVSTiVolume = 48;
- m_nType = MOD_TYPE_IT;
+ m_nType = MOD_TYPE_J2B;
ASSERT(LittleEndian(mainchunk->unknown) == 0xFF0001C5 || LittleEndian(mainchunk->unknown) == 0x35800716);
// It seems like there's no way to differentiate between
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-07-16 21:43:21
|
Revision: 649
http://modplug.svn.sourceforge.net/modplug/?rev=649&view=rev
Author: saga-games
Date: 2010-07-16 21:43:14 +0000 (Fri, 16 Jul 2010)
Log Message:
-----------
[Ref] Some refactoring and additional documentation.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/Ctrl_com.cpp
trunk/OpenMPT/mptrack/MPTHacks.cpp
trunk/OpenMPT/mptrack/MainFrm.cpp
trunk/OpenMPT/mptrack/Mainfrm.h
Modified: trunk/OpenMPT/mptrack/Ctrl_com.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Ctrl_com.cpp 2010-07-16 19:20:22 UTC (rev 648)
+++ trunk/OpenMPT/mptrack/Ctrl_com.cpp 2010-07-16 21:43:14 UTC (rev 649)
@@ -152,7 +152,7 @@
CHAR s[256], *oldcomments = NULL;
if ((m_nLockCount) || (!m_pSndFile)
- || (m_pSndFile->m_nType & (MOD_TYPE_MOD|MOD_TYPE_S3M))) return;
+ || !m_pSndFile->GetModSpecifications().hasComments) return;
if ((!m_bInitialized) || (!m_EditComments.m_hWnd) || (!m_EditComments.GetModify())) return;
if (m_pSndFile->m_lpszSongComments)
{
@@ -164,7 +164,7 @@
UINT n = m_EditComments.GetLineCount();
- LPSTR p = new char[n*LINE_LENGTH+1];
+ LPSTR p = new char[n * LINE_LENGTH + 1];
p[0] = 0;
if (!p) return;
for (UINT i=0; i<n; i++)
@@ -189,9 +189,9 @@
delete[] p;
if (oldcomments)
{
- BOOL bSame = FALSE;
+ bool bSame = false;
if ((m_pSndFile->m_lpszSongComments)
- && (!strcmp(m_pSndFile->m_lpszSongComments, oldcomments))) bSame = TRUE;
+ && (!strcmp(m_pSndFile->m_lpszSongComments, oldcomments))) bSame = true;
delete[] oldcomments;
if (bSame) return;
} else
Modified: trunk/OpenMPT/mptrack/MPTHacks.cpp
===================================================================
--- trunk/OpenMPT/mptrack/MPTHacks.cpp 2010-07-16 19:20:22 UTC (rev 648)
+++ trunk/OpenMPT/mptrack/MPTHacks.cpp 2010-07-16 21:43:14 UTC (rev 649)
@@ -90,7 +90,7 @@
{
const CModSpecifications *originalSpecs = &m_SndFile.GetModSpecifications();
// retrieve original (not hacked) specs.
- switch(m_SndFile.GetType())
+ switch(m_SndFile.GetBestSaveFormat())
{
case MOD_TYPE_MOD:
originalSpecs = &ModSpecs::mod;
Modified: trunk/OpenMPT/mptrack/MainFrm.cpp
===================================================================
--- trunk/OpenMPT/mptrack/MainFrm.cpp 2010-07-16 19:20:22 UTC (rev 648)
+++ trunk/OpenMPT/mptrack/MainFrm.cpp 2010-07-16 21:43:14 UTC (rev 649)
@@ -874,6 +874,7 @@
DeleteGDIObject(penEnvelope);
DeleteGDIObject(penEnvelopeHighlight);
DeleteGDIObject(m_hFixedFont);
+ DeleteGDIObject(m_hLargeFixedFont);
DeleteGDIObject(penScratch);
DeleteGDIObject(penGray00);
DeleteGDIObject(penGray33);
@@ -3082,8 +3083,6 @@
// retrieve / set default directory from given string and store it our setup variables
-// TODO: Let some magic happen to convert between absolute and relative paths. m_csExecutableDirectoryPath might be helpful
-
void CMainFrame::SetDirectory(const LPCTSTR szFilenameFrom, Directory dir, TCHAR (&directories)[NUM_DIRS][_MAX_PATH], bool bStripFilename)
//----------------------------------------------------------------------------------------------------------------------------------------
{
Modified: trunk/OpenMPT/mptrack/Mainfrm.h
===================================================================
--- trunk/OpenMPT/mptrack/Mainfrm.h 2010-07-16 19:20:22 UTC (rev 648)
+++ trunk/OpenMPT/mptrack/Mainfrm.h 2010-07-16 21:43:14 UTC (rev 649)
@@ -197,15 +197,15 @@
// Midi Setup
-#define MIDISETUP_RECORDVELOCITY 0x01
-#define MIDISETUP_TRANSPOSEKEYBOARD 0x02
-#define MIDISETUP_MIDITOPLUG 0x04
-#define MIDISETUP_MIDIVOL_TO_NOTEVOL 0x08
-#define MIDISETUP_RECORDNOTEOFF 0x10
-#define MIDISETUP_RESPONDTOPLAYCONTROLMSGS 0x20
-#define MIDISETUP_AMPLIFYVELOCITY 0x40
-#define MIDISETUP_MIDIMACROCONTROL 0x80
-#define MIDISETUP_PLAYPATTERNONMIDIIN 0x100
+#define MIDISETUP_RECORDVELOCITY 0x01 // Record MIDI velocity
+#define MIDISETUP_TRANSPOSEKEYBOARD 0x02 // Apply transpose value to MIDI Notes
+#define MIDISETUP_MIDITOPLUG 0x04 // Pass MIDI messages to plugins
+#define MIDISETUP_MIDIVOL_TO_NOTEVOL 0x08 // Combine MIDI volume to note velocity
+#define MIDISETUP_RECORDNOTEOFF 0x10 // Record MIDI Note Off to pattern
+#define MIDISETUP_RESPONDTOPLAYCONTROLMSGS 0x20 // Respond to Restart/Continue/Stop MIDI commands
+#define MIDISETUP_AMPLIFYVELOCITY 0x40 // Amplify velocity of recorded notes
+#define MIDISETUP_MIDIMACROCONTROL 0x80 // Record MIDI controller changes a MIDI macro changes in pattern
+#define MIDISETUP_PLAYPATTERNONMIDIIN 0x100 // Play pattern if MIDI Note is received and playback is paused
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-07-16 19:20:29
|
Revision: 648
http://modplug.svn.sourceforge.net/modplug/?rev=648&view=rev
Author: saga-games
Date: 2010-07-16 19:20:22 +0000 (Fri, 16 Jul 2010)
Log Message:
-----------
[Ref] Message reading: It's now possible to specify a callback function for converting characters. The AMS loader makes use of this.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_ams.cpp
trunk/OpenMPT/soundlib/Message.cpp
trunk/OpenMPT/soundlib/Sndfile.h
Modified: trunk/OpenMPT/soundlib/Load_ams.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_ams.cpp 2010-07-15 23:55:10 UTC (rev 647)
+++ trunk/OpenMPT/soundlib/Load_ams.cpp 2010-07-16 19:20:22 UTC (rev 648)
@@ -5,6 +5,12 @@
*
* Authors: Olivier Lapicque <oli...@jp...>
* OpenMPT dev(s) (miscellaneous modifications)
+ * Notes : Extreme was renamed to Velvet Development at some point,
+ * and thus they also renamed their tracker from
+ * "Extreme's Tracker" to "Velvet Studio".
+ * While the two programs look rather similiar, the structure of both
+ * programs' "AMS" format is significantly different - Velvet Studio is a
+ * rather advanced tracker in comparison to Extreme's Tracker.
*/
//////////////////////////////////////////////
@@ -44,7 +50,28 @@
#pragma pack()
+// Callback function for reading text
+void Convert_AMS_Text_Chars(char &c)
+//----------------------------------
+{
+ switch((unsigned char)c)
+ {
+ case 0x00:
+ case 0x81: c = ' '; break;
+ case 0x14: c = '\xF6'; break;
+ case 0x19: c = '\xD6'; break;
+ case 0x04: c = '\xE4'; break;
+ case 0x0E: c = '\xC4'; break;
+ case 0x06: c = '\xE5'; break;
+ case 0x0F: c = '\xC5'; break;
+ default:
+ if((unsigned char)c > 0x81)
+ c = '\r';
+ break;
+ }
+}
+
bool CSoundFile::ReadAMS(const LPCBYTE lpStream, const DWORD dwMemLength)
//-----------------------------------------------------------------------
{
@@ -136,29 +163,9 @@
tmp = *((WORD *)(lpStream+dwMemPos));
dwMemPos += 2;
if (dwMemPos + tmp >= dwMemLength) return true;
- if (tmp && AllocateMessage(tmp))
+ if (tmp)
{
- // Translate that weird text format...
- for(size_t i = 0; i < tmp; i++)
- {
- switch(lpStream[dwMemPos + i])
- {
- case 0x00:
- case 0x81: m_lpszSongComments[i] = ' '; break;
- case 0x14: m_lpszSongComments[i] = '\xF6'; break;
- case 0x19: m_lpszSongComments[i] = '\xD6'; break;
- case 0x04: m_lpszSongComments[i] = '\xE4'; break;
- case 0x0E: m_lpszSongComments[i] = '\xC4'; break;
- case 0x06: m_lpszSongComments[i] = '\xE5'; break;
- case 0x0F: m_lpszSongComments[i] = '\xC5'; break;
- default:
- if(lpStream[dwMemPos + i] > 0x81)
- m_lpszSongComments[i] = '\r';
- else
- m_lpszSongComments[i] = lpStream[dwMemPos + i];
- break;
- }
- }
+ ReadMessage(lpStream + dwMemPos, tmp, leCR, &Convert_AMS_Text_Chars);
}
dwMemPos += tmp;
@@ -352,11 +359,11 @@
BYTE packedsamples[MAX_SAMPLES];
if ((pfh->dwHdr1 != 0x68534D41) || (pfh->wHdr2 != 0x7264)
- || (pfh->b1A != 0x1A) || (pfh->titlelen > 30)) return FALSE;
+ || (pfh->b1A != 0x1A) || (pfh->titlelen > 30)) return false;
dwMemPos = pfh->titlelen + 8;
psh = (AMS2SONGHEADER *)(lpStream + dwMemPos);
if (((psh->version & 0xFF00) != 0x0200) || (!psh->instruments)
- || (psh->instruments > MAX_INSTRUMENTS) || (!psh->patterns) || (!psh->orders)) return FALSE;
+ || (psh->instruments > MAX_INSTRUMENTS) || (!psh->patterns) || (!psh->orders)) return false;
dwMemPos += sizeof(AMS2SONGHEADER);
if (pfh->titlelen)
{
@@ -461,7 +468,7 @@
dwMemPos += sizeof(AMS2SAMPLE);
}
}
- if (dwMemPos + 256 >= dwMemLength) return TRUE;
+ if (dwMemPos + 256 >= dwMemLength) return true;
// Comments
{
UINT composernamelen = lpStream[dwMemPos];
@@ -480,16 +487,16 @@
SpaceToNullStringFixed(ChnSettings[i].szName, chnnamlen);
}
dwMemPos += chnnamlen + 1;
- if (dwMemPos + chnnamlen + 256 >= dwMemLength) return TRUE;
+ if (dwMemPos + chnnamlen + 256 >= dwMemLength) return true;
}
// packed comments (ignored)
UINT songtextlen = *((LPDWORD)(lpStream+dwMemPos));
dwMemPos += songtextlen;
- if (dwMemPos + 256 >= dwMemLength) return TRUE;
+ if (dwMemPos + 256 >= dwMemLength) return true;
}
// Order List
{
- if ((dwMemPos + 2 * psh->orders) >= dwMemLength) return TRUE;
+ if ((dwMemPos + 2 * psh->orders) >= dwMemLength) return true;
Order.resize(psh->orders, Order.GetInvalidPatIndex());
for (UINT iOrd = 0; iOrd < psh->orders; iOrd++)
{
@@ -500,7 +507,7 @@
// Pattern Data
for (UINT ipat=0; ipat<psh->patterns; ipat++)
{
- if (dwMemPos+8 >= dwMemLength) return TRUE;
+ if (dwMemPos+8 >= dwMemLength) return true;
UINT packedlen = *((LPDWORD)(lpStream+dwMemPos));
UINT numrows = 1 + (UINT)(lpStream[dwMemPos+4]);
//UINT patchn = 1 + (UINT)(lpStream[dwMemPos+5] & 0x1F);
@@ -516,7 +523,7 @@
SpaceToNullStringFixed(s, patnamlen);
SetPatternName(ipat, s);
}
- if(Patterns.Insert(ipat, numrows)) return TRUE;
+ if(Patterns.Insert(ipat, numrows)) return true;
// Unpack Pattern Data
LPCBYTE psrc = lpStream + dwMemPos;
UINT pos = 3 + patnamlen;
@@ -570,7 +577,7 @@
// Read Samples
for (UINT iSmp=1; iSmp<=m_nSamples; iSmp++) if (Samples[iSmp].nLength)
{
- if (dwMemPos >= dwMemLength - 9) return TRUE;
+ if (dwMemPos >= dwMemLength - 9) return true;
UINT flags;
if (packedsamples[iSmp] & 0x03)
{
@@ -581,7 +588,7 @@
}
dwMemPos += ReadSample(&Samples[iSmp], flags, (LPSTR)(lpStream+dwMemPos), dwMemLength-dwMemPos);
}
- return TRUE;
+ return true;
}
Modified: trunk/OpenMPT/soundlib/Message.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Message.cpp 2010-07-15 23:55:10 UTC (rev 647)
+++ trunk/OpenMPT/soundlib/Message.cpp 2010-07-16 19:20:22 UTC (rev 648)
@@ -51,21 +51,30 @@
// [in] data: pointer to the data in memory that is going to be read
// [in] length: number of characters that should be read, not including a possible trailing null terminator (it is automatically appended).
// [in] lineEnding: line ending formatting of the text in memory.
+// [in] pTextConverter: Pointer to a callback function which can be used to pre-process the read characters, if necessary (nullptr otherwise).
// [out] returns true on success.
-bool CSoundFile::ReadMessage(const BYTE *data, const size_t length, enmLineEndings lineEnding)
-//--------------------------------------------------------------------------------------------
+bool CSoundFile::ReadMessage(const BYTE *data, const size_t length, enmLineEndings lineEnding, void (*pTextConverter)(char &))
+//----------------------------------------------------------------------------------------------------------------------------
{
+ char c;
+
// Simple line-ending detection algorithm. VERY simple.
if(lineEnding == leAutodetect)
{
+ char cprev = 0;
size_t nCR = 0, nLF = 0, nCRLF = 0;
// find CRs, LFs and CRLFs
for(size_t i = 0; i < length; i++)
- {
- if(data[i] == '\r') nCR++;
- else if(data[i] == '\n') nLF++;
+ {
+ c = data[i];
+ if(pTextConverter != nullptr)
+ pTextConverter(c);
- if(i && data[i - 1] == '\r' && data[i] == '\n') nCRLF++;
+ if(c == '\r') nCR++;
+ else if(c == '\n') nLF++;
+
+ if(i && cprev == '\r' && c == '\n') nCRLF++;
+ cprev = c;
}
// evaluate findings
if(nCR == nLF && nCR == nCRLF)
@@ -82,7 +91,11 @@
// calculate the final amount of characters to be allocated.
for(size_t i = 0; i < length; i++)
{
- switch(data[i])
+ c = data[i];
+ if(pTextConverter != nullptr)
+ pTextConverter(c);
+
+ switch(c)
{
case '\r':
if(lineEnding != leLF) final_length++;
@@ -102,7 +115,11 @@
size_t cpos = 0;
for(size_t i = 0; i < length; i++, cpos++)
{
- switch(data[i])
+ c = data[i];
+ if(pTextConverter != nullptr)
+ pTextConverter(c);
+
+ switch(c)
{
case '\r':
if(lineEnding != leLF)
@@ -121,7 +138,7 @@
m_lpszSongComments[cpos] = ' ';
break;
default:
- m_lpszSongComments[cpos] = data[i];
+ m_lpszSongComments[cpos] = c;
break;
}
}
@@ -135,9 +152,10 @@
// [in] length: number of characters that should be read, not including a possible trailing null terminator (it is automatically appended).
// [in] lineLength: The fixed length of a line.
// [in] lineEndingLength: The padding space between two fikxed lines. (there could for example be a null char after every line)
+// [in] pTextConverter: Pointer to a callback function which can be used to pre-process the read characters, if necessary (nullptr otherwise).
// [out] returns true on success.
-bool CSoundFile::ReadFixedLineLengthMessage(const BYTE *data, const size_t length, const size_t lineLength, const size_t lineEndingLength)
-//----------------------------------------------------------------------------------------------------------------------------------------
+bool CSoundFile::ReadFixedLineLengthMessage(const BYTE *data, const size_t length, const size_t lineLength, const size_t lineEndingLength, void (*pTextConverter)(char &))
+//------------------------------------------------------------------------------------------------------------------------------------------------------------------------
{
if(lineLength == 0)
return false;
@@ -155,6 +173,9 @@
// fix weird chars
for(size_t lpos = 0; lpos < lineLength; lpos++)
{
+ // Pre-process text
+ if(pTextConverter != nullptr) pTextConverter(m_lpszSongComments[cpos + lpos]);
+
switch(m_lpszSongComments[cpos + lpos])
{
case '\0':
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2010-07-15 23:55:10 UTC (rev 647)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2010-07-16 19:20:22 UTC (rev 648)
@@ -964,16 +964,18 @@
// [in] data: pointer to the data in memory that is going to be read
// [in] length: number of characters that should be read, not including a possible trailing null terminator (it is automatically appended).
// [in] lineEnding: line ending formatting of the text in memory.
+ // [in] pTextConverter: Pointer to a callback function which can be used to pre-process the read characters, if necessary (nullptr otherwise).
// [out] returns true on success.
- bool ReadMessage(const BYTE *data, const size_t length, enmLineEndings lineEnding);
+ bool ReadMessage(const BYTE *data, const size_t length, enmLineEndings lineEnding, void (*pTextConverter)(char &) = nullptr);
// Read comments with fixed line length from a mapped file.
// [in] data: pointer to the data in memory that is going to be read
// [in] length: number of characters that should be read, not including a possible trailing null terminator (it is automatically appended).
// [in] lineLength: The fixed length of a line.
// [in] lineEndingLength: The padding space between two fikxed lines. (there could for example be a null char after every line)
+ // [in] pTextConverter: Pointer to a callback function which can be used to pre-process the read characters, if necessary (nullptr otherwise).
// [out] returns true on success.
- bool ReadFixedLineLengthMessage(const BYTE *data, const size_t length, const size_t lineLength, const size_t lineEndingLength);
+ bool ReadFixedLineLengthMessage(const BYTE *data, const size_t length, const size_t lineLength, const size_t lineEndingLength, void (*pTextConverter)(char &) = nullptr);
// Currently unused (and the code doesn't look very nice :)
UINT GetSongMessage(LPSTR s, UINT cbsize, UINT linesize=32);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-07-15 23:55:18
|
Revision: 647
http://modplug.svn.sourceforge.net/modplug/?rev=647&view=rev
Author: saga-games
Date: 2010-07-15 23:55:10 +0000 (Thu, 15 Jul 2010)
Log Message:
-----------
[New] Instrument Editor: Pressing Ctrl while dragging a point now also moves the tail of the envelope.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/View_ins.cpp
Modified: trunk/OpenMPT/mptrack/View_ins.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_ins.cpp 2010-07-14 19:33:48 UTC (rev 646)
+++ trunk/OpenMPT/mptrack/View_ins.cpp 2010-07-15 23:55:10 UTC (rev 647)
@@ -1363,14 +1363,11 @@
void CViewInstrument::OnMouseMove(UINT, CPoint pt)
//------------------------------------------------
{
- CModDoc *pModDoc = GetDocument();
- if(pModDoc == nullptr) return;
- CSoundFile *pSndFile = pModDoc->GetSoundFile();
- if(pSndFile == nullptr) return;
- MODINSTRUMENT *pIns = pSndFile->Instruments[m_nInstrument];
- if (pIns == nullptr) return;
+ MODINSTRUMENT *pIns = GetInstrumentPtr();
+ INSTRUMENTENVELOPE *pEnv = GetEnvelopePtr();
+ if (pIns == nullptr || pEnv == nullptr) return;
- BOOL bSplitCursor = FALSE;
+ bool bSplitCursor = false;
CHAR s[256];
if ((m_nBtnMouseOver < ENV_LEFTBAR_BUTTONS) || (m_dwStatus & INSSTATUS_NCLBTNDOWN))
@@ -1381,11 +1378,9 @@
CMainFrame *pMainFrm = CMainFrame::GetMainFrame();
if (pMainFrm) pMainFrm->SetHelpText("");
}
- if (!pModDoc) return;
int nTick = ScreenToTick(pt.x);
int nVal = ScreenToValue(pt.y);
- if (nVal < 0) nVal = 0;
- if (nVal > 64) nVal = 64;
+ nVal = CLAMP(nVal, ENVELOPE_MIN, ENVELOPE_MAX);
if (nTick < 0) nTick = 0;
if (nTick <= EnvGetReleaseNodeTick() + 1 || EnvGetReleaseNode() == ENV_RELEASE_NODE_UNSET)
{
@@ -1406,11 +1401,22 @@
if ((m_dwStatus & INSSTATUS_DRAGGING) && (m_nDragItem))
{
- BOOL bChanged = FALSE;
+ bool bChanged = false;
if (pt.x >= m_rcClient.right - 2) nTick++;
if (IsDragItemEnvPoint())
{
+ int nRelTick = pEnv->Ticks[m_nDragItem - 1];
bChanged = EnvSetValue(m_nDragItem - 1, nTick, nVal);
+
+ // Ctrl pressed -> move tail of envelope
+ if(m_nDragItem > 1 && CMainFrame::GetMainFrame()->GetInputHandler()->CtrlPressed())
+ {
+ nRelTick = pEnv->Ticks[m_nDragItem - 1] - nRelTick;
+ for(size_t i = m_nDragItem; i < pEnv->nNodes; i++)
+ {
+ pEnv->Ticks[i] = (WORD)(max(0, (int)pEnv->Ticks[i] + nRelTick));
+ }
+ }
} else
{
int nPoint = ScreenToPoint(pt.x, pt.y);
@@ -1418,19 +1424,19 @@
{
case ENV_DRAGLOOPSTART:
bChanged = EnvSetLoopStart(nPoint);
- bSplitCursor = TRUE;
+ bSplitCursor = true;
break;
case ENV_DRAGLOOPEND:
bChanged = EnvSetLoopEnd(nPoint);
- bSplitCursor = TRUE;
+ bSplitCursor = true;
break;
case ENV_DRAGSUSTAINSTART:
bChanged = EnvSetSustainStart(nPoint);
- bSplitCursor = TRUE;
+ bSplitCursor = true;
break;
case ENV_DRAGSUSTAINEND:
bChanged = EnvSetSustainEnd(nPoint);
- bSplitCursor = TRUE;
+ bSplitCursor = true;
break;
}
}
@@ -1446,8 +1452,12 @@
UpdateScrollSize();
OnScrollBy(CSize((int)m_fZoom + pt.x - m_rcClient.right, 0), TRUE);
}
- pModDoc->SetModified();
- pModDoc->UpdateAllViews(NULL, (m_nInstrument << HINT_SHIFT_INS) | HINT_ENVELOPE, NULL);
+ CModDoc *pModDoc = GetDocument();
+ if(pModDoc)
+ {
+ pModDoc->SetModified();
+ pModDoc->UpdateAllViews(NULL, (m_nInstrument << HINT_SHIFT_INS) | HINT_ENVELOPE, NULL);
+ }
UpdateWindow(); //rewbs: TODO - optimisation here so we don't redraw whole view.
}
} else
@@ -1462,14 +1472,14 @@
rect.left = rect.right - (int)(m_fZoom * 2);
if (rect.PtInRect(pt))
{
- bSplitCursor = TRUE; // ENV_DRAGSUSTAINSTART;
+ bSplitCursor = true; // ENV_DRAGSUSTAINSTART;
} else
{
rect.top = ValueToScreen(EnvGetValue(EnvGetSustainEnd())) - nspace;
rect.bottom = rect.top + nspace * 2;
rect.left = PointToScreen(EnvGetSustainEnd()) - 1;
rect.right = rect.left + (int)(m_fZoom *2);
- if (rect.PtInRect(pt)) bSplitCursor = TRUE; // ENV_DRAGSUSTAINEND;
+ if (rect.PtInRect(pt)) bSplitCursor = true; // ENV_DRAGSUSTAINEND;
}
}
if (EnvGetLoop())
@@ -1480,12 +1490,12 @@
rect.left = rect.right - (int)(m_fZoom * 2);
if (rect.PtInRect(pt))
{
- bSplitCursor = TRUE; // ENV_DRAGLOOPSTART;
+ bSplitCursor = true; // ENV_DRAGLOOPSTART;
} else
{
rect.left = PointToScreen(EnvGetLoopEnd()) - 1;
rect.right = rect.left + (int)(m_fZoom * 2);
- if (rect.PtInRect(pt)) bSplitCursor = TRUE; // ENV_DRAGLOOPEND;
+ if (rect.PtInRect(pt)) bSplitCursor = true; // ENV_DRAGLOOPEND;
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-07-14 19:33:55
|
Revision: 646
http://modplug.svn.sourceforge.net/modplug/?rev=646&view=rev
Author: saga-games
Date: 2010-07-14 19:33:48 +0000 (Wed, 14 Jul 2010)
Log Message:
-----------
[Imp] Installer: If unmo3.dll is already present in the app's directory, the download task is automatically hidden in the unmo3-free version of the installer.
Modified Paths:
--------------
trunk/OpenMPT/installer/install-unmo3-free.iss
trunk/OpenMPT/installer/install.iss
Modified: trunk/OpenMPT/installer/install-unmo3-free.iss
===================================================================
--- trunk/OpenMPT/installer/install-unmo3-free.iss 2010-07-13 19:59:59 UTC (rev 645)
+++ trunk/OpenMPT/installer/install-unmo3-free.iss 2010-07-14 19:33:48 UTC (rev 646)
@@ -13,13 +13,15 @@
#include "install.iss"
+[_ISToolDownload]
+Source: http://openmpt.com/download/unmo3.dll; DestDir: {tmp}; DestName: openmpt-unmo3.dll.tmp; Tasks: downloadmo3
[Code]
// Verify checksum of downloaded file, and if it is OK, copy it to the app directory.
procedure VerifyUNMO3Checksum();
begin
if(IsTaskSelected('downloadmo3') And FileExists(ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp'))) then
begin
- if(GetSHA1OfFile(ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp')) <> '2e17f7bb6d19ce326851333b918070c5357cacd1') then
+ if(GetSHA1OfFile(ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp')) <> '2e17f7bb6d19ce326851333b918070c5357cacd1') then
begin
MsgBox('Warning: unmo3.dll has been downloaded, but its checksum is wrong! This means that either the downloaded file is corrupted or that a newer version of unmo3.dll is available. The file has thus not been installed. Please obtain unmo3.dll from http://openmpt.com/ and verify its checksum.', mbCriticalError, MB_OK)
end else
@@ -30,11 +32,13 @@
end;
end;
+function IsUNMO3Installed(): Boolean;
+begin
+ Result := FileExists(ExpandConstant('{app}\unmo3.dll'));
+end;
+
// Function generated by ISTool.
function NextButtonClick(CurPage: Integer): Boolean;
begin
Result := istool_download(CurPage);
end;
-
-[_ISToolDownload]
-Source: http://openmpt.com/download/unmo3.dll; DestDir: {tmp}; DestName: openmpt-unmo3.dll.tmp; Tasks: downloadmo3
Modified: trunk/OpenMPT/installer/install.iss
===================================================================
--- trunk/OpenMPT/installer/install.iss 2010-07-13 19:59:59 UTC (rev 645)
+++ trunk/OpenMPT/installer/install.iss 2010-07-14 19:33:48 UTC (rev 646)
@@ -39,7 +39,7 @@
Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}
Name: quicklaunchicon; Description: {cm:CreateQuickLaunchIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked
#ifdef DOWNLOAD_MO3
-Name: downloadmo3; Description: Download unmo3 (library needed for reading MO3 files, recommended); GroupDescription: Options:
+Name: downloadmo3; Description: Download unmo3 (library needed for reading MO3 files, recommended); Check: not IsUNMO3Installed; GroupDescription: Options:
#endif
Name: portable; Description: Portable mode (use program folder for storing settings, no registry changes); GroupDescription: Options:; Flags: unchecked
Name: vst_scan; Description: Scan for previously installed VST plugins; GroupDescription: Options:; Flags: unchecked
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-07-13 20:00:06
|
Revision: 645
http://modplug.svn.sourceforge.net/modplug/?rev=645&view=rev
Author: saga-games
Date: 2010-07-13 19:59:59 +0000 (Tue, 13 Jul 2010)
Log Message:
-----------
[Ref] Unified code for song message allocation / freeing / reading. From now on, Message.cpp ahould contain all code used for song messages.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/mptrack.vcproj
trunk/OpenMPT/mptrack/mptrack_08.vcproj
trunk/OpenMPT/soundlib/LOAD_DMF.CPP
trunk/OpenMPT/soundlib/Load_669.cpp
trunk/OpenMPT/soundlib/Load_ams.cpp
trunk/OpenMPT/soundlib/Load_far.cpp
trunk/OpenMPT/soundlib/Load_gdm.cpp
trunk/OpenMPT/soundlib/Load_it.cpp
trunk/OpenMPT/soundlib/Load_mdl.cpp
trunk/OpenMPT/soundlib/Load_med.cpp
trunk/OpenMPT/soundlib/Load_mid.cpp
trunk/OpenMPT/soundlib/Load_mt2.cpp
trunk/OpenMPT/soundlib/Load_mtm.cpp
trunk/OpenMPT/soundlib/Load_ult.cpp
trunk/OpenMPT/soundlib/Load_xm.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/Sndfile.h
Added Paths:
-----------
trunk/OpenMPT/soundlib/Message.cpp
Modified: trunk/OpenMPT/mptrack/mptrack.vcproj
===================================================================
--- trunk/OpenMPT/mptrack/mptrack.vcproj 2010-07-13 19:19:41 UTC (rev 644)
+++ trunk/OpenMPT/mptrack/mptrack.vcproj 2010-07-13 19:59:59 UTC (rev 645)
@@ -346,6 +346,9 @@
RelativePath=".\MainFrm.cpp">
</File>
<File
+ RelativePath="..\soundlib\Message.cpp">
+ </File>
+ <File
RelativePath=".\MIDIMappingDialog.cpp">
</File>
<File
@@ -394,6 +397,9 @@
RelativePath=".\mpt_midi.cpp">
</File>
<File
+ RelativePath=".\MPTHacks.cpp">
+ </File>
+ <File
RelativePath=".\mptrack.cpp">
</File>
<File
Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj
===================================================================
--- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2010-07-13 19:19:41 UTC (rev 644)
+++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2010-07-13 19:59:59 UTC (rev 645)
@@ -465,6 +465,10 @@
>
</File>
<File
+ RelativePath="..\soundlib\Message.cpp"
+ >
+ </File>
+ <File
RelativePath=".\MIDIMappingDialog.cpp"
>
</File>
@@ -529,6 +533,10 @@
>
</File>
<File
+ RelativePath=".\MPTHacks.cpp"
+ >
+ </File>
+ <File
RelativePath=".\mptrack.cpp"
>
</File>
Modified: trunk/OpenMPT/soundlib/LOAD_DMF.CPP
===================================================================
--- trunk/OpenMPT/soundlib/LOAD_DMF.CPP 2010-07-13 19:19:41 UTC (rev 644)
+++ trunk/OpenMPT/soundlib/LOAD_DMF.CPP 2010-07-13 19:59:59 UTC (rev 645)
@@ -119,21 +119,9 @@
psi = (DMFINFO *)(lpStream+dwMemPos);
if (id == 0x47534d43) dwMemPos++;
if ((psi->infosize > dwMemLength) || (psi->infosize + dwMemPos + 8 > dwMemLength)) goto dmfexit;
- if ((psi->infosize >= 8) && (!m_lpszSongComments))
+ if (psi->infosize >= 8)
{
- m_lpszSongComments = new char[psi->infosize];
- if (m_lpszSongComments)
- {
- for (UINT i=0; i<psi->infosize-1; i++)
- {
- CHAR c = lpStream[dwMemPos+8+i];
- if ((i % 40) == 39)
- m_lpszSongComments[i] = 0x0d;
- else
- m_lpszSongComments[i] = (c < ' ') ? ' ' : c;
- }
- m_lpszSongComments[psi->infosize-1] = 0;
- }
+ ReadFixedLineLengthMessage(lpStream + dwMemPos + 8, psi->infosize - 1, 40, 0);
}
dwMemPos += psi->infosize + 8 - 1;
break;
Modified: trunk/OpenMPT/soundlib/Load_669.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_669.cpp 2010-07-13 19:19:41 UTC (rev 644)
+++ trunk/OpenMPT/soundlib/Load_669.cpp 2010-07-13 19:59:59 UTC (rev 645)
@@ -92,10 +92,10 @@
Samples[nSmp].nGlobalVol = 64;
Samples[nSmp].nPan = 128;
}
+
// Song Message
- m_lpszSongComments = new char[109];
- memcpy(m_lpszSongComments, pfh->songmessage, 108);
- m_lpszSongComments[108] = 0;
+ ReadFixedLineLengthMessage((BYTE *)(&pfh->songmessage), 108, 36, 0);
+
// Reading Orders
Order.ReadAsByte(pfh->orders, 128, 128);
m_nRestartPos = pfh->restartpos;
@@ -106,6 +106,7 @@
ChnSettings[npan].nPan = (npan & 1) ? 0x30 : 0xD0;
ChnSettings[npan].nVolume = 64;
}
+
// Reading Patterns
dwMemPos = 0x1F1 + pfh->samples * 25;
for (UINT npat=0; npat<pfh->patterns; npat++)
@@ -179,6 +180,7 @@
}
dwMemPos += 0x600;
}
+
// Reading Samples
for (UINT n=1; n<=m_nSamples; n++)
{
Modified: trunk/OpenMPT/soundlib/Load_ams.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_ams.cpp 2010-07-13 19:19:41 UTC (rev 644)
+++ trunk/OpenMPT/soundlib/Load_ams.cpp 2010-07-13 19:59:59 UTC (rev 645)
@@ -8,7 +8,7 @@
*/
//////////////////////////////////////////////
-// AMS module loader //
+// AMS (Extreme's Tracker) module loader //
//////////////////////////////////////////////
#include "stdafx.h"
#include "sndfile.h"
@@ -53,7 +53,7 @@
DWORD dwMemPos;
UINT tmp, tmp2;
- if ((!lpStream) || (dwMemLength < 1024)) return false;
+ if ((!lpStream) || (dwMemLength < 126)) return false;
if ((pfh->verhi != 0x01) || (strncmp(pfh->szHeader, "Extreme", 7))
|| (!pfh->patterns) || (!pfh->orders) || (!pfh->samples) || (pfh->samples > MAX_SAMPLES)
|| (pfh->patterns > MAX_PATTERNS) || (pfh->orders > MAX_ORDERS))
@@ -61,12 +61,12 @@
return ReadAMS2(lpStream, dwMemLength);
}
dwMemPos = sizeof(AMSFILEHEADER) + pfh->extra;
- if (dwMemPos + pfh->samples * sizeof(AMSSAMPLEHEADER) + 256 >= dwMemLength) return false;
+ if (dwMemPos + pfh->samples * sizeof(AMSSAMPLEHEADER) >= dwMemLength) return false;
m_nType = MOD_TYPE_AMS;
m_nInstruments = 0;
m_nChannels = (pfh->chncfg & 0x1F) + 1;
m_nSamples = pfh->samples;
- for (UINT nSmp=1; nSmp<=m_nSamples; nSmp++, dwMemPos += sizeof(AMSSAMPLEHEADER))
+ for (UINT nSmp=1; nSmp <= m_nSamples; nSmp++, dwMemPos += sizeof(AMSSAMPLEHEADER))
{
AMSSAMPLEHEADER *psh = (AMSSAMPLEHEADER *)(lpStream + dwMemPos);
MODSAMPLE *pSmp = &Samples[nSmp];
@@ -83,14 +83,17 @@
if ((pSmp->nLoopEnd <= pSmp->nLength) && (pSmp->nLoopStart+4 <= pSmp->nLoopEnd)) pSmp->uFlags |= CHN_LOOP;
pkinf[nSmp] = psh->infobyte;
}
+
// Read Song Name
+ if (dwMemPos + 1 >= dwMemLength) return true;
tmp = lpStream[dwMemPos++];
if (dwMemPos + tmp + 1 >= dwMemLength) return true;
tmp2 = (tmp < 32) ? tmp : 31;
- if (tmp2) memcpy(m_szNames[0], lpStream+dwMemPos, tmp2);
+ if (tmp2) memcpy(m_szNames[0], lpStream + dwMemPos, tmp2);
SpaceToNullStringFixed(m_szNames[0], tmp2);
m_szNames[0][tmp2] = 0;
dwMemPos += tmp;
+
// Read sample names
for (UINT sNam=1; sNam<=m_nSamples; sNam++)
{
@@ -101,6 +104,7 @@
SpaceToNullStringFixed(m_szNames[sNam], tmp2);
dwMemPos += tmp;
}
+
// Read Channel names
for (UINT cNam=0; cNam<m_nChannels; cNam++)
{
@@ -113,6 +117,7 @@
}
dwMemPos += chnnamlen;
}
+
// Read Pattern Names
m_lpszPatternNames = new char[pfh->patterns * 32];
if (!m_lpszPatternNames) return true;
@@ -126,24 +131,44 @@
if (tmp2) memcpy(m_lpszPatternNames+pNam*32, lpStream+dwMemPos, tmp2);
dwMemPos += tmp;
}
+
// Read Song Comments
tmp = *((WORD *)(lpStream+dwMemPos));
dwMemPos += 2;
if (dwMemPos + tmp >= dwMemLength) return true;
- if (tmp)
+ if (tmp && AllocateMessage(tmp))
{
- m_lpszSongComments = new char[tmp+1];
- if (!m_lpszSongComments) return true;
- memset(m_lpszSongComments, 0, tmp+1);
- memcpy(m_lpszSongComments, lpStream + dwMemPos, tmp);
- dwMemPos += tmp;
+ // Translate that weird text format...
+ for(size_t i = 0; i < tmp; i++)
+ {
+ switch(lpStream[dwMemPos + i])
+ {
+ case 0x00:
+ case 0x81: m_lpszSongComments[i] = ' '; break;
+ case 0x14: m_lpszSongComments[i] = '\xF6'; break;
+ case 0x19: m_lpszSongComments[i] = '\xD6'; break;
+ case 0x04: m_lpszSongComments[i] = '\xE4'; break;
+ case 0x0E: m_lpszSongComments[i] = '\xC4'; break;
+ case 0x06: m_lpszSongComments[i] = '\xE5'; break;
+ case 0x0F: m_lpszSongComments[i] = '\xC5'; break;
+ default:
+ if(lpStream[dwMemPos + i] > 0x81)
+ m_lpszSongComments[i] = '\r';
+ else
+ m_lpszSongComments[i] = lpStream[dwMemPos + i];
+ break;
+ }
+ }
}
+ dwMemPos += tmp;
+
// Read Order List
Order.resize(pfh->orders, Order.GetInvalidPatIndex());
for (UINT iOrd=0; iOrd < pfh->orders; iOrd++, dwMemPos += 2)
{
Order[iOrd] = (PATTERNINDEX)*((WORD *)(lpStream + dwMemPos));
}
+
// Read Patterns
for (UINT iPat=0; iPat<pfh->patterns; iPat++)
{
@@ -244,6 +269,7 @@
}
dwMemPos += len;
}
+
// Read Samples
for (UINT iSmp=1; iSmp<=m_nSamples; iSmp++) if (Samples[iSmp].nLength)
{
@@ -256,7 +282,7 @@
/////////////////////////////////////////////////////////////////////
-// AMS 2.2 loader
+// AMS (Velvet Studio) 2.2 loader
#pragma pack(1)
@@ -441,12 +467,7 @@
UINT composernamelen = lpStream[dwMemPos];
if (composernamelen)
{
- m_lpszSongComments = new char[composernamelen+1];
- if (m_lpszSongComments)
- {
- memcpy(m_lpszSongComments, lpStream+dwMemPos+1, composernamelen);
- m_lpszSongComments[composernamelen] = 0;
- }
+ ReadMessage(lpStream + dwMemPos + 1, composernamelen, leCR);
}
dwMemPos += composernamelen + 1;
// channel names
Modified: trunk/OpenMPT/soundlib/Load_far.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_far.cpp 2010-07-13 19:19:41 UTC (rev 644)
+++ trunk/OpenMPT/soundlib/Load_far.cpp 2010-07-13 19:59:59 UTC (rev 645)
@@ -102,11 +102,7 @@
{
UINT szLen = pmh1->stlen;
if (szLen > dwMemLength - dwMemPos) szLen = dwMemLength - dwMemPos;
- if ((m_lpszSongComments = new char[szLen + 1]) != NULL)
- {
- memcpy(m_lpszSongComments, lpStream+dwMemPos, szLen);
- m_lpszSongComments[szLen] = 0;
- }
+ ReadFixedLineLengthMessage(lpStream + dwMemPos, szLen, 132, 0); // 132 characters per line... wow. :)
dwMemPos += pmh1->stlen;
}
// Reading orders
Modified: trunk/OpenMPT/soundlib/Load_gdm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_gdm.cpp 2010-07-13 19:19:41 UTC (rev 644)
+++ trunk/OpenMPT/soundlib/Load_gdm.cpp 2010-07-13 19:59:59 UTC (rev 645)
@@ -272,7 +272,7 @@
for(UINT iRow = 0; iRow < 64; iRow++)
{
- do // zero byte = next row
+ while(true) // zero byte = next row
{
if(iPatternPos + 1 > dwMemLength) break;
@@ -307,7 +307,7 @@
m->command = CMD_NONE;
m->volcmd = CMD_NONE;
- do
+ while(true)
{
if(iPatternPos + 2 > dwMemLength) break;
BYTE bEffect = lpStream[iPatternPos++];
@@ -493,25 +493,20 @@
}
if(!(bEffect & 0x20)) break; // no other effect follows
- } while(1);
+ }
}
- } while(1);
+ }
}
iPatternsOffset += iPatternLength;
}
// read song comments
- if(iMTLength)
+ if(iMTLength > 0)
{
- m_lpszSongComments = new char[iMTLength + 1];
- if (m_lpszSongComments)
- {
- memset(m_lpszSongComments, 0, iMTLength + 1);
- memcpy(m_lpszSongComments, lpStream + iMTOffset, iMTLength);
- }
+ ReadMessage(lpStream + iMTOffset, iMTLength, leAutodetect);
}
return true;
Modified: trunk/OpenMPT/soundlib/Load_it.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_it.cpp 2010-07-13 19:19:41 UTC (rev 644)
+++ trunk/OpenMPT/soundlib/Load_it.cpp 2010-07-13 19:59:59 UTC (rev 645)
@@ -507,23 +507,14 @@
streamPos += sizeof(DWORD);
if(id > uint16_max) return false;
- // allocate comment string
- if(m_lpszSongComments) delete[] m_lpszSongComments;
- if (id < dwMemLength && id > 0)
+ // allocate and copy comment string
+ ASSERT_CAN_READ(id);
+ if(id > 0)
{
- m_lpszSongComments = new char[id];
+ ReadMessage(lpStream + streamPos, id - 1, leCR);
}
- else
- m_lpszSongComments = NULL;
+ streamPos += id;
- // m_lpszSongComments
- if (m_lpszSongComments && id)
- {
- ASSERT_CAN_READ(id);
- memcpy(&m_lpszSongComments[0],lpStream+streamPos,id);
- streamPos += id;
- }
-
// Song global config
ASSERT_CAN_READ(5*4);
@@ -1032,21 +1023,10 @@
// Reading Song Message
if ((pifh->special & 0x01) && (pifh->msglength) && (pifh->msglength <= dwMemLength) && (pifh->msgoffset < dwMemLength - pifh->msglength))
{
- m_lpszSongComments = new char[pifh->msglength+1];
- if (m_lpszSongComments)
- {
- memcpy(m_lpszSongComments, lpStream+pifh->msgoffset, pifh->msglength);
- m_lpszSongComments[pifh->msglength] = 0;
- // ChibiTracker uses \n instead of \r.
- if(pifh->cwtv == 0x0214 && pifh->cmwt == 0x0214 && LittleEndian(pifh->reserved) == IT_CHBI)
- {
- for(size_t i = 0; i < pifh->msglength; i++)
- {
- if(m_lpszSongComments[i] == '\n')
- m_lpszSongComments[i] = '\r';
- }
- }
- }
+ // Generally, IT files should use CR for line endings. However, ChibiTracker uses LF. One could do...
+ // if(pifh->cwtv == 0x0214 && pifh->cmwt == 0x0214 && LittleEndian(pifh->reserved) == IT_CHBI) --> Chibi detected.
+ // But we'll just use autodetection here:
+ ReadMessage(lpStream + pifh->msgoffset, pifh->msglength, leAutodetect);
}
// Reading orders
UINT nordsize = pifh->ordnum;
Modified: trunk/OpenMPT/soundlib/Load_mdl.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mdl.cpp 2010-07-13 19:19:41 UTC (rev 644)
+++ trunk/OpenMPT/soundlib/Load_mdl.cpp 2010-07-13 19:59:59 UTC (rev 645)
@@ -300,15 +300,9 @@
#ifdef MDL_LOG
Log("song message: %d bytes\n", blocklen);
#endif
- if (blocklen)
+ if(blocklen)
{
- if (m_lpszSongComments) delete[] m_lpszSongComments;
- m_lpszSongComments = new char[blocklen];
- if (m_lpszSongComments)
- {
- memcpy(m_lpszSongComments, lpStream+dwMemPos, blocklen);
- m_lpszSongComments[blocklen-1] = 0;
- }
+ ReadMessage(lpStream + dwMemPos, blocklen - 1, leCR);
}
break;
// PA: Pattern Data
Modified: trunk/OpenMPT/soundlib/Load_med.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_med.cpp 2010-07-13 19:19:41 UTC (rev 644)
+++ trunk/OpenMPT/soundlib/Load_med.cpp 2010-07-13 19:59:59 UTC (rev 645)
@@ -696,18 +696,13 @@
if (pmex->channelsplit[i8ch]) m_nChannels++;
}
}
- // Song Comments
+ // Song Comments (null-terminated)
UINT annotxt = BigEndian(pmex->annotxt);
UINT annolen = BigEndian(pmex->annolen);
annolen = min(annolen, MED_MAX_COMMENT_LENGTH); //Thanks to Luigi Auriemma for pointing out an overflow risk
if ((annotxt) && (annolen) && (annolen <= dwMemLength) && (annotxt <= dwMemLength - annolen) )
{
- m_lpszSongComments = new char[annolen+1];
- if (m_lpszSongComments)
- {
- memcpy(m_lpszSongComments, lpStream+annotxt, annolen);
- m_lpszSongComments[annolen] = 0;
- }
+ ReadMessage(lpStream + annotxt, annolen - 1, leAutodetect);
}
// Song Name
UINT songname = BigEndian(pmex->songname);
Modified: trunk/OpenMPT/soundlib/Load_mid.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mid.cpp 2010-07-13 19:19:41 UTC (rev 644)
+++ trunk/OpenMPT/soundlib/Load_mid.cpp 2010-07-13 19:59:59 UTC (rev 645)
@@ -732,12 +732,7 @@
} else
if ((!m_lpszSongComments) && (ptrk->ptracks[0]) && (ptrk->ptracks[0] < 0x7F))
{
- m_lpszSongComments = new char [len+1];
- if (m_lpszSongComments)
- {
- memcpy(m_lpszSongComments, ptrk->ptracks, len);
- m_lpszSongComments[len] = 0;
- }
+ ReadMessage(ptrk->ptracks, len, leAutodetect);
}
break;
// FF.02 [text]: Song Copyright
@@ -745,12 +740,7 @@
if (!len) break;
if ((!m_lpszSongComments) && (ptrk->ptracks[0]) && (ptrk->ptracks[0] < 0x7F) && (len > 7))
{
- m_lpszSongComments = new char [len+1];
- if (m_lpszSongComments)
- {
- memcpy(m_lpszSongComments, ptrk->ptracks, len);
- m_lpszSongComments[len] = 0;
- }
+ ReadMessage(ptrk->ptracks, len, leAutodetect);
}
break;
// FF.03: Sequence Name
Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mt2.cpp 2010-07-13 19:19:41 UTC (rev 644)
+++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2010-07-13 19:59:59 UTC (rev 645)
@@ -252,16 +252,11 @@
{
// MSG
case 0x0047534D:
- if ((dwLen > 3) && (!m_lpszSongComments))
+ if (dwLen > 3)
{
DWORD nTxtLen = dwLen;
if (nTxtLen > 32000) nTxtLen = 32000;
- m_lpszSongComments = new char[nTxtLen];
- if (m_lpszSongComments)
- {
- memcpy(m_lpszSongComments, lpStream+dwMemPos+1, nTxtLen-1);
- m_lpszSongComments[nTxtLen-1] = 0;
- }
+ ReadMessage(lpStream + dwMemPos + 1, nTxtLen - 1, leCRLF);
}
break;
// SUM -> author name (or "Unregistered")
Modified: trunk/OpenMPT/soundlib/Load_mtm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mtm.cpp 2010-07-13 19:19:41 UTC (rev 644)
+++ trunk/OpenMPT/soundlib/Load_mtm.cpp 2010-07-13 19:59:59 UTC (rev 645)
@@ -139,19 +139,7 @@
if ((pmh->commentsize) && (dwMemPos + pmh->commentsize < dwMemLength))
{
UINT n = pmh->commentsize;
- m_lpszSongComments = new char[n+1];
- if (m_lpszSongComments)
- {
- memcpy(m_lpszSongComments, lpStream+dwMemPos, n);
- m_lpszSongComments[n] = 0;
- for (UINT i=0; i<n; i++)
- {
- if (!m_lpszSongComments[i])
- {
- m_lpszSongComments[i] = ((i + 1) % 40) ? 0x20 : 0x0D;
- }
- }
- }
+ ReadFixedLineLengthMessage(lpStream + dwMemPos, n, 39, 1);
}
dwMemPos += pmh->commentsize;
// Reading Samples
Modified: trunk/OpenMPT/soundlib/Load_ult.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_ult.cpp 2010-07-13 19:19:41 UTC (rev 644)
+++ trunk/OpenMPT/soundlib/Load_ult.cpp 2010-07-13 19:59:59 UTC (rev 645)
@@ -332,18 +332,7 @@
uint8 nNumLines = (uint8)lpStream[dwMemPos++];
ASSERT_CAN_READ((DWORD)(nNumLines * 32));
// read "nNumLines" lines, each containing 32 characters.
- if(m_lpszSongComments != nullptr)
- delete(m_lpszSongComments);
- m_lpszSongComments = new char[(nNumLines * 33) + 1];
- if(m_lpszSongComments)
- {
- for(size_t nLine = 0; nLine < nNumLines; nLine++)
- {
- memcpy(m_lpszSongComments + nLine * 33, lpStream + dwMemPos + nLine * 32, 32);
- m_lpszSongComments[nLine * 33 + 32] = 0x0D;
- }
- m_lpszSongComments[nNumLines * 33] = 0;
- }
+ ReadFixedLineLengthMessage(lpStream + dwMemPos, nNumLines * 32, 32, 0);
dwMemPos += nNumLines * 32;
ASSERT_CAN_READ(1);
Modified: trunk/OpenMPT/soundlib/Load_xm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_xm.cpp 2010-07-13 19:19:41 UTC (rev 644)
+++ trunk/OpenMPT/soundlib/Load_xm.cpp 2010-07-13 19:59:59 UTC (rev 645)
@@ -607,12 +607,7 @@
dwMemPos += 8;
if ((dwMemPos + len <= dwMemLength) && (len < 16384))
{
- m_lpszSongComments = new char[len+1];
- if (m_lpszSongComments)
- {
- memcpy(m_lpszSongComments, lpStream+dwMemPos, len);
- m_lpszSongComments[len] = 0;
- }
+ ReadMessage(lpStream + dwMemPos, len, leCR);
dwMemPos += len;
}
bMadeWithModPlug = true;
Added: trunk/OpenMPT/soundlib/Message.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Message.cpp (rev 0)
+++ trunk/OpenMPT/soundlib/Message.cpp 2010-07-13 19:59:59 UTC (rev 645)
@@ -0,0 +1,242 @@
+/*
+ * Message.cpp
+ * -----------
+ * Purpose: Various functions concerning song messages (allocating, reading from file...)
+ * Notes : Those functions should offer a rather high level of abstraction compared to
+ * previous ways of reading the song messages. There are still many things to do,
+ * though. Future versions of ReadMessage() could f.e. offer charset conversion
+ * and the code is not yet ready for unicode.
+ * Some functions for preparing the message text to be written to a file would
+ * also be handy.
+ * Authors: OpenMPT Devs
+ *
+ */
+
+#include "stdafx.h"
+#include "Sndfile.h"
+
+
+// Allocate memory for song message.
+// [in] length: text length in characters, without possible trailing null terminator.
+// [out] returns true on success.
+bool CSoundFile::AllocateMessage(size_t length)
+//---------------------------------------------
+{
+ FreeMessage();
+ m_lpszSongComments = new char[length + 1]; // + 1 for trailing null
+ if(m_lpszSongComments == nullptr)
+ {
+ return false;
+ } else
+ {
+ memset(m_lpszSongComments, 0, length + 1);
+ return true;
+ }
+}
+
+
+// Free previously allocated song message memory
+void CSoundFile::FreeMessage()
+//----------------------------
+{
+ if(m_lpszSongComments)
+ {
+ delete[] m_lpszSongComments;
+ m_lpszSongComments = nullptr;
+ }
+}
+
+
+// Read song message from a mapped file.
+// [in] data: pointer to the data in memory that is going to be read
+// [in] length: number of characters that should be read, not including a possible trailing null terminator (it is automatically appended).
+// [in] lineEnding: line ending formatting of the text in memory.
+// [out] returns true on success.
+bool CSoundFile::ReadMessage(const BYTE *data, const size_t length, enmLineEndings lineEnding)
+//--------------------------------------------------------------------------------------------
+{
+ // Simple line-ending detection algorithm. VERY simple.
+ if(lineEnding == leAutodetect)
+ {
+ size_t nCR = 0, nLF = 0, nCRLF = 0;
+ // find CRs, LFs and CRLFs
+ for(size_t i = 0; i < length; i++)
+ {
+ if(data[i] == '\r') nCR++;
+ else if(data[i] == '\n') nLF++;
+
+ if(i && data[i - 1] == '\r' && data[i] == '\n') nCRLF++;
+ }
+ // evaluate findings
+ if(nCR == nLF && nCR == nCRLF)
+ lineEnding = leCRLF;
+ else if(nCR && !nLF)
+ lineEnding = leCR;
+ else if(!nCR && nLF)
+ lineEnding = leLF;
+ else
+ lineEnding = leMixed;
+ }
+
+ size_t final_length = 0;
+ // calculate the final amount of characters to be allocated.
+ for(size_t i = 0; i < length; i++)
+ {
+ switch(data[i])
+ {
+ case '\r':
+ if(lineEnding != leLF) final_length++;
+ break;
+ case '\n':
+ if(lineEnding != leCR && lineEnding != leCRLF) final_length++;
+ break;
+ default:
+ final_length++;
+ break;
+ }
+ }
+
+ if(!AllocateMessage(final_length))
+ return false;
+
+ size_t cpos = 0;
+ for(size_t i = 0; i < length; i++, cpos++)
+ {
+ switch(data[i])
+ {
+ case '\r':
+ if(lineEnding != leLF)
+ m_lpszSongComments[cpos] = '\r';
+ else
+ m_lpszSongComments[cpos] = ' ';
+ if(lineEnding == leCRLF) i++; // skip the LF
+ break;
+ case '\n':
+ if(lineEnding != leCR && lineEnding != leCRLF)
+ m_lpszSongComments[cpos] = '\r';
+ else
+ m_lpszSongComments[cpos] = ' ';
+ break;
+ case '\0':
+ m_lpszSongComments[cpos] = ' ';
+ break;
+ default:
+ m_lpszSongComments[cpos] = data[i];
+ break;
+ }
+ }
+
+ return true;
+}
+
+
+// Read comments with fixed line length from a mapped file.
+// [in] data: pointer to the data in memory that is going to be read
+// [in] length: number of characters that should be read, not including a possible trailing null terminator (it is automatically appended).
+// [in] lineLength: The fixed length of a line.
+// [in] lineEndingLength: The padding space between two fikxed lines. (there could for example be a null char after every line)
+// [out] returns true on success.
+bool CSoundFile::ReadFixedLineLengthMessage(const BYTE *data, const size_t length, const size_t lineLength, const size_t lineEndingLength)
+//----------------------------------------------------------------------------------------------------------------------------------------
+{
+ if(lineLength == 0)
+ return false;
+
+ const size_t num_lines = (length / (lineLength + lineEndingLength));
+ const size_t final_length = num_lines * (lineLength + 1);
+ if(!AllocateMessage(final_length))
+ return false;
+
+ for(size_t line = 0, fpos = 0, cpos = 0; line < num_lines; line++, fpos += (lineLength + lineEndingLength), cpos += (lineLength + 1))
+ {
+ memcpy(m_lpszSongComments + cpos, data + fpos, min(lineLength, length - fpos));
+ m_lpszSongComments[cpos + lineLength] = '\r';
+
+ // fix weird chars
+ for(size_t lpos = 0; lpos < lineLength; lpos++)
+ {
+ switch(m_lpszSongComments[cpos + lpos])
+ {
+ case '\0':
+ case '\n':
+ case '\r':
+ m_lpszSongComments[cpos + lpos] = ' ';
+ break;
+ }
+
+ }
+ }
+ return true;
+}
+
+
+// OLD and unused function. Do we still need it?
+UINT CSoundFile::GetSongMessage(LPSTR s, UINT len, UINT linesize)
+//---------------------------------------------------------------
+{
+ LPCSTR p = m_lpszSongComments;
+ if (!p) return 0;
+ UINT i = 2, ln=0;
+ if ((len) && (s)) s[0] = '\x0D';
+ if ((len > 1) && (s)) s[1] = '\x0A';
+ while ((*p) && (i+2 < len))
+ {
+ BYTE c = (BYTE)*p++;
+ if ((c == 0x0D) || ((c == ' ') && (ln >= linesize)))
+ { if (s) { s[i++] = '\x0D'; s[i++] = '\x0A'; } else i+= 2; ln=0; }
+ else
+ if (c >= 0x20) { if (s) s[i++] = c; else i++; ln++; }
+ }
+ if (s) s[i] = 0;
+ return i;
+}
+
+
+// OLD and unused function. Do we still need it?
+UINT CSoundFile::GetRawSongMessage(LPSTR s, UINT len, UINT linesize)
+//------------------------------------------------------------------
+{
+ LPCSTR p = m_lpszSongComments;
+ if (!p) return 0;
+ UINT i = 0, ln=0;
+ while ((*p) && (i < len-1))
+ {
+ BYTE c = (BYTE)*p++;
+ if ((c == 0x0D) || (c == 0x0A))
+ {
+ if (ln)
+ {
+ while (ln < linesize) { if (s) s[i] = ' '; i++; ln++; }
+ ln = 0;
+ }
+ } else
+ if ((c == ' ') && (!ln))
+ {
+ UINT k=0;
+ while ((p[k]) && (p[k] >= ' ')) k++;
+ if (k <= linesize)
+ {
+ if (s) s[i] = ' ';
+ i++;
+ ln++;
+ }
+ } else
+ {
+ if (s) s[i] = c;
+ i++;
+ ln++;
+ if (ln == linesize) ln = 0;
+ }
+ }
+ if (ln)
+ {
+ while ((ln < linesize) && (i < len))
+ {
+ if (s) s[i] = ' ';
+ i++;
+ ln++;
+ }
+ }
+ if (s) s[i] = 0;
+ return i;
+}
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2010-07-13 19:19:41 UTC (rev 644)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2010-07-13 19:59:59 UTC (rev 645)
@@ -859,8 +859,7 @@
delete[] m_lpszPatternNames;
m_lpszPatternNames = NULL;
- delete[] m_lpszSongComments;
- m_lpszSongComments = NULL;
+ FreeMessage();
for (i=1; i<MAX_SAMPLES; i++)
{
@@ -955,76 +954,6 @@
}
-UINT CSoundFile::GetSongComments(LPSTR s, UINT len, UINT linesize)
-//----------------------------------------------------------------
-{
- LPCSTR p = m_lpszSongComments;
- if (!p) return 0;
- UINT i = 2, ln=0;
- if ((len) && (s)) s[0] = '\x0D';
- if ((len > 1) && (s)) s[1] = '\x0A';
- while ((*p) && (i+2 < len))
- {
- BYTE c = (BYTE)*p++;
- if ((c == 0x0D) || ((c == ' ') && (ln >= linesize)))
- { if (s) { s[i++] = '\x0D'; s[i++] = '\x0A'; } else i+= 2; ln=0; }
- else
- if (c >= 0x20) { if (s) s[i++] = c; else i++; ln++; }
- }
- if (s) s[i] = 0;
- return i;
-}
-
-
-UINT CSoundFile::GetRawSongComments(LPSTR s, UINT len, UINT linesize)
-//-------------------------------------------------------------------
-{
- LPCSTR p = m_lpszSongComments;
- if (!p) return 0;
- UINT i = 0, ln=0;
- while ((*p) && (i < len-1))
- {
- BYTE c = (BYTE)*p++;
- if ((c == 0x0D) || (c == 0x0A))
- {
- if (ln)
- {
- while (ln < linesize) { if (s) s[i] = ' '; i++; ln++; }
- ln = 0;
- }
- } else
- if ((c == ' ') && (!ln))
- {
- UINT k=0;
- while ((p[k]) && (p[k] >= ' ')) k++;
- if (k <= linesize)
- {
- if (s) s[i] = ' ';
- i++;
- ln++;
- }
- } else
- {
- if (s) s[i] = c;
- i++;
- ln++;
- if (ln == linesize) ln = 0;
- }
- }
- if (ln)
- {
- while ((ln < linesize) && (i < len))
- {
- if (s) s[i] = ' ';
- i++;
- ln++;
- }
- }
- if (s) s[i] = 0;
- return i;
-}
-
-
BOOL CSoundFile::SetWaveConfig(UINT nRate,UINT nBits,UINT nChannels,BOOL bMMX)
//----------------------------------------------------------------------------
{
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2010-07-13 19:19:41 UTC (rev 644)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2010-07-13 19:59:59 UTC (rev 645)
@@ -443,7 +443,17 @@
#include "PlaybackEventer.h"
+// Line ending types (for reading song messages from module files)
+enum enmLineEndings
+{
+ leCR, // Carriage Return (0x0D, \r)
+ leLF, // Line Feed (0x0A \n)
+ leCRLF, // Carriage Return, Line Feed (0x0D0A, \r\n)
+ leMixed, // It is not defined whether Carriage Return or Line Feed is the actual line ending. Both are accepted.
+ leAutodetect, // Detect suitable line ending
+};
+
class CSoundFile;
@@ -627,8 +637,6 @@
UINT GetCurrentPos() const;
UINT GetCurrentPattern() const { return m_nPattern; }
ORDERINDEX GetCurrentOrder() const { return static_cast<ORDERINDEX>(m_nCurrentPattern); }
- UINT GetSongComments(LPSTR s, UINT cbsize, UINT linesize=32);
- UINT GetRawSongComments(LPSTR s, UINT cbsize, UINT linesize=32);
UINT GetMaxPosition() const;
CHANNELINDEX GetNumChannels() const { return m_nChannels; }
@@ -851,8 +859,8 @@
void GlobalVolSlide(UINT param, UINT * nOldGlobalVolSlide);
DWORD IsSongFinished(UINT nOrder, UINT nRow) const;
BOOL IsValidBackwardJump(UINT nStartOrder, UINT nStartRow, UINT nJumpOrder, UINT nJumpRow) const;
+
public:
-
// Write pattern effect functions
bool TryWriteEffect(PATTERNINDEX nPat, ROWINDEX nRow, BYTE nEffect, BYTE nParam, bool bIsVolumeEffect, CHANNELINDEX nChn = CHANNELINDEX_INVALID, bool bAllowMultipleEffects = true, bool bAllowNextRow = false, bool bRetry = true);
@@ -937,12 +945,41 @@
static LPSTR AllocateSample(UINT nbytes);
static void FreeSample(LPVOID p);
static UINT Normalize24BitBuffer(LPBYTE pbuffer, UINT cbsizebytes, DWORD lmax24, DWORD dwByteInc);
- UINT GetBestPlugin(UINT nChn, UINT priority, bool respectMutes);
//private:
static MODCOMMAND *AllocatePattern(UINT rows, UINT nchns);
static void FreePattern(LPVOID pat);
+ // Song message helper functions
public:
+ // Allocate memory for song message.
+ // [in] length: text length in characters, without possible trailing null terminator.
+ // [out] returns true on success.
+ bool AllocateMessage(size_t length);
+
+ // Free previously allocated song message memory.
+ void FreeMessage();
+
+protected:
+ // Read song message from a mapped file.
+ // [in] data: pointer to the data in memory that is going to be read
+ // [in] length: number of characters that should be read, not including a possible trailing null terminator (it is automatically appended).
+ // [in] lineEnding: line ending formatting of the text in memory.
+ // [out] returns true on success.
+ bool ReadMessage(const BYTE *data, const size_t length, enmLineEndings lineEnding);
+
+ // Read comments with fixed line length from a mapped file.
+ // [in] data: pointer to the data in memory that is going to be read
+ // [in] length: number of characters that should be read, not including a possible trailing null terminator (it is automatically appended).
+ // [in] lineLength: The fixed length of a line.
+ // [in] lineEndingLength: The padding space between two fikxed lines. (there could for example be a null char after every line)
+ // [out] returns true on success.
+ bool ReadFixedLineLengthMessage(const BYTE *data, const size_t length, const size_t lineLength, const size_t lineEndingLength);
+
+ // Currently unused (and the code doesn't look very nice :)
+ UINT GetSongMessage(LPSTR s, UINT cbsize, UINT linesize=32);
+ UINT GetRawSongMessage(LPSTR s, UINT cbsize, UINT linesize=32);
+
+public:
int getVolEnvValueFromPosition(int position, MODINSTRUMENT* pIns);
void resetEnvelopes(MODCHANNEL* pChn, enmResetEnv envToReset = ENV_RESET_ALL);
void SetDefaultInstrumentValues(MODINSTRUMENT *pIns);
@@ -955,6 +992,9 @@
void BuildDefaultInstrument();
long GetSampleOffset();
+public:
+ UINT GetBestPlugin(UINT nChn, UINT priority, bool respectMutes);
+
// A couple of functions for handling backwards jumps and stuff to prevent infinite loops when counting the mod length or rendering to wav.
public:
void InitializeVisitedRows(const bool bReset = true);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-07-13 19:19:48
|
Revision: 644
http://modplug.svn.sourceforge.net/modplug/?rev=644&view=rev
Author: saga-games
Date: 2010-07-13 19:19:41 +0000 (Tue, 13 Jul 2010)
Log Message:
-----------
[Mod] Setup: Updated format descriptions in filetypes.iss
Modified Paths:
--------------
trunk/OpenMPT/installer/filetypes.iss
Modified: trunk/OpenMPT/installer/filetypes.iss
===================================================================
--- trunk/OpenMPT/installer/filetypes.iss 2010-07-13 14:01:29 UTC (rev 643)
+++ trunk/OpenMPT/installer/filetypes.iss 2010-07-13 19:19:41 UTC (rev 644)
@@ -19,9 +19,9 @@
Name: "associate_common\compressed"; Description: "Above when compressed (MDR, MDZ, S3Z, XMZ, ITZ, MPTMZ)";
; less common
Name: "associate_exotic"; Description: "Associate OpenMPT with less common module files"; GroupDescription: "File associations:";
-Name: "associate_exotic\669"; Description: "Composer 669 (669)";
+Name: "associate_exotic\669"; Description: "Composer 669 / UNIS 669 (669)";
Name: "associate_exotic\amf"; Description: "ASYLUM Music Format / Advanced Music Format (AMF)";
-Name: "associate_exotic\ams"; Description: "Extreme Tracker (AMS)";
+Name: "associate_exotic\ams"; Description: "Extreme's Tracker / Velvet Studio (AMS)";
Name: "associate_exotic\dbm"; Description: "DigiBooster (DBM)";
Name: "associate_exotic\dmf"; Description: "X-Tracker (DMF)";
Name: "associate_exotic\dsm"; Description: "DSIK (DSM)";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-07-13 14:01:36
|
Revision: 643
http://modplug.svn.sourceforge.net/modplug/?rev=643&view=rev
Author: saga-games
Date: 2010-07-13 14:01:29 +0000 (Tue, 13 Jul 2010)
Log Message:
-----------
[Ref] Shuffled around some MODCOMMAND editing functions to new file modcommand.cpp. There might be more functions worth moving which I didn't think of.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/mptrack.vcproj
trunk/OpenMPT/mptrack/mptrack_08.vcproj
trunk/OpenMPT/soundlib/Sndfile.cpp
Added Paths:
-----------
trunk/OpenMPT/soundlib/modcommand.cpp
Modified: trunk/OpenMPT/mptrack/mptrack.vcproj
===================================================================
--- trunk/OpenMPT/mptrack/mptrack.vcproj 2010-07-12 22:45:33 UTC (rev 642)
+++ trunk/OpenMPT/mptrack/mptrack.vcproj 2010-07-13 14:01:29 UTC (rev 643)
@@ -367,6 +367,9 @@
RelativePath="..\soundlib\mod_specifications.cpp">
</File>
<File
+ RelativePath="..\soundlib\modcommand.cpp">
+ </File>
+ <File
RelativePath=".\Moddoc.cpp">
</File>
<File
Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj
===================================================================
--- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2010-07-12 22:45:33 UTC (rev 642)
+++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2010-07-13 14:01:29 UTC (rev 643)
@@ -493,6 +493,10 @@
>
</File>
<File
+ RelativePath="..\soundlib\modcommand.cpp"
+ >
+ </File>
+ <File
RelativePath=".\Moddoc.cpp"
>
</File>
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2010-07-12 22:45:33 UTC (rev 642)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2010-07-13 14:01:29 UTC (rev 643)
@@ -70,8 +70,6 @@
extern void ITUnpack8Bit(LPSTR pSample, DWORD dwLen, LPBYTE lpMemFile, DWORD dwMemLength, BOOL b215);
extern void ITUnpack16Bit(LPSTR pSample, DWORD dwLen, LPBYTE lpMemFile, DWORD dwMemLength, BOOL b215);
-extern BYTE ImpulseTrackerPortaVolCmd[16];
-
#define MAX_PACK_TABLES 3
@@ -457,7 +455,7 @@
m_nInstruments = 0;
m_nPatternNames = 0;
m_lpszPatternNames = NULL;
- m_lpszSongComments = NULL;
+ m_lpszSongComments = nullptr;
m_nFreqFactor = m_nTempoFactor = 128;
m_nMasterVolume = 128;
m_nMinPeriod = MIN_PERIOD;
@@ -550,7 +548,7 @@
m_nPatternNames = 0;
m_nMaxOrderPosition = 0;
m_lpszPatternNames = NULL;
- m_lpszSongComments = NULL;
+ m_lpszSongComments = nullptr;
m_nMixLevels = mixLevels_original; // Will be overridden if appropriate.
memset(Samples, 0, sizeof(Samples));
memset(ChnMix, 0, sizeof(ChnMix));
@@ -3028,7 +3026,6 @@
}
-
long CSoundFile::GetSampleOffset()
//-------------------------------
{
@@ -3144,158 +3141,6 @@
}
-/* Try to write an (volume column) effect in a given channel or any channel of a pattern in a specific row.
- Usage: nPat - Pattern that should be modified
- nRow - Row that should be modified
- nEffect - (Volume) Effect that should be written
- nParam - Effect that should be written
- bIsVolumeEffect - Indicates whether the given effect is a volume column effect or not
- nChn - Channel that should be modified - use CHANNELINDEX_INVALID to allow all channels of the given row
- bAllowMultipleEffects - If false, No effect will be written if an effect of the same type is already present in the channel(s). Useful for f.e. tempo effects.
- bAllowNextRow - Indicates whether it is allowed to use the next row if there's no space for the effect
- bRetry - For internal use only. Indicates whether an effect "rewrite" has already taken place (for recursive calls)
-*/
-bool CSoundFile::TryWriteEffect(PATTERNINDEX nPat, ROWINDEX nRow, BYTE nEffect, BYTE nParam, bool bIsVolumeEffect, CHANNELINDEX nChn, bool bAllowMultipleEffects, bool bAllowNextRow, bool bRetry)
-//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-{
- // NOTE: Effect remapping is only implemented for a few basic effects.
- CHANNELINDEX nScanChnMin = nChn, nScanChnMax = nChn;
- MODCOMMAND *p = Patterns[nPat], *m;
-
- // Scan all channels
- if(nChn == CHANNELINDEX_INVALID)
- {
- nScanChnMin = 0;
- nScanChnMax = m_nChannels - 1;
- }
-
- // Scan channel(s) for same effect type - if an effect of the same type is already present, exit.
- if(!bAllowMultipleEffects)
- {
- for(CHANNELINDEX i = nScanChnMin; i <= nScanChnMax; i++)
- {
- m = p + nRow * m_nChannels + i;
- if(!bIsVolumeEffect && m->command == nEffect)
- return true;
- if(bIsVolumeEffect && m->volcmd == nEffect)
- return true;
- }
- }
-
- // Easy case: check if there's some space left to put the effect somewhere
- for(CHANNELINDEX i = nScanChnMin; i <= nScanChnMax; i++)
- {
- m = p + nRow * m_nChannels + i;
- if(!bIsVolumeEffect && m->command == CMD_NONE)
- {
- m->command = nEffect;
- m->param = nParam;
- return true;
- }
- if(bIsVolumeEffect && m->volcmd == VOLCMD_NONE)
- {
- m->volcmd = nEffect;
- m->vol = nParam;
- return true;
- }
- }
-
- // Ok, apparently there's no space. If we haven't tried already, try to map it to the volume column or effect column instead.
- if(bRetry)
- {
- // Move some effects that also work in the volume column, so there's place for our new effect.
- if(!bIsVolumeEffect)
- {
- for(CHANNELINDEX i = nScanChnMin; i <= nScanChnMax; i++)
- {
- m = p + nRow * m_nChannels + i;
- switch(m->command)
- {
- case CMD_VOLUME:
- m->volcmd = VOLCMD_VOLUME;
- m->vol = m->param;
- m->command = nEffect;
- m->param = nParam;
- return true;
-
- case CMD_PANNING8:
- if(m_nType & MOD_TYPE_S3M && nParam > 0x80)
- break;
-
- m->volcmd = VOLCMD_PANNING;
- m->command = nEffect;
-
- if(m_nType & MOD_TYPE_S3M)
- {
- m->vol = m->param >> 1;
- }
- else
- {
- m->vol = (m->param >> 2) + 1;
- }
-
- m->param = nParam;
- return true;
- }
- }
- }
-
- // Let's try it again by writing into the "other" effect column.
- BYTE nNewEffect = CMD_NONE;
- if(bIsVolumeEffect)
- {
- switch(nEffect)
- {
- case VOLCMD_PANNING:
- nNewEffect = CMD_PANNING8;
- if(m_nType & MOD_TYPE_S3M)
- nParam <<= 1;
- else
- nParam = min(nParam << 2, 0xFF);
- break;
- case VOLCMD_VOLUME:
- nNewEffect = CMD_VOLUME;
- break;
- }
- } else
- {
- switch(nEffect)
- {
- case CMD_PANNING8:
- nNewEffect = VOLCMD_PANNING;
- if(m_nType & MOD_TYPE_S3M)
- {
- if(nParam <= 0x80)
- nParam >>= 1;
- else
- nNewEffect = CMD_NONE;
- }
- else
- {
- nParam = (nParam >> 2) + 1;
- }
- break;
- case CMD_VOLUME:
- nNewEffect = CMD_VOLUME;
- break;
- }
- }
- if(nNewEffect != CMD_NONE)
- {
- if(TryWriteEffect(nPat, nRow, nNewEffect, nParam, !bIsVolumeEffect, nChn, bAllowMultipleEffects, bAllowNextRow, false) == true) return true;
- }
- }
-
- // Try in the next row if possible (this may also happen if we already retried)
- if(bAllowNextRow && (nRow + 1 < Patterns[nPat].GetNumRows()))
- {
- return TryWriteEffect(nPat, nRow + 1, nEffect, nParam, bIsVolumeEffect, nChn, bAllowMultipleEffects, bAllowNextRow, bRetry);
- }
-
- return false;
-}
-
-
// Set up channel panning and volume suitable for MOD + similar files. If the current mod type is not MOD, bForceSetup has to be set to true.
void CSoundFile::SetupMODPanning(bool bForceSetup)
//------------------------------------------------
@@ -3312,749 +3157,3 @@
ChnSettings[nChn].nPan = (((nChn & 3) == 1) || ((nChn & 3) == 2)) ? 0xC0 : 0x40;
}
}
-
-
-// Convert an Exx command (MOD) to Sxx command (S3M)
-void CSoundFile::MODExx2S3MSxx(MODCOMMAND *m)
-//-------------------------------------------
-{
- if(m->command != CMD_MODCMDEX) return;
- m->command = CMD_S3MCMDEX;
- switch(m->param & 0xF0)
- {
- case 0x10: m->command = CMD_PORTAMENTOUP; m->param |= 0xF0; break;
- case 0x20: m->command = CMD_PORTAMENTODOWN; m->param |= 0xF0; break;
- case 0x30: m->param = (m->param & 0x0F) | 0x10; break;
- case 0x40: m->param = (m->param & 0x03) | 0x30; break;
- case 0x50: m->param = (m->param & 0x0F) | 0x20; break;
- case 0x60: m->param = (m->param & 0x0F) | 0xB0; break;
- case 0x70: m->param = (m->param & 0x03) | 0x40; break;
- case 0x90: m->command = CMD_RETRIG; m->param = 0x80 | (m->param & 0x0F); break;
- case 0xA0: if (m->param & 0x0F) { m->command = CMD_VOLUMESLIDE; m->param = (m->param << 4) | 0x0F; } else m->command = 0; break;
- case 0xB0: if (m->param & 0x0F) { m->command = CMD_VOLUMESLIDE; m->param |= 0xF0; } else m->command = 0; break;
- case 0xC0: if (m->param == 0xC0) { m->command = CMD_NONE; m->note = NOTE_NOTECUT; } // this does different things in IT and ST3
- case 0xD0: if (m->param == 0xD0) { m->command = CMD_NONE; } // dito
- // rest are the same
- }
-}
-
-
-// Convert an Sxx command (S3M) to Exx command (MOD)
-void CSoundFile::S3MSxx2MODExx(MODCOMMAND *m)
-//-------------------------------------------
-{
- if(m->command != CMD_S3MCMDEX) return;
- m->command = CMD_MODCMDEX;
- switch(m->param & 0xF0)
- {
- case 0x10: m->param = (m->param & 0x0F) | 0x30; break;
- case 0x20: m->param = (m->param & 0x0F) | 0x50; break;
- case 0x30: m->param = (m->param & 0x0F) | 0x40; break;
- case 0x40: m->param = (m->param & 0x0F) | 0x70; break;
- case 0x50:
- case 0x60:
- case 0x70: if(((m->param & 0xF0) == 0x70) && ((m->param & 0x0F) > 0x0A)) { m->command = CMD_NONE; break; } // no pitch env in XM format
- case 0x90:
- case 0xA0: m->command = CMD_XFINEPORTAUPDOWN; break;
- case 0xB0: m->param = (m->param & 0x0F) | 0x60; break;
- // rest are the same
- }
-}
-
-
-// Convert a mod command from one format to another.
-void CSoundFile::ConvertCommand(MODCOMMAND *m, MODTYPE nOldType, MODTYPE nNewType)
-//--------------------------------------------------------------------------------
-{
- // helper variables
- const bool oldTypeIsMOD = (nOldType == MOD_TYPE_MOD), oldTypeIsXM = (nOldType == MOD_TYPE_XM),
- oldTypeIsS3M = (nOldType == MOD_TYPE_S3M), oldTypeIsIT = (nOldType == MOD_TYPE_IT),
- oldTypeIsMPT = (nOldType == MOD_TYPE_MPT), oldTypeIsMOD_XM = (oldTypeIsMOD || oldTypeIsXM),
- oldTypeIsS3M_IT_MPT = (oldTypeIsS3M || oldTypeIsIT || oldTypeIsMPT),
- oldTypeIsIT_MPT = (oldTypeIsIT || oldTypeIsMPT);
-
- const bool newTypeIsMOD = (nNewType == MOD_TYPE_MOD), newTypeIsXM = (nNewType == MOD_TYPE_XM),
- newTypeIsS3M = (nNewType == MOD_TYPE_S3M), newTypeIsIT = (nNewType == MOD_TYPE_IT),
- newTypeIsMPT = (nNewType == MOD_TYPE_MPT), newTypeIsMOD_XM = (newTypeIsMOD || newTypeIsXM),
- newTypeIsS3M_IT_MPT = (newTypeIsS3M || newTypeIsIT || newTypeIsMPT),
- newTypeIsIT_MPT = (newTypeIsIT || newTypeIsMPT);
-
- //////////////////////////
- // Convert 8-bit Panning
- if(m->command == CMD_PANNING8)
- {
- if(newTypeIsS3M)
- {
- m->param = (m->param + 1) >> 1;
- }
- else if(oldTypeIsS3M)
- {
- if(m->param == 0xA4)
- {
- // surround remap
- m->command = (nNewType & (MOD_TYPE_IT|MOD_TYPE_MPT)) ? CMD_S3MCMDEX : CMD_XFINEPORTAUPDOWN;
- m->param = 0x91;
- }
- else
- {
- m->param = min(m->param << 1, 0xFF);
- }
- }
- } // End if(m->command == CMD_PANNING8)
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // MPTM to anything: Convert param control, extended envelope control, note delay+cut
- if(oldTypeIsMPT)
- {
- if(m->IsPcNote())
- {
- m->param = (BYTE)(min(MODCOMMAND::maxColumnValue, m->GetValueEffectCol()) * 0x7F / MODCOMMAND::maxColumnValue);
- m->command = (m->note == NOTE_PC) ? CMD_MIDI : CMD_SMOOTHMIDI; // might be removed later
- m->volcmd = VOLCMD_NONE;
- m->note = NOTE_NONE;
- m->instr = 0;
- }
-
- // adjust extended envelope control commands
- if((m->command == CMD_S3MCMDEX) && ((m->param & 0xF0) == 0x70) && ((m->param & 0x0F) > 0x0C))
- {
- m->param = 0x7C;
- }
-
- if(m->command == CMD_DELAYCUT)
- {
- m->command = CMD_S3MCMDEX; // when converting to MOD/XM, this will be converted to CMD_MODCMDEX later
- m->param = 0xD0 | (m->param >> 4); // preserve delay nibble.
- }
- } // End if(oldTypeIsMPT)
-
- /////////////////////////////////////////
- // Convert MOD / XM to S3M / IT / MPTM
- if(oldTypeIsMOD_XM && newTypeIsS3M_IT_MPT)
- {
- switch(m->command)
- {
- case CMD_MODCMDEX:
- MODExx2S3MSxx(m);
- break;
- case CMD_VOLUME:
- if (!m->volcmd)
- {
- m->volcmd = VOLCMD_VOLUME;
- m->vol = m->param;
- if (m->vol > 0x40) m->vol = 0x40;
- m->command = m->param = 0;
- }
- break;
- case CMD_PORTAMENTOUP:
- if (m->param > 0xDF) m->param = 0xDF;
- break;
- case CMD_PORTAMENTODOWN:
- if (m->param > 0xDF) m->param = 0xDF;
- break;
- case CMD_XFINEPORTAUPDOWN:
- switch(m->param & 0xF0)
- {
- case 0x10: m->command = CMD_PORTAMENTOUP; m->param = (m->param & 0x0F) | 0xE0; break;
- case 0x20: m->command = CMD_PORTAMENTODOWN; m->param = (m->param & 0x0F) | 0xE0; break;
- case 0x50:
- case 0x60:
- case 0x70:
- case 0x90:
- case 0xA0:
- m->command = CMD_S3MCMDEX;
- // surround remap (this is the "official" command)
- if(nNewType & MOD_TYPE_S3M && m->param == 0x91)
- {
- m->command = CMD_PANNING8;
- m->param = 0xA4;
- }
- break;
- }
- break;
- case CMD_KEYOFF:
- if(m->note == 0)
- {
- m->note = (newTypeIsS3M) ? NOTE_NOTECUT : NOTE_KEYOFF;
- m->command = CMD_S3MCMDEX;
- if(m->param == 0)
- m->instr = 0;
- m->param = 0xD0 | (m->param & 0x0F);
- }
- break;
- case CMD_PANNINGSLIDE:
- // swap L/R
- m->param = ((m->param & 0x0F) << 4) | (m->param >> 4);
- default:
- break;
- }
- } // End if(oldTypeIsMOD_XM && newTypeIsS3M_IT_MPT)
-
-
- /////////////////////////////////////////
- // Convert S3M / IT / MPTM to MOD / XM
- else if(oldTypeIsS3M_IT_MPT && newTypeIsMOD_XM)
- {
- if(m->note == NOTE_NOTECUT)
- {
- // convert note cut to EC0
- m->note = NOTE_NONE;
- m->command = CMD_MODCMDEX;
- m->param = 0xC0;
- } else if(m->note == NOTE_FADE)
- {
- // convert note fade to note off
- m->note = NOTE_KEYOFF;
- }
-
- switch(m->command)
- {
- case CMD_S3MCMDEX:
- S3MSxx2MODExx(m);
- break;
- case CMD_VOLUMESLIDE:
- if ((m->param & 0xF0) && ((m->param & 0x0F) == 0x0F))
- {
- m->command = CMD_MODCMDEX;
- m->param = (m->param >> 4) | 0xA0;
- } else
- if ((m->param & 0x0F) && ((m->param & 0xF0) == 0xF0))
- {
- m->command = CMD_MODCMDEX;
- m->param = (m->param & 0x0F) | 0xB0;
- }
- break;
- case CMD_PORTAMENTOUP:
- if (m->param >= 0xF0)
- {
- m->command = CMD_MODCMDEX;
- m->param = (m->param & 0x0F) | 0x10;
- } else
- if (m->param >= 0xE0)
- {
- m->command = CMD_MODCMDEX;
- m->param = (((m->param & 0x0F)+3) >> 2) | 0x10;
- } else m->command = CMD_PORTAMENTOUP;
- break;
- case CMD_PORTAMENTODOWN:
- if (m->param >= 0xF0)
- {
- m->command = CMD_MODCMDEX;
- m->param = (m->param & 0x0F) | 0x20;
- } else
- if (m->param >= 0xE0)
- {
- m->command = CMD_MODCMDEX;
- m->param = (((m->param & 0x0F)+3) >> 2) | 0x20;
- } else m->command = CMD_PORTAMENTODOWN;
- break;
- case CMD_SPEED:
- {
- m->param = min(m->param, (nNewType == MOD_TYPE_XM) ? 0x1F : 0x20);
- }
- break;
- case CMD_TEMPO:
- if(m->param < 0x20) m->command = CMD_NONE; // no tempo slides
- break;
- case CMD_PANNINGSLIDE:
- // swap L/R
- m->param = ((m->param & 0x0F) << 4) | (m->param >> 4);
- // remove fine slides
- if((m->param > 0xF0) || ((m->param & 0x0F) == 0x0F && m->param != 0x0F))
- m->command = CMD_NONE;
- default:
- break;
- }
- } // End if(oldTypeIsS3M_IT_MPT && newTypeIsMOD_XM)
-
-
- ///////////////////////
- // Convert IT to S3M
- else if(oldTypeIsIT_MPT && newTypeIsS3M)
- {
- if(m->note == NOTE_KEYOFF || m->note == NOTE_FADE)
- m->note = NOTE_NOTECUT;
-
- switch(m->command)
- {
- case CMD_S3MCMDEX:
- if(m->param == 0x91)
- {
- // surround remap (this is the "official" command)
- m->command = CMD_PANNING8;
- m->param = 0xA4;
- }
- break;
- case CMD_SMOOTHMIDI:
- m->command = CMD_MIDI;
- break;
- default:
- break;
- }
- } // End if (oldTypeIsIT_MPT && newTypeIsS3M)
-
- ///////////////////////////////////
- // MOD <-> XM: Speed/Tempo update
- if(oldTypeIsMOD && newTypeIsXM)
- {
- switch(m->command)
- {
- case CMD_SPEED:
- m->param = min(m->param, 0x1F);
- break;
- }
- } else if(oldTypeIsXM && newTypeIsMOD)
- {
- switch(m->command)
- {
- case CMD_TEMPO:
- m->param = max(m->param, 0x21);
- break;
- }
- }
-
-
- ///////////////////////////////////////////////////////////////////////
- // Convert MOD to anything - adjust effect memory, remove Invert Loop
- if (oldTypeIsMOD)
- {
- switch(m->command)
- {
- case CMD_TONEPORTAVOL: // lacks memory -> 500 is the same as 300
- if(m->param == 0x00) m->command = CMD_TONEPORTAMENTO;
- break;
- case CMD_VIBRATOVOL: // lacks memory -> 600 is the same as 400
- if(m->param == 0x00) m->command = CMD_VIBRATO;
- break;
-
- case CMD_MODCMDEX: // This would turn into "Set Active Macro", so let's better remove it
- case CMD_S3MCMDEX:
- if((m->param & 0xF0) == 0xF0) m->command = CMD_NONE;
- break;
- }
- } // End if (oldTypeIsMOD && newTypeIsXM)
-
- /////////////////////////////////////////////////////////////////////
- // Convert anything to MOD - remove volume column, remove Set Macro
- if (newTypeIsMOD)
- {
- // convert note off events
- if(m->note >= NOTE_MIN_SPECIAL)
- {
- m->note = NOTE_NONE;
- // no effect present, so just convert note off to volume 0
- if(m->command == CMD_NONE)
- {
- m->command = CMD_VOLUME;
- m->param = 0;
- // EDx effect present, so convert it to ECx
- } else if((m->command == CMD_MODCMDEX) && ((m->param & 0xF0) == 0xD0))
- {
- m->param = 0xC0 | (m->param & 0x0F);
- }
- }
-
- if(m->command) switch(m->command)
- {
- case CMD_RETRIG: // MOD only has E9x
- m->command = CMD_MODCMDEX;
- m->param = 0x90 | (m->param & 0x0F);
- break;
- case CMD_MODCMDEX: // This would turn into "Invert Loop", so let's better remove it
- if((m->param & 0xF0) == 0xF0) m->command = CMD_NONE;
- break;
- }
-
- else switch(m->volcmd)
- {
- case VOLCMD_VOLUME:
- m->command = CMD_VOLUME;
- m->param = m->vol;
- break;
- case VOLCMD_PANNING:
- m->command = CMD_PANNING8;
- m->param = CLAMP(m->vol << 2, 0, 0xFF);
- break;
- case VOLCMD_VOLSLIDEDOWN:
- m->command = CMD_VOLUMESLIDE;
- m->param = m->vol;
- break;
- case VOLCMD_VOLSLIDEUP:
- m->command = CMD_VOLUMESLIDE;
- m->param = m->vol << 4;
- break;
- case VOLCMD_FINEVOLDOWN:
- m->command = CMD_MODCMDEX;
- m->param = 0xB0 | m->vol;
- break;
- case VOLCMD_FINEVOLUP:
- m->command = CMD_MODCMDEX;
- m->param = 0xA0 | m->vol;
- break;
- case VOLCMD_PORTADOWN:
- m->command = CMD_PORTAMENTODOWN;
- m->param = m->vol << 2;
- break;
- case VOLCMD_PORTAUP:
- m->command = CMD_PORTAMENTOUP;
- m->param = m->vol << 2;
- break;
- case VOLCMD_TONEPORTAMENTO:
- m->command = CMD_TONEPORTAMENTO;
- m->param = m->vol << 2;
- break;
- case VOLCMD_VIBRATODEPTH:
- m->command = CMD_VIBRATO;
- m->param = m->vol;
- break;
- case VOLCMD_VIBRATOSPEED:
- m->command = CMD_VIBRATO;
- m->param = m->vol << 4;
- break;
- // OpenMPT-specific commands
- case VOLCMD_OFFSET:
- m->command = CMD_OFFSET;
- m->param = m->vol << 3;
- break;
- default:
- break;
- }
- m->volcmd = CMD_NONE;
- } // End if (newTypeIsMOD)
-
- ///////////////////////////////////////////////////
- // Convert anything to S3M - adjust volume column
- if (newTypeIsS3M)
- {
- if(!m->command) switch(m->volcmd)
- {
- case VOLCMD_VOLSLIDEDOWN:
- m->command = CMD_VOLUMESLIDE;
- m->param = m->vol;
- m->volcmd = CMD_NONE;
- break;
- case VOLCMD_VOLSLIDEUP:
- m->command = CMD_VOLUMESLIDE;
- m->param = m->vol << 4;
- m->volcmd = CMD_NONE;
- break;
- case VOLCMD_FINEVOLDOWN:
- m->command = CMD_VOLUMESLIDE;
- m->param = 0xF0 | m->vol;
- m->volcmd = CMD_NONE;
- break;
- case VOLCMD_FINEVOLUP:
- m->command = CMD_VOLUMESLIDE;
- m->param = (m->vol << 4) | 0x0F;
- m->volcmd = CMD_NONE;
- break;
- case VOLCMD_PORTADOWN:
- m->command = CMD_PORTAMENTODOWN;
- m->param = m->vol << 2;
- m->volcmd = CMD_NONE;
- break;
- case VOLCMD_PORTAUP:
- m->command = CMD_PORTAMENTOUP;
- m->param = m->vol << 2;
- m->volcmd = CMD_NONE;
- break;
- case VOLCMD_TONEPORTAMENTO:
- m->command = CMD_TONEPORTAMENTO;
- m->param = m->vol << 2;
- m->volcmd = CMD_NONE;
- break;
- case VOLCMD_VIBRATODEPTH:
- m->command = CMD_VIBRATO;
- m->param = m->vol;
- m->volcmd = CMD_NONE;
- break;
- case VOLCMD_VIBRATOSPEED:
- m->command = CMD_VIBRATO;
- m->param = m->vol << 4;
- m->volcmd = CMD_NONE;
- break;
- case VOLCMD_PANSLIDELEFT:
- m->command = CMD_PANNINGSLIDE;
- m->param = m->vol << 4;
- m->volcmd = CMD_NONE;
- break;
- case VOLCMD_PANSLIDERIGHT:
- m->command = CMD_PANNINGSLIDE;
- m->param = m->vol;
- m->volcmd = CMD_NONE;
- break;
- // OpenMPT-specific commands
- case VOLCMD_OFFSET:
- m->command = CMD_OFFSET;
- m->param = m->vol << 3;
- m->volcmd = CMD_NONE;
- break;
- default:
- break;
- }
- } // End if (newTypeIsS3M)
-
- ////////////////////////////////////////////////////////////////////////
- // Convert anything to XM - adjust volume column, breaking EDx command
- if (newTypeIsXM)
- {
- // remove EDx if no note is next to it, or it will retrigger the note in FT2 mode
- if(m->command == CMD_MODCMDEX && (m->param & 0xF0) == 0xD0 && m->note == NOTE_NONE)
- {
- m->command = m->param = 0;
- }
-
- if(!m->command) switch(m->volcmd)
- {
- case VOLCMD_PORTADOWN:
- m->command = CMD_PORTAMENTODOWN;
- m->param = m->vol << 2;
- m->volcmd = CMD_NONE;
- break;
- case VOLCMD_PORTAUP:
- m->command = CMD_PORTAMENTOUP;
- m->param = m->vol << 2;
- m->volcmd = CMD_NONE;
- break;
- // OpenMPT-specific commands
- case VOLCMD_OFFSET:
- m->command = CMD_OFFSET;
- m->param = m->vol << 3;
- m->volcmd = CMD_NONE;
- break;
- default:
- break;
- }
- } // End if (newTypeIsXM)
-
- ///////////////////////////////////////////////////
- // Convert anything to IT - adjust volume column
- if (newTypeIsIT_MPT)
- {
- if(!m->command) switch(m->volcmd)
- {
- case VOLCMD_VOLSLIDEDOWN:
- case VOLCMD_VOLSLIDEUP:
- case VOLCMD_FINEVOLDOWN:
- case VOLCMD_FINEVOLUP:
- case VOLCMD_PORTADOWN:
- case VOLCMD_PORTAUP:
- case VOLCMD_TONEPORTAMENTO:
- case VOLCMD_VIBRATODEPTH:
- // OpenMPT-specific commands
- case VOLCMD_OFFSET:
- m->vol = min(m->vol, 9);
- break;
- case VOLCMD_PANSLIDELEFT:
- m->command = CMD_PANNINGSLIDE;
- m->param = m->vol << 4;
- m->volcmd = CMD_NONE;
- break;
- case VOLCMD_PANSLIDERIGHT:
- m->command = CMD_PANNINGSLIDE;
- m->param = m->vol;
- m->volcmd = CMD_NONE;
- break;
- case VOLCMD_VIBRATOSPEED:
- m->command = CMD_VIBRATO;
- m->param = m->vol << 4;
- m->volcmd = CMD_NONE;
- break;
- default:
- break;
- }
- } // End if (newTypeIsIT)
-
- if(!CSoundFile::GetModSpecifications(nNewType).HasNote(m->note))
- m->note = NOTE_NONE;
-
- // ensure the commands really exist in this format
- if(CSoundFile::GetModSpecifications(nNewType).HasCommand(m->command) == false)
- m->command = CMD_NONE;
- if(CSoundFile::GetModSpecifications(nNewType).HasVolCommand(m->volcmd) == false)
- m->volcmd = CMD_NONE;
-
-}
-
-
-// "importance" of every FX command. Table is used for importing from formats with multiple effect colums
-// and is approximately the same as in SchismTracker.
-uint16 CSoundFile::GetEffectWeight(MODCOMMAND::COMMAND cmd)
-//---------------------------------------------------------
-{
- switch(cmd)
- {
- case CMD_PATTERNBREAK: return 288;
- case CMD_POSITIONJUMP: return 280;
- case CMD_SPEED: return 272;
- case CMD_TEMPO: return 264;
- case CMD_GLOBALVOLUME: return 256;
- case CMD_GLOBALVOLSLIDE: return 248;
- case CMD_CHANNELVOLUME: return 240;
- case CMD_CHANNELVOLSLIDE: return 232;
- case CMD_TONEPORTAVOL: return 224;
- case CMD_TONEPORTAMENTO: return 216;
- case CMD_ARPEGGIO: return 208;
- case CMD_RETRIG: return 200;
- case CMD_TREMOR: return 192;
- case CMD_OFFSET: return 184;
- case CMD_VOLUME: return 176;
- case CMD_VIBRATOVOL: return 168;
- case CMD_VOLUMESLIDE: return 160;
- case CMD_PORTAMENTODOWN: return 152;
- case CMD_PORTAMENTOUP: return 133;
- case CMD_NOTESLIDEDOWN: return 136;
- case CMD_NOTESLIDEUP: return 128;
- case CMD_PANNING8: return 120;
- case CMD_PANNINGSLIDE: return 112;
- case CMD_SMOOTHMIDI: return 104;
- case CMD_MIDI: return 96;
- case CMD_DELAYCUT: return 88;
- case CMD_MODCMDEX: return 80;
- case CMD_S3MCMDEX: return 72;
- case CMD_PANBRELLO: return 64;
- case CMD_XFINEPORTAUPDOWN: return 56;
- case CMD_VIBRATO: return 48;
- case CMD_FINEVIBRATO: return 40;
- case CMD_TREMOLO: return 32;
- case CMD_KEYOFF: return 24;
- case CMD_SETENVPOSITION: return 16;
- case CMD_XPARAM: return 8;
- case CMD_NONE:
- default: return 0;
- }
-}
-
-// Try to convert a fx column command (*e) into a volume column command.
-// Returns true if successful.
-// Some commands can only be converted by losing some precision.
-// If moving the command into the volume column is more important than accuracy, use bForce = true.
-// (Code translated from SchismTracker and mainly supposed to be used with loaders ported from this tracker)
-bool CSoundFile::ConvertVolEffect(uint8 *e, uint8 *p, bool bForce)
-//----------------------------------------------------------------
-{
- switch (*e)
- {
- case CMD_NONE:
- return true;
- case CMD_VOLUME:
- *e = VOLCMD_VOLUME;
- *p = min(*p, 64);
- break;
- case CMD_PORTAMENTOUP:
- if (bForce)
- *p = min(*p, 9);
- else if (*p > 9)
- return false;
- *e = VOLCMD_PORTAUP;
- break;
- case CMD_PORTAMENTODOWN:
- if (bForce)
- *p = min(*p, 9);
- else if (*p > 9)
- return false;
- *e = VOLCMD_PORTADOWN;
- break;
- case CMD_TONEPORTAMENTO:
- if (*p >= 0xF0)
- {
- // hack for people who can't type F twice :)
- *e = VOLCMD_TONEPORTAMENTO;
- *p = 0xFF;
- return true;
- }
- for (uint8 n = 0; n < 10; n++)
- {
- if (bForce
- ? (*p <= ImpulseTrackerPortaVolCmd[n])
- : (*p == ImpulseTrackerPortaVolCmd[n]))
- {
- *e = VOLCMD_TONEPORTAMENTO;
- *p = n;
- return true;
- }
- }
- return false;
- case CMD_VIBRATO:
- if (bForce)
- *p = min(*p, 9);
- else if (*p > 9)
- return false;
- *e = VOLCMD_VIBRATODEPTH;
- break;
- case CMD_FINEVIBRATO:
- if (bForce)
- *p = 0;
- else if (*p)
- return false;
- *e = VOLCMD_VIBRATODEPTH;
- break;
- case CMD_PANNING8:
- *p = min(64, *p * 64 / 255);
- *e = VOLCMD_PANNING;
- break;
- case CMD_VOLUMESLIDE:
- if (*p == 0)
- return false;
- if ((*p & 0xF) == 0) // Dx0 / Cx
- {
- if (bForce)
- *p = min(*p >> 4, 9);
- else if ((*p >> 4) > 9)
- return false;
- else
- *p >>= 4;
- *e = VOLCMD_VOLSLIDEUP;
- } else if ((*p & 0xF0) == 0) // D0x / Dx
- {
- if (bForce)
- *p = min(*p, 9);
- else if (*p > 9)
- return false;
- *e = VOLCMD_VOLSLIDEDOWN;
- } else if ((*p & 0xF) == 0xF) // DxF / Ax
- {
- if (bForce)
- *p = min(*p >> 4, 9);
- else if ((*p >> 4) > 9)
- return false;
- else
- *p >>= 4;
- *e = VOLCMD_FINEVOLUP;
- } else if ((*p & 0xf0) == 0xf0) // DFx / Bx
- {
- if (bForce)
- *p = min(*p, 9);
- else if ((*p & 0xF) > 9)
- return false;
- else
- *p &= 0xF;
- *e = VOLCMD_FINEVOLDOWN;
- } else // ???
- {
- return false;
- }
- break;
- case CMD_S3MCMDEX:
- switch (*p >> 4)
- {
- case 8:
- *e = VOLCMD_PANNING;
- *p = ((*p & 0xf) << 2) + 2;
- return true;
- case 0: case 1: case 2: case 0xF:
- if (bForce)
- {
- *e = *p = 0;
- return true;
- }
- break;
- default:
- break;
- }
- return false;
- default:
- return false;
- }
- return true;
-}
Added: trunk/OpenMPT/soundlib/modcommand.cpp
===================================================================
--- trunk/OpenMPT/soundlib/modcommand.cpp (rev 0)
+++ trunk/OpenMPT/soundlib/modcommand.cpp 2010-07-13 14:01:29 UTC (rev 643)
@@ -0,0 +1,911 @@
+/*
+ * modcommand.cpp
+ * --------------
+ * Purpose: Various functions for writing effects to patterns, converting MODCOMMANDs, etc.
+ * Authors: OpenMPT Devs
+ *
+ */
+
+#include "stdafx.h"
+#include "Sndfile.h"
+
+extern BYTE ImpulseTrackerPortaVolCmd[16];
+
+
+// Convert an Exx command (MOD) to Sxx command (S3M)
+void CSoundFile::MODExx2S3MSxx(MODCOMMAND *m)
+//-------------------------------------------
+{
+ if(m->command != CMD_MODCMDEX) return;
+ m->command = CMD_S3MCMDEX;
+ switch(m->param & 0xF0)
+ {
+ case 0x10: m->command = CMD_PORTAMENTOUP; m->param |= 0xF0; break;
+ case 0x20: m->command = CMD_PORTAMENTODOWN; m->param |= 0xF0; break;
+ case 0x30: m->param = (m->param & 0x0F) | 0x10; break;
+ case 0x40: m->param = (m->param & 0x03) | 0x30; break;
+ case 0x50: m->param = (m->param & 0x0F) | 0x20; break;
+ case 0x60: m->param = (m->param & 0x0F) | 0xB0; break;
+ case 0x70: m->param = (m->param & 0x03) | 0x40; break;
+ case 0x90: m->command = CMD_RETRIG; m->param = 0x80 | (m->param & 0x0F); break;
+ case 0xA0: if (m->param & 0x0F) { m->command = CMD_VOLUMESLIDE; m->param = (m->param << 4) | 0x0F; } else m->command = 0; break;
+ case 0xB0: if (m->param & 0x0F) { m->command = CMD_VOLUMESLIDE; m->param |= 0xF0; } else m->command = 0; break;
+ case 0xC0: if (m->param == 0xC0) { m->command = CMD_NONE; m->note = NOTE_NOTECUT; } // this does different things in IT and ST3
+ case 0xD0: if (m->param == 0xD0) { m->command = CMD_NONE; } // dito
+ // rest are the same
+ }
+}
+
+
+// Convert an Sxx command (S3M) to Exx command (MOD)
+void CSoundFile::S3MSxx2MODExx(MODCOMMAND *m)
+//-------------------------------------------
+{
+ if(m->command != CMD_S3MCMDEX) return;
+ m->command = CMD_MODCMDEX;
+ switch(m->param & 0xF0)
+ {
+ case 0x10: m->param = (m->param & 0x0F) | 0x30; break;
+ case 0x20: m->param = (m->param & 0x0F) | 0x50; break;
+ case 0x30: m->param = (m->param & 0x0F) | 0x40; break;
+ case 0x40: m->param = (m->param & 0x0F) | 0x70; break;
+ case 0x50:
+ case 0x60:
+ case 0x70: if(((m->param & 0xF0) == 0x70) && ((m->param & 0x0F) > 0x0A)) { m->command = CMD_NONE; break; } // no pitch env in XM format
+ case 0x90:
+ case 0xA0: m->command = CMD_XFINEPORTAUPDOWN; break;
+ case 0xB0: m->param = (m->param & 0x0F) | 0x60; break;
+ // rest are the same
+ }
+}
+
+
+// Convert a mod command from one format to another.
+void CSoundFile::ConvertCommand(MODCOMMAND *m, MODTYPE nOldType, MODTYPE nNewType)
+//--------------------------------------------------------------------------------
+{
+ // helper variables
+ const bool oldTypeIsMOD = (nOldType == MOD_TYPE_MOD), oldTypeIsXM = (nOldType == MOD_TYPE_XM),
+ oldTypeIsS3M = (nOldType == MOD_TYPE_S3M), oldTypeIsIT = (nOldType == MOD_TYPE_IT),
+ oldTypeIsMPT = (nOldType == MOD_TYPE_MPT), oldTypeIsMOD_XM = (oldTypeIsMOD || oldTypeIsXM),
+ oldTypeIsS3M_IT_MPT = (oldTypeIsS3M || oldTypeIsIT || oldTypeIsMPT),
+ oldTypeIsIT_MPT = (oldTypeIsIT || oldTypeIsMPT);
+
+ const bool newTypeIsMOD = (nNewType == MOD_TYPE_MOD), newTypeIsXM = (nNewType == MOD_TYPE_XM),
+ newTypeIsS3M = (nNewType == MOD_TYPE_S3M), newTypeIsIT = (nNewType == MOD_TYPE_IT),
+ newTypeIsMPT = (nNewType == MOD_TYPE_MPT), newTypeIsMOD_XM = (newTypeIsMOD || newTypeIsXM),
+ newTypeIsS3M_IT_MPT = (newTypeIsS3M || newTypeIsIT || newTypeIsMPT),
+ newTypeIsIT_MPT = (newTypeIsIT || newTypeIsMPT);
+
+ //////////////////////////
+ // Convert 8-bit Panning
+ if(m->command == CMD_PANNING8)
+ {
+ if(newTypeIsS3M)
+ {
+ m->param = (m->param + 1) >> 1;
+ }
+ else if(oldTypeIsS3M)
+ {
+ if(m->param == 0xA4)
+ {
+ // surround remap
+ m->command = (nNewType & (MOD_TYPE_IT|MOD_TYPE_MPT)) ? CMD_S3MCMDEX : CMD_XFINEPORTAUPDOWN;
+ m->param = 0x91;
+ }
+ else
+ {
+ m->param = min(m->param << 1, 0xFF);
+ }
+ }
+ } // End if(m->command == CMD_PANNING8)
+
+ ///////////////////////////////////////////////////////////////////////////////////////
+ // MPTM to anything: Convert param control, extended envelope control, note delay+cut
+ if(oldTypeIsMPT)
+ {
+ if(m->IsPcNote())
+ {
+ m->param = (BYTE)(min(MODCOMMAND::maxColumnValue, m->GetValueEffectCol()) * 0x7F / MODCOMMAND::maxColumnValue);
+ m->command = (m->note == NOTE_PC) ? CMD_MIDI : CMD_SMOOTHMIDI; // might be removed later
+ m->volcmd = VOLCMD_NONE;
+ m->note = NOTE_NONE;
+ m->instr = 0;
+ }
+
+ // adjust extended envelope control commands
+ if((m->command == CMD_S3MCMDEX) && ((m->param & 0xF0) == 0x70) && ((m->param & 0x0F) > 0x0C))
+ {
+ m->param = 0x7C;
+ }
+
+ if(m->command == CMD_DELAYCUT)
+ {
+ m->command = CMD_S3MCMDEX; // when converting to MOD/XM, this will be converted to CMD_MODCMDEX later
+ m->param = 0xD0 | (m->param >> 4); // preserve delay nibble.
+ }
+ } // End if(oldTypeIsMPT)
+
+ /////////////////////////////////////////
+ // Convert MOD / XM to S3M / IT / MPTM
+ if(oldTypeIsMOD_XM && newTypeIsS3M_IT_MPT)
+ {
+ switch(m->command)
+ {
+ case CMD_MODCMDEX:
+ MODExx2S3MSxx(m);
+ break;
+ case CMD_VOLUME:
+ if (!m->volcmd)
+ {
+ m->volcmd = VOLCMD_VOLUME;
+ m->vol = m->param;
+ if (m->vol > 0x40) m->vol = 0x40;
+ m->command = m->param = 0;
+ }
+ break;
+ case CMD_PORTAMENTOUP:
+ if (m->param > 0xDF) m->param = 0xDF;
+ break;
+ case CMD_PORTAMENTODOWN:
+ if (m->param > 0xDF) m->param = 0xDF;
+ break;
+ case CMD_XFINEPORTAUPDOWN:
+ switch(m->param & 0xF0)
+ {
+ case 0x10: m->command = CMD_PORTAMENTOUP; m->param = (m->param & 0x0F) | 0xE0; break;
+ case 0x20: m->command = CMD_PORTAMENTODOWN; m->param = (m->param & 0x0F) | 0xE0; break;
+ case 0x50:
+ case 0x60:
+ case 0x70:
+ case 0x90:
+ case 0xA0:
+ m->command = CMD_S3MCMDEX;
+ // surround remap (this is the "official" command)
+ if(nNewType & MOD_TYPE_S3M && m->param == 0x91)
+ {
+ m->command = CMD_PANNING8;
+ m->param = 0xA4;
+ }
+ break;
+ }
+ break;
+ case CMD_KEYOFF:
+ if(m->note == 0)
+ {
+ m->note = (newTypeIsS3M) ? NOTE_NOTECUT : NOTE_KEYOFF;
+ m->command = CMD_S3MCMDEX;
+ if(m->param == 0)
+ m->instr = 0;
+ m->param = 0xD0 | (m->param & 0x0F);
+ }
+ break;
+ case CMD_PANNINGSLIDE:
+ // swap L/R
+ m->param = ((m->param & 0x0F) << 4) | (m->param >> 4);
+ default:
+ break;
+ }
+ } // End if(oldTypeIsMOD_XM && newTypeIsS3M_IT_MPT)
+
+
+ /////////////////////////////////////////
+ // Convert S3M / IT / MPTM to MOD / XM
+ else if(oldTypeIsS3M_IT_MPT && newTypeIsMOD_XM)
+ {
+ if(m->note == NOTE_NOTECUT)
+ {
+ // convert note cut to EC0
+ m->note = NOTE_NONE;
+ m->command = CMD_MODCMDEX;
+ m->param = 0xC0;
+ } else if(m->note == NOTE_FADE)
+ {
+ // convert note fade to note off
+ m->note = NOTE_KEYOFF;
+ }
+
+ switch(m->command)
+ {
+ case CMD_S3MCMDEX:
+ S3MSxx2MODExx(m);
+ break;
+ case CMD_VOLUMESLIDE:
+ if ((m->param & 0xF0) && ((m->param & 0x0F) == 0x0F))
+ {
+ m->command = CMD_MODCMDEX;
+ m->param = (m->param >> 4) | 0xA0;
+ } else
+ if ((m->param & 0x0F) && ((m->param & 0xF0) == 0xF0))
+ {
+ m->command = CMD_MODCMDEX;
+ m->param = (m->param & 0x0F) | 0xB0;
+ }
+ break;
+ case CMD_PORTAMENTOUP:
+ if (m->param >= 0xF0)
+ {
+ m->command = CMD_MODCMDEX;
+ m->param = (m->param & 0x0F) | 0x10;
+ } else
+ if (m->param >= 0xE0)
+ {
+ m->command = CMD_MODCMDEX;
+ m->param = (((m->param & 0x0F)+3) >> 2) | 0x10;
+ } else m->command = CMD_PORTAMENTOUP;
+ break;
+ case CMD_PORTAMENTODOWN:
+ if (m->param >= 0xF0)
+ {
+ m->command = CMD_MODCMDEX;
+ m->param = (m->param & 0x0F) | 0x20;
+ } else
+ if (m->param >= 0xE0)
+ {
+ m->command = CMD_MODCMDEX;
+ m->param = (((m->param & 0x0F)+3) >> 2) | 0x20;
+ } else m->command = CMD_PORTAMENTODOWN;
+ break;
+ case CMD_SPEED:
+ {
+ m->param = min(m->param, (nNewType == MOD_TYPE_XM) ? 0x1F : 0x20);
+ }
+ break;
+ case CMD_TEMPO:
+ if(m->param < 0x20) m->command = CMD_NONE; // no tempo slides
+ break;
+ case CMD_PANNINGSLIDE:
+ // swap L/R
+ m->param = ((m->param & 0x0F) << 4) | (m->param >> 4);
+ // remove fine slides
+ if((m->param > 0xF0) || ((m->param & 0x0F) == 0x0F && m->param != 0x0F))
+ m->command = CMD_NONE;
+ default:
+ break;
+ }
+ } // End if(oldTypeIsS3M_IT_MPT && newTypeIsMOD_XM)
+
+
+ ///////////////////////
+ // Convert IT to S3M
+ else if(oldTypeIsIT_MPT && newTypeIsS3M)
+ {
+ if(m->note == NOTE_KEYOFF || m->note == NOTE_FADE)
+ m->note = NOTE_NOTECUT;
+
+ switch(m->command)
+ {
+ case CMD_S3MCMDEX:
+ if(m->param == 0x91)
+ {
+ // surround remap (this is the "official" command)
+ m->command = CMD_PANNING8;
+ m->param = 0xA4;
+ }
+ break;
+ case CMD_SMOOTHMIDI:
+ m->command = CMD_MIDI;
+ break;
+ default:
+ break;
+ }
+ } // End if (oldTypeIsIT_MPT && newTypeIsS3M)
+
+ ///////////////////////////////////
+ // MOD <-> XM: Speed/Tempo update
+ if(oldTypeIsMOD && newTypeIsXM)
+ {
+ switch(m->command)
+ {
+ case CMD_SPEED:
+ m->param = min(m->param, 0x1F);
+ break;
+ }
+ } else if(oldTypeIsXM && newTypeIsMOD)
+ {
+ switch(m->command)
+ {
+ case CMD_TEMPO:
+ m->param = max(m->param, 0x21);
+ break;
+ }
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////
+ // Convert MOD to anything - adjust effect memory, remove Invert Loop
+ if (oldTypeIsMOD)
+ {
+ switch(m->command)
+ {
+ case CMD_TONEPORTAVOL: // lacks memory -> 500 is the same as 300
+ if(m->param == 0x00) m->command = CMD_TONEPORTAMENTO;
+ break;
+ case CMD_VIBRATOVOL: // lacks memory -> 600 is the same as 400
+ if(m->param == 0x00) m->command = CMD_VIBRATO;
+ break;
+
+ case CMD_MODCMDEX: // This would turn into "Set Active Macro", so let's better remove it
+ case CMD_S3MCMDEX:
+ if((m->param & 0xF0) == 0xF0) m->command = CMD_NONE;
+ break;
+ }
+ } // End if (oldTypeIsMOD && newTypeIsXM)
+
+ /////////////////////////////////////////////////////////////////////
+ // Convert anything to MOD - remove volume column, remove Set Macro
+ if (newTypeIsMOD)
+ {
+ // convert note off events
+ if(m->note >= NOTE_MIN_SPECIAL)
+ {
+ m->note = NOTE_NONE;
+ // no effect present, so just convert note off to volume 0
+ if(m->command == CMD_NONE)
+ {
+ m->command = CMD_VOLUME;
+ m->param = 0;
+ // EDx effect present, so convert it to ECx
+ } else if((m->command == CMD_MODCMDEX) && ((m->param & 0xF0) == 0xD0))
+ {
+ m->param = 0xC0 | (m->param & 0x0F);
+ }
+ }
+
+ if(m->command) switch(m->command)
+ {
+ case CMD_RETRIG: // MOD only has E9x
+ m->command = CMD_MODCMDEX;
+ m->param = 0x90 | (m->param & 0x0F);
+ break;
+ case CMD_MODCMDEX: // This would turn into "Invert Loop", so let's better remove it
+ if((m->param & 0xF0) == 0xF0) m->command = CMD_NONE;
+ break;
+ }
+
+ else switch(m->volcmd)
+ {
+ case VOLCMD_VOLUME:
+ m->command = CMD_VOLUME;
+ m->param = m->vol;
+ break;
+ case VOLCMD_PANNING:
+ m->command = CMD_PANNING8;
+ m->param = CLAMP(m->vol << 2, 0, 0xFF);
+ break;
+ case VOLCMD_VOLSLIDEDOWN:
+ m->command = CMD_VOLUMESLIDE;
+ m->param = m->vol;
+ break;
+ case VOLCMD_VOLSLIDEUP:
+ m->command = CMD_VOLUMESLIDE;
+ m->param = m->vol << 4;
+ break;
+ case VOLCMD_FINEVOLDOWN:
+ m->command = CMD_MODCMDEX;
+ m->param = 0xB0 | m->vol;
+ break;
+ case VOLCMD_FINEVOLUP:
+ m->command = CMD_MODCMDEX;
+ m->param = 0xA0 | m->vol;
+ break;
+ case VOLCMD_PORTADOWN:
+ m->command = CMD_PORTAMENTODOWN;
+ m->param = m->vol << 2;
+ break;
+ case VOLCMD_PORTAUP:
+ m->command = CMD_PORTAMENTOUP;
+ m->param = m->vol << 2;
+ break;
+ case VOLCMD_TONEPORTAMENTO:
+ m->command = CMD_TONEPORTAMENTO;
+ m->param = m->vol << 2;
+ break;
+ case VOLCMD_VIBRATODEPTH:
+ m->command = CMD_VIBRATO;
+ m->param = m->vol;
+ break;
+ case VOLCMD_VIBRATOSPEED:
+ m->command = CMD_VIBRATO;
+ m->param = m->vol << 4;
+ break;
+ // OpenMPT-specific commands
+ case VOLCMD_OFFSET:
+ m->command = CMD_OFFSET;
+ m->param = m->vol << 3;
+ break;
+ default:
+ break;
+ }
+ m->volcmd = CMD_NONE;
+ } // End if (newTypeIsMOD)
+
+ ///////////////////////////////////////////////////
+ // Convert anything to S3M - adjust volume column
+ if (newTypeIsS3M)
+ {
+ if(!m->command) switch(m->volcmd)
+ {
+ case VOLCMD_VOLSLIDEDOWN:
+ m->command = CMD_VOLUMESLIDE;
+ m->param = m->vol;
+ m->volcmd = CMD_NONE;
+ break;
+ case VOLCMD_VOLSLIDEUP:
+ m->command = CMD_VOLUMESLIDE;
+ m->param = m->vol << 4;
+ m->volcmd = CMD_NONE;
+ break;
+ case VOLCMD_FINEVOLDOWN:
+ m->command = CMD_VOLUMESLIDE;
+ m->param = 0xF0 | m->vol;
+ m->volcmd = CMD_NONE;
+ break;
+ case VOLCMD_FINEVOLUP:
+ m->command = CMD_VOLUMESLIDE;
+ m->param = (m->vol << 4) | 0x0F;
+ m->volcmd = CMD_NONE;
+ break;
+ case VOLCMD_PORTADOWN:
+ m->command = CMD_PORTAMENTODOWN;
+ m->param = m->vol << 2;
+ m->volcmd = CMD_NONE;
+ break;
+ case VOLCMD_PORTAUP:
+ m->command = CMD_PORTAMENTOUP;
+ m->param = m->vol << 2;
+ m->volcmd = CMD_NONE;
+ break;
+ case VOLCMD_TONEPORTAMENTO:
+ m->command = CMD_TONEPORTAMENTO;
+ m->param = m->vol << 2;
+ m->volcmd = CMD_NONE;
+ break;
+ case VOLCMD_VIBRATODEPTH:
+ m->command = CMD_VIBRATO;
+ m->param = m->vol;
+ m->volcmd = CMD_NONE;
+ break;
+ case VOLCMD_VIBRATOSPEED:
+ m->command = CMD_VIBRATO;
+ m->param = m->vol << 4;
+ m->volcmd = CMD_NONE;
+ break;
+ case VOLCMD_PANSLIDELEFT:
+ m->command = CMD_PANNINGSLIDE;
+ m->param = m->vol << 4;
+ m->volcmd = CMD_NONE;
+ break;
+ case VOLCMD_PANSLIDERIGHT:
+ m->command = CMD_PANNINGSLIDE;
+ m->param = m->vol;
+ m->volcmd = CMD_NONE;
+ break;
+ // OpenMPT-specific commands
+ case VOLCMD_OFFSET:
+ m->command = CMD_OFFSET;
+ m->param = m->vol << 3;
+ m->volcmd = CMD_NONE;
+ break;
+ default:
+ break;
+ }
+ } // End if (newTypeIsS3M)
+
+ ////////////////////////////////////////////////////////////////////////
+ // Convert anything to XM - adjust volume column, breaking EDx command
+ if (newTypeIsXM)
+ {
+ // remove EDx if no note is next to it, or it will retrigger the note in FT2 mode
+ if(m->command == CMD_MODCMDEX && (m->param & 0xF0) == 0xD0 && m->note == NOTE_NONE)
+ {
+ m->command = m->param = 0;
+ }
+
+ if(!m->command) switch(m->volcmd)
+ {
+ case VOLCMD_PORTADOWN:
+ m->command = CMD_PORTAMENTODOWN;
+ m->param = m->vol << 2;
+ m->volcmd = CMD_NONE;
+ break;
+ case VOLCMD_PORTAUP:
+ m->command = CMD_PORTAMENTOUP;
+ m->param = m->vol << 2;
+ m->volcmd = CMD_NONE;
+ break;
+ // OpenMPT-specific commands
+ case VOLCMD_OFFSET:
+ m->command = CMD_OFFSET;
+ m->param = m->vol << 3;
+ m->volcmd = CMD_NONE;
+ break;
+ default:
+ break;
+ }
+ } // End if (newTypeIsXM)
+
+ ///////////////////////////////////////////////////
+ // Convert anything to IT - adjust volume column
+ if (newTypeIsIT_MPT)
+ {
+ if(!m->command) switch(m->volcmd)
+ {
+ case VOLCMD_VOLSLIDEDOWN:
+ case VOLCMD_VOLSLIDEUP:
+ case VOLCMD_FINEVOLDOWN:
+ case VOLCMD_FINEVOLUP:
+ case VOLCMD_PORTADOWN:
+ case VOLCMD_PORTAUP:
+ case VOLCMD_TONEPORTAMENTO:
+ case VOLCMD_VIBRATODEPTH:
+ // OpenMPT-specific commands
+ case VOLCMD_OFFSET:
+ m->vol = min(m->vol, 9);
+ break;
+ case VOLCMD_PANSLIDELEFT:
+ m->command = CMD_PANNINGSLIDE;
+ m->param = m->vol << 4;
+ m->volcmd = CMD_NONE;
+ break;
+ case VOLCMD_PANSLIDERIGHT:
+ m->command = CMD_PANNINGSLIDE;
+ m->param = m->vol;
+ m->volcmd = CMD_NONE;
+ break;
+ case VOLCMD_VIBRATOSPEED:
+ m->command = CMD_VIBRATO;
+ m->param = m->vol << 4;
+ m->volcmd = CMD_NONE;
+ break;
+ default:
+ break;
+ }
+ } // End if (newTypeIsIT)
+
+ if(!CSoundFile::GetModSpecifications(nNewType).HasNote(m->note))
+ m->note = NOTE_NONE;
+
+ // ensure the commands really exist in this format
+ if(CSoundFile::GetModSpecifications(nNewType).HasCommand(m->command) == false)
+ m->command = CMD_NONE;
+ if(CSoundFile::GetModSpecifications(nNewType).HasVolCommand(m->volcmd) == false)
+ m->volcmd = CMD_NONE;
+
+}
+
+
+// "importance" of every FX command. Table is used for importing from formats with multiple effect colums
+// and is approximately the same as in SchismTracker.
+uint16 CSoundFile::GetEffectWeight(MODCOMMAND::COMMAND cmd)
+//---------------------------------------------------------
+{
+ switch(cmd)
+ {
+ case CMD_PATTERNBREAK: return 288;
+ case CMD_POSITIONJUMP: return 280;
+ case CMD_SPEED: return 272;
+ case CMD_TEMPO: return 264;
+ case CMD_GLOBALVOLUME: return 256;
+ case CMD_GLOBALVOLSLIDE: return 248;
+ case CMD_CHANNELVOLUME: return 240;
+ case CMD_CHANNELVOLSLIDE: return 232;
+ case CMD_TONEPORTAVOL: return 224;
+ case CMD_TONEPORTAMENTO: return 216;
+ case CMD_ARPEGGIO: return 208;
+ case CMD_RETRIG: return 200;
+ case CMD_TREMOR: return 192;
+ case CMD_OFFSET: return 184;
+ case CMD_VOLUME: return 176;
+ case CMD_VIBRATOVOL: return 168;
+ case CMD_VOLUMESLIDE: return 160;
+ case CMD_PORTAMENTODOWN: return 152;
+ case CMD_PORTAMENTOUP: return 133;
+ case CMD_NOTESLIDEDOWN: return 136;
+ case CMD_NOTESLIDEUP: return 128;
+ case CMD_PANNING8: return 120;
+ case CMD_PANNINGSLIDE: return 112;
+ case CMD_SMOOTHMIDI: return 104;
+ case CMD_MIDI: return 96;
+ case CMD_DELAYCUT: return 88;
+ case CMD_MODCMDEX: return 80;
+ case CMD_S3MCMDEX: return 72;
+ case CMD_PANBRELLO: return 64;
+ case CMD_XFINEPORTAUPDOWN: return 56;
+ case CMD_VIBRATO: return 48;
+ case CMD_FINEVIBRATO: return 40;
+ case CMD_TREMOLO: return 32;
+ case CMD_KEYOFF: return 24;
+ case CMD_SETENVPOSITION: return 16;
+ case CMD_XPARAM: return 8;
+ case CMD_NONE:
+ default: return 0;
+ }
+}
+
+
+/* Try to write an (volume column) effect in a given channel or any channel of a pattern in a specific row.
+ Usage: nPat - Pattern that should be modified
+ nRow - Row that should be modified
+ nEffect - (Volume) Effect that should be written
+ nParam - Effect that should be written
+ bIsVolumeEffect - Indicates whether the given effect is a volume column effect or not
+ nChn - Channel that should be modified - use CHANNELINDEX_INVALID to allow all channels of the given row
+ bAllowMultipleEffects - If false, No effect will be written if an effect of the same type is already present in the channel(s). Useful for f.e. tempo effects.
+ bAllowNextRow - Indicates whether it is allowed to use the next row if there's no space for the effect
+ bRetry - For internal use only. Indicates whether an effect "rewrite" has already taken place (for recursive calls)
+*/
+bool CSoundFile::TryWriteEffect(PATTERNINDEX nPat, ROWINDEX nRow, BYTE nEffect, BYTE nParam, bool bIsVolumeEffect, CHANNELINDEX nChn, bool bAllowMultipleEffects, bool bAllowNextRow, bool bRetry)
+//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+{
+ // NOTE: Effect remapping is only implemented for a few basic effects.
+ CHANNELINDEX nScanChnMin = nChn, nScanChnMax = nChn;
+ MODCOMMAND *p = Patterns[nPat], *m;
+
+ // Scan all channels
+ if(nChn == CHANNELINDEX_INVALID)
+ {
+ nScanChnMin = 0;
+ nScanChnMax = m_nChannels - 1;
+ }
+
+ // Scan channel(s) for same effect type - if an effect of the same type is already present, exit.
+ if(!bAllowMultipleEffects)
+ {
+ for(CHANNELINDEX i = nScanChnMin; i <= nScanChnMax; i++)
+ {
+ m = p + nRow * m_nChannels + i;
+ if(!bIsVolumeEffect && m->command == nEffect)
+ return true;
+ if(bIsVolumeEffect && m->volcmd == nEffect)
+ return true;
+ }
+ }
+
+ // Easy case: check if there's some space left to put the effect somewhere
+ for(CHANNELINDEX i = nScanChnMin; i <= nScanChnMax; i++)
+ {
+ m = p + nRow * m_nChannels + i;
+ if(!bIsVolumeEffect && m->command == CMD_NONE)
+ {
+ m->command = nEffect;
+ m->param = nParam;
+ return true;
+ }
+ if(bIsVolumeEffect && m->volcmd == VOLCMD_NONE)
+ {
+ m->volcmd = nEffect;
+ m->vol = nParam;
+ return true;
+ }
+ }
+
+ // Ok, apparently there's no space. If we haven't tried already, try to map it to the volume column or effect column instead.
+ if(bRetry)
+ {
+ // Move some effects that also work in the volume column, so there's place for our new effect.
+ if(!bIsVolumeEffect)
+ {
+ for(CHANNELINDEX i = nScanChnMin; i <= nScanChnMax; i++)
+ {
+ m = p + nRow * m_nChannels + i;
+ switch(m->command)
+ {
+ case CMD_VOLUME:
+ m->volcmd = VOLCMD_VOLUME;
+ m->vol = m->param;
+ m->command = nEffect;
+ m->param = nParam;
+ return true;
+
+ case CMD_PANNING8:
+ if(m_nType & MOD_TYPE_S3M && nParam > 0x80)
+ break;
+
+ m->volcmd = VOLCMD_PANNING;
+ m->command = nEffect;
+
+ if(m_nType & MOD_TYPE_S3M)
+ {
+ m->vol = m->param >> 1;
+ }
+ else
+ {
+ m->vol = (m->param >> 2) + 1;
+ }
+
+ m->param = nParam;
+ return true;
+ }
+ }
+ }
+
+ // Let's try it again by writing into the "other" effect column.
+ BYTE nNewEffect = CMD_NONE;
+ if(bIsVolumeEffect)
+ {
+ switch(nEffect)
+ {
+ case VOLCMD_PANNING:
+ nNewEffect = CMD_PANNING8;
+ if(m_nType & MOD_TYPE_S3M)
+ nParam <<= 1;
+ else
+ nParam = min(nParam << 2, 0xFF);
+ break;
+ case VOLCMD_VOLUME:
+ nNewEffect = CMD_VOLUME;
+ break;
+ }
+ } else
+ {
+ switch(nEffect)
+ {
+ case CMD_PANNING8:
+ nNewEffect = VOLCMD_PANNING;
+ if(m_nType & MOD_TYPE_S3M)
+ {
+ if(nParam <= 0x80)
+ nParam >>= 1;
+ else
+ nNewEffect = CMD_NONE;
+ }
+ else
+ {
+ nParam = (nParam >> 2) + 1;
+ }
+ break;
+ case CMD_VOLUME:
+ nNewEffect = CMD_VOLUME;
+ break;
+ }
+ }
+ if(nNewEffect != CMD_NONE)
+ {
+ if(TryWriteEffect(nPat, nRow, nNewEffect, nParam, !bIsVolumeEffect, nChn, bAllowMultipleEffects, bAllowNextRow, false) == true) return true;
+ }
+ }
+
+ // Try in the next row if possible (this may also happen if we already retried)
+ if(bAllowNextRow && (nRow + 1 < Patterns[nPat].GetNumRows()))
+ {
+ return TryWriteEffect(nPat, nRow + 1, nEffect, nParam, bIsVolumeEffect, nChn, bAllowMultipleEffects, bAllowNextRow, bRetry);
+ }
+
+ return false;
+}
+
+
+// Try to convert a fx column command (*e) into a volume column command.
+// Returns true if successful.
+// Some commands can only be converted by losing some precision.
+// If moving the command into the volume column is more important than accuracy, use bForce = true.
+// (Code translated from SchismTracker and mainly supposed to be used with loaders ported from this tracker)
+bool CSoundFile::ConvertVolEffect(uint8 *e, uint8 *p, bool bForce)
+//----------------------------------------------------------------
+{
+ switch (*e)
+ {
+ case CMD_NONE:
+ return true;
+ case CMD_VOLUME:
+ *e = VOLCMD_VOLUME;
+ *p = min(*p, 64);
+ break;
+ case CMD_PORTAMENTOUP:
+ if (bForce)
+ *p = min(*p, 9);
+ else if (*p > 9)
+ return false;
+ *e = VOLCMD_PORTAUP;
+ break;
+ case CMD_PORTAMENTODOWN:
+ if (bForce)
+ *p = min(*p, 9);
+ else if (*p > 9)
+ return false;
+ *e = VOLCMD_PORTADOWN;
+ break;
+ case CMD_TONEPORTAMENTO:
+ if (*p >= 0xF0)
+ {
+ // hack for people who can't type F twice :)
+ *e = VOLCMD_TONEPORTAMENTO;
+ *p = 0xFF;
+ return true;
+ }
+ for (uint8 n = 0; n < 10; n++)
+ {
+ if (bForce
+ ? (*p <= ImpulseTrackerPortaVolCmd[n])
+ : (*p == ImpulseTrackerPortaVolCmd[n]))
+ {
+ *e = VOLCMD_TONEPORTAMENTO;
+ *p = n;
+ return true;
+ }
+ }
+ return false;
+ case CMD_VIBRATO:
+ if (bForce)
+ *p = min(*p, 9);
+ else if (*p > 9)
+ return false;
+ *e = VOLCMD_VIBRATODEPTH;
+ break;
+ case CMD_FINEVIBRATO:
+ if (bForce)
+ *p = 0;
+ else if (*p)
+ return false;
+ *e = VOLCMD_VIBRATODEPTH;
+ break;
+ case CMD_PANNING8:
+ *p = min(64, *p * 64 / 255);
+ *e = VOLCMD_PANNING;
+ break;
+ case CMD_VOLUMESLIDE:
+ if (*p == 0)
+ return false;
+ if ((*p & 0xF) == 0) // Dx0 / Cx
+ {
+ if (bForce)
+ *p = min(*p >> 4, 9);
+ else if ((*p >> 4) > 9)
+ return false;
+ else
+ *p >>= 4;
+ *e = VOLCMD_VOLSLIDEUP;
+ } else if ((*p & 0xF0) == 0) // D0x / Dx
+ {
+ if (bForce)
+ *p = min(*p, 9);
+ else if (*p > 9)
+ return false;
+ *e = VOLCMD_VOLSLIDEDOWN;
+ } else if ((*p & 0xF) == 0xF) // DxF / Ax
+ {
+ if (bForce)
+ *p = min(*p >> 4, 9);
+ else if ((*p >> 4) > 9)
+ return false;
+ else
+ *p >>= 4;
+ *e = VOLCMD_FINEVOLUP;
+ } else if ((*p & 0xf0) == 0xf0) // DFx / Bx
+ {
+ if (bForce)
+ *p = min(*p, 9);
+ else if ((*p & 0xF) > 9)
+ return false;
+ else
+ *p &= 0xF;
+ *e = VOLCMD_FINEVOLDOWN;
+ } else // ???
+ {
+ return false;
+ }
+ break;
+ case CMD_S3MCMDEX:
+ switch (*p >> 4)
+ {
+ case 8:
+ *e = VOLCMD_PANNING;
+ *p = ((*p & 0xf) << 2) + 2;
+ return true;
+ case 0: case 1: case 2: case 0xF:
+ if (bForce)
+ {
+ *e = *p = 0;
+ return true;
+ }
+ break;
+ default:
+ break;
+ }
+ return false;
+ default:
+ return false;
+ }
+ return true;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-07-12 23:10:19
|
Revision: 642
http://modplug.svn.sourceforge.net/modplug/?rev=642&view=rev
Author: saga-games
Date: 2010-07-12 22:45:33 +0000 (Mon, 12 Jul 2010)
Log Message:
-----------
[Imp] Installer: Better separation between "normal" setup and "unmo3-free" setup (code-wise). There's no need to change files during setup compilation anymore, just compile install.iss with regular InnoSetup+ISPP for a "normal" setup and compile "install-unmo3-free.iss" with ISTool for an "unmo3-free" setup.
Modified Paths:
--------------
trunk/OpenMPT/installer/install.iss
Added Paths:
-----------
trunk/OpenMPT/installer/install-unmo3-free.iss
Added: trunk/OpenMPT/installer/install-unmo3-free.iss
===================================================================
--- trunk/OpenMPT/installer/install-unmo3-free.iss (rev 0)
+++ trunk/OpenMPT/installer/install-unmo3-free.iss 2010-07-12 22:45:33 UTC (rev 642)
@@ -0,0 +1,40 @@
+; OpenMPT Install script for InnoSetup
+; Written by Johannes Schultz
+; http://sagamusix.de/
+; http://sagagames.de/
+
+; This file is provided for creating an install package without the proprietary unmo3.dll (for example for the SourceForge package).
+; Instead of including the file in the setup package, the user instead has the possibility to automatically download unmo3.dll from
+; our servers.
+; The download code requires the ISTool IDE with its downloader extension. ISPP is also required.
+; To download and install ISPP and ISTool, get the Inno Setup QuickStart Pack from http://www.jrsoftware.org/isdl.php#qsp
+
+#define DOWNLOAD_MO3
+
+#include "install.iss"
+
+[Code]
+// Verify checksum of downloaded file, and if it is OK, copy it to the app directory.
+procedure VerifyUNMO3Checksum();
+begin
+ if(IsTaskSelected('downloadmo3') And FileExists(ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp'))) then
+ begin
+ if(GetSHA1OfFile(ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp')) <> '2e17f7bb6d19ce326851333b918070c5357cacd1') then
+ begin
+ MsgBox('Warning: unmo3.dll has been downloaded, but its checksum is wrong! This means that either the downloaded file is corrupted or that a newer version of unmo3.dll is available. The file has thus not been installed. Please obtain unmo3.dll from http://openmpt.com/ and verify its checksum.', mbCriticalError, MB_OK)
+ end else
+ begin
+ FileCopy(ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp'), ExpandConstant('{app}\unmo3.dll'), true);
+ end;
+ DeleteFile(ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp'));
+ end;
+end;
+
+// Function generated by ISTool.
+function NextButtonClick(CurPage: Integer): Boolean;
+begin
+ Result := istool_download(CurPage);
+end;
+
+[_ISToolDownload]
+Source: http://openmpt.com/download/unmo3.dll; DestDir: {tmp}; DestName: openmpt-unmo3.dll.tmp; Tasks: downloadmo3
Modified: trunk/OpenMPT/installer/install.iss
===================================================================
--- trunk/OpenMPT/installer/install.iss 2010-07-10 23:19:27 UTC (rev 641)
+++ trunk/OpenMPT/installer/install.iss 2010-07-12 22:45:33 UTC (rev 642)
@@ -5,11 +5,9 @@
; ISPP is needed for automated version retrieval.
; Furthermore, the ISTool IDE with its downloader extension is required for "unmo3-free" packages which don't contain unmo3.dll, but download it from a server.
+; Check install-unmo3-free.iss for details on this matter.
; To download and install ISPP and ISTool, get the Inno Setup QuickStart Pack from http://www.jrsoftware.org/isdl.php#qsp
-; Use this for sourceforge.net packages (ISTool required):
-;#define DOWNLOAD_MO3
-
#define GetAppVersion StringChange(GetFileProductVersion("..\mptrack\bin\mptrack.exe"), ",", ".")
#define GetAppVersionShort Copy(GetAppVersion, 1, 4)
@@ -129,6 +127,10 @@
[Code]
+#ifdef DOWNLOAD_MO3
+procedure VerifyUNMO3Checksum(); forward;
+#endif
+
// Copy old config files to the AppData directory, if there are any (and if the files don't exist already)
procedure CopyConfigsToAppDataDir();
var
@@ -185,18 +187,7 @@
begin
#ifdef DOWNLOAD_MO3
- // Verify checksum of downloaded file, and if it is OK, copy it to the app directory.
- if(IsTaskSelected('downloadmo3') And FileExists(ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp'))) then
- begin
- if(GetSHA1OfFile(ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp')) <> '2e17f7bb6d19ce326851333b918070c5357cacd1') then
- begin
- MsgBox('Warning: unmo3.dll has been downloaded, but its checksum is wrong! This means that either the downloaded file is corrupted or that a newer version of unmo3.dll is available. The file has thus not been installed. Please obtain unmo3.dll from http://openmpt.com/ and verify its checksum.', mbCriticalError, MB_OK)
- end else
- begin
- FileCopy(ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp'), ExpandConstant('{app}\unmo3.dll'), true);
- end;
- DeleteFile(ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp'));
- end;
+ VerifyUNMO3Checksum();
#endif
// Copy old config files from app's directory, if possible and necessary.
@@ -279,12 +270,4 @@
end;
end;
end;
-#ifdef DOWNLOAD_MO3
-// Function generated by ISTool.
-function NextButtonClick(CurPage: Integer): Boolean;
-begin
- Result := istool_download(CurPage);
-end;
-[_ISToolDownload]
-Source: http://openmpt.com/download/unmo3.dll; DestDir: {tmp}; DestName: openmpt-unmo3.dll.tmp; Tasks: downloadmo3
-#endif
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-07-10 23:19:33
|
Revision: 641
http://modplug.svn.sourceforge.net/modplug/?rev=641&view=rev
Author: saga-games
Date: 2010-07-10 23:19:27 +0000 (Sat, 10 Jul 2010)
Log Message:
-----------
[Imp] Installer: Added a compiler switch for offering a downloadable version of unmo3.dll (for sf.net) instead of including it in the binary - This needs ISTool from the Quick Start pack, see comments in install.iss for details.
Modified Paths:
--------------
trunk/OpenMPT/installer/install.iss
Modified: trunk/OpenMPT/installer/install.iss
===================================================================
--- trunk/OpenMPT/installer/install.iss 2010-07-10 18:30:08 UTC (rev 640)
+++ trunk/OpenMPT/installer/install.iss 2010-07-10 23:19:27 UTC (rev 641)
@@ -4,7 +4,12 @@
; http://sagagames.de/
; ISPP is needed for automated version retrieval.
-; To download and install ISPP, get the Inno Setup QuickStart Pack from http://www.jrsoftware.org/isdl.php#qsp
+; Furthermore, the ISTool IDE with its downloader extension is required for "unmo3-free" packages which don't contain unmo3.dll, but download it from a server.
+; To download and install ISPP and ISTool, get the Inno Setup QuickStart Pack from http://www.jrsoftware.org/isdl.php#qsp
+
+; Use this for sourceforge.net packages (ISTool required):
+;#define DOWNLOAD_MO3
+
#define GetAppVersion StringChange(GetFileProductVersion("..\mptrack\bin\mptrack.exe"), ",", ".")
#define GetAppVersionShort Copy(GetAppVersion, 1, 4)
@@ -33,15 +38,18 @@
[Tasks]
; icons and install mode
-Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}";
-Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
-Name: "portable"; Description: "Portable mode (use program folder for storing settings, no registry changes)"; GroupDescription: "Options:"; Flags: unchecked
-Name: "vst_scan"; Description: "Scan for previously installed VST plugins"; GroupDescription: "Options:"; Flags: unchecked
+Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}
+Name: quicklaunchicon; Description: {cm:CreateQuickLaunchIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked
+#ifdef DOWNLOAD_MO3
+Name: downloadmo3; Description: Download unmo3 (library needed for reading MO3 files, recommended); GroupDescription: Options:
+#endif
+Name: portable; Description: Portable mode (use program folder for storing settings, no registry changes); GroupDescription: Options:; Flags: unchecked
+Name: vst_scan; Description: Scan for previously installed VST plugins; GroupDescription: Options:; Flags: unchecked
; file associations - put this below all other [tasks]!
#include "filetypes.iss"
[Languages]
-Name: "english"; MessagesFile: "compiler:Default.isl"
+Name: english; MessagesFile: compiler:Default.isl
[Files]
; note: packageTemplate\ contains files specific for the "install package".
@@ -49,68 +57,73 @@
; preserve file type order for best solid compression results (first binary, then text)
; home folder
-Source: "..\mptrack\bin\mptrack.exe"; DestDir: "{app}"; Flags: ignoreversion
-Source: "..\mptrack\bin\OpenMPT_SoundTouch_i16.dll"; DestDir: "{app}"; Flags: ignoreversion
-Source: "..\mptrack\bin\unmo3.dll"; DestDir: "{app}"; Flags: ignoreversion
+Source: ..\mptrack\bin\mptrack.exe; DestDir: {app}; Flags: ignoreversion
+Source: ..\mptrack\bin\OpenMPT_SoundTouch_i16.dll; DestDir: {app}; Flags: ignoreversion
+#ifndef DOWNLOAD_MO3
+Source: ..\mptrack\bin\unmo3.dll; DestDir: {app}; Flags: ignoreversion
+#endif
-Source: "..\packageTemplate\ExampleSongs\*.*"; DestDir: "{app}\ExampleSongs\"; Flags: ignoreversion
+Source: ..\packageTemplate\ExampleSongs\*.*; DestDir: {app}\ExampleSongs\; Flags: ignoreversion sortfilesbyextension
-Source: "packageTemplate\readme.txt"; DestDir: "{app}"; Flags: ignoreversion
-Source: "..\packageTemplate\history.txt"; DestDir: "{app}"; Flags: ignoreversion
+Source: packageTemplate\readme.txt; DestDir: {app}; Flags: ignoreversion
+Source: ..\packageTemplate\history.txt; DestDir: {app}; Flags: ignoreversion
; release notes
-Source: "..\packageTemplate\ReleaseNotesImages\general\*.*"; DestDir: "{app}\ReleaseNotesImages\general\"; Flags: ignoreversion
-Source: "..\packageTemplate\ReleaseNotesImages\1.18\*.*"; DestDir: "{app}\ReleaseNotesImages\1.18\"; Flags: ignoreversion
-Source: "..\packageTemplate\OMPT_1.18_ReleaseNotes.html"; DestDir: "{app}"; Flags: ignoreversion
+Source: ..\packageTemplate\ReleaseNotesImages\general\*.*; DestDir: {app}\ReleaseNotesImages\general\; Flags: ignoreversion sortfilesbyextension
+Source: ..\packageTemplate\ReleaseNotesImages\1.18\*.*; DestDir: {app}\ReleaseNotesImages\1.18\; Flags: ignoreversion sortfilesbyextension
+Source: ..\packageTemplate\OMPT_1.18_ReleaseNotes.html; DestDir: {app}; Flags: ignoreversion
; soundtouch license stuff
-Source: "..\packageTemplate\SoundTouch\*.*"; DestDir: "{app}\SoundTouch"; Flags: ignoreversion
+Source: ..\packageTemplate\SoundTouch\*.*; DestDir: {app}\SoundTouch; Flags: ignoreversion sortfilesbyextension
; keymaps
-Source: "..\packageTemplate\extraKeymaps\*.*"; DestDir: "{app}\extraKeymaps"; Flags: ignoreversion
+Source: ..\packageTemplate\extraKeymaps\*.*; DestDir: {app}\extraKeymaps; Flags: ignoreversion sortfilesbyextension
; kind of auto-backup - handy!
-Source: "{userappdata}\OpenMPT\mptrack.ini"; DestDir: "{userappdata}\OpenMPT"; DestName: "mptrack.ini.old"; Flags: external skipifsourcedoesntexist; Tasks: not portable
-Source: "{userappdata}\OpenMPT\plugin.cache"; DestDir: "{userappdata}\OpenMPT"; DestName: "plugin.cache.old"; Flags: external skipifsourcedoesntexist; Tasks: not portable
+Source: {userappdata}\OpenMPT\mptrack.ini; DestDir: {userappdata}\OpenMPT; DestName: mptrack.ini.old; Flags: external skipifsourcedoesntexist; Tasks: not portable
+Source: {userappdata}\OpenMPT\plugin.cache; DestDir: {userappdata}\OpenMPT; DestName: plugin.cache.old; Flags: external skipifsourcedoesntexist; Tasks: not portable
[Dirs]
; option dirs for non-portable mode
-Name: "{userappdata}\OpenMPT"; Tasks: not portable
-Name: "{userappdata}\OpenMPT\tunings"; Tasks: not portable
+Name: {userappdata}\OpenMPT; Tasks: not portable
+Name: {userappdata}\OpenMPT\tunings; Tasks: not portable
; dirst for portable mode
-Name: "{app}\tunings"; Tasks: portable
+Name: {app}\tunings; Tasks: portable
[Icons]
; start menu
-Name: "{group}\{cm:LaunchProgram,OpenMPT}"; Filename: "{app}\mptrack.exe"
-Name: "{group}\{cm:UninstallProgram,OpenMPT}"; Filename: "{uninstallexe}"
-Name: "{group}\ModPlug Central"; Filename: "{app}\ModPlug Central.url"
-Name: "{group}\Configuration files"; Filename: "{userappdata}\OpenMPT\"; Tasks: not portable
+Name: {group}\{cm:LaunchProgram,OpenMPT}; Filename: {app}\mptrack.exe
+Name: {group}\{cm:UninstallProgram,OpenMPT}; Filename: {uninstallexe}
+Name: {group}\ModPlug Central; Filename: {app}\ModPlug Central.url
+Name: {group}\Configuration files; Filename: {userappdata}\OpenMPT\; Tasks: not portable
; app's directory (for ease of use)
-Name: "{app}\Configuration files"; Filename: "{userappdata}\OpenMPT\"; Tasks: not portable
+Name: {app}\Configuration files; Filename: {userappdata}\OpenMPT\; Tasks: not portable
; desktop, quick launch
-Name: "{userdesktop}\OpenMPT"; Filename: "{app}\mptrack.exe"; Tasks: desktopicon
-Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\OpenMPT"; Filename: "{app}\mptrack.exe"; Tasks: quicklaunchicon
+Name: {userdesktop}\OpenMPT; Filename: {app}\mptrack.exe; Tasks: desktopicon
+Name: {userappdata}\Microsoft\Internet Explorer\Quick Launch\OpenMPT; Filename: {app}\mptrack.exe; Tasks: quicklaunchicon
[INI]
; enable portable mode
-Filename: "{app}\mptrack.ini"; Section: "Paths"; Key: "UseAppDataDirectory"; String: "0"; Flags: createkeyifdoesntexist; Tasks: portable
+Filename: {app}\mptrack.ini; Section: Paths; Key: UseAppDataDirectory; String: 0; Flags: createkeyifdoesntexist; Tasks: portable
; internet shortcut
-Filename: "{app}\ModPlug Central.url"; Section: "InternetShortcut"; Key: "URL"; String: "http://openmpt.com/forum/"; Flags: createkeyifdoesntexist;
+Filename: {app}\ModPlug Central.url; Section: InternetShortcut; Key: URL; String: http://openmpt.com/forum/; Flags: createkeyifdoesntexist
[Run]
; duh
-Filename: "{app}\mptrack.exe"; Parameters: """{app}\ExampleSongs\xaimus - digital sentience.it"""; Description: "{cm:LaunchProgram,OpenMPT}"; Flags: nowait postinstall skipifsilent
+Filename: {app}\mptrack.exe; Parameters: """{app}\ExampleSongs\xaimus - digital sentience.it"""; Description: {cm:LaunchProgram,OpenMPT}; Flags: nowait postinstall skipifsilent
[UninstallDelete]
; internet shortcut has to be deleted manually
-Type: files; Name: "{app}\ModPlug Central.url";
+Type: files; Name: {app}\ModPlug Central.url
; normal installation
-Type: dirifempty; Name: "{userappdata}\OpenMPT\tunings"; Tasks: not portable
-Type: dirifempty; Name: "{userappdata}\OpenMPT"; Tasks: not portable
+Type: dirifempty; Name: {userappdata}\OpenMPT\tunings; Tasks: not portable
+Type: dirifempty; Name: {userappdata}\OpenMPT; Tasks: not portable
; portable installation
-Type: dirifempty; Name: "{app}\tunings"; Tasks: portable;
+Type: dirifempty; Name: {app}\tunings; Tasks: portable
+#ifdef DOWNLOAD_MO3
+Type: files; Name: {app}\unmo3.dll; Tasks: downloadmo3
+#endif
#include "vst_scan.iss"
@@ -170,6 +183,22 @@
case CurStep of
ssPostInstall:
begin
+
+#ifdef DOWNLOAD_MO3
+ // Verify checksum of downloaded file, and if it is OK, copy it to the app directory.
+ if(IsTaskSelected('downloadmo3') And FileExists(ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp'))) then
+ begin
+ if(GetSHA1OfFile(ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp')) <> '2e17f7bb6d19ce326851333b918070c5357cacd1') then
+ begin
+ MsgBox('Warning: unmo3.dll has been downloaded, but its checksum is wrong! This means that either the downloaded file is corrupted or that a newer version of unmo3.dll is available. The file has thus not been installed. Please obtain unmo3.dll from http://openmpt.com/ and verify its checksum.', mbCriticalError, MB_OK)
+ end else
+ begin
+ FileCopy(ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp'), ExpandConstant('{app}\unmo3.dll'), true);
+ end;
+ DeleteFile(ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp'));
+ end;
+#endif
+
// Copy old config files from app's directory, if possible and necessary.
CopyConfigsToAppDataDir();
@@ -250,3 +279,12 @@
end;
end;
end;
+#ifdef DOWNLOAD_MO3
+// Function generated by ISTool.
+function NextButtonClick(CurPage: Integer): Boolean;
+begin
+ Result := istool_download(CurPage);
+end;
+[_ISToolDownload]
+Source: http://openmpt.com/download/unmo3.dll; DestDir: {tmp}; DestName: openmpt-unmo3.dll.tmp; Tasks: downloadmo3
+#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-07-10 18:30:16
|
Revision: 640
http://modplug.svn.sourceforge.net/modplug/?rev=640&view=rev
Author: saga-games
Date: 2010-07-10 18:30:08 +0000 (Sat, 10 Jul 2010)
Log Message:
-----------
[Ref] Added more const modifiers to the loader functions.
Modified Paths:
--------------
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_669.cpp
trunk/OpenMPT/soundlib/Load_ams.cpp
trunk/OpenMPT/soundlib/Load_far.cpp
trunk/OpenMPT/soundlib/Load_imf.cpp
trunk/OpenMPT/soundlib/Load_it.cpp
trunk/OpenMPT/soundlib/Load_mdl.cpp
trunk/OpenMPT/soundlib/Load_med.cpp
trunk/OpenMPT/soundlib/Load_ptm.cpp
trunk/OpenMPT/soundlib/Load_s3m.cpp
trunk/OpenMPT/soundlib/Load_stm.cpp
trunk/OpenMPT/soundlib/Load_ult.cpp
trunk/OpenMPT/soundlib/Load_umx.cpp
trunk/OpenMPT/soundlib/Load_wav.cpp
trunk/OpenMPT/soundlib/Load_xm.cpp
trunk/OpenMPT/soundlib/Sndfile.h
Modified: trunk/OpenMPT/soundlib/LOAD_AMF.CPP
===================================================================
--- trunk/OpenMPT/soundlib/LOAD_AMF.CPP 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/LOAD_AMF.CPP 2010-07-10 18:30:08 UTC (rev 640)
@@ -171,8 +171,8 @@
-bool CSoundFile::ReadAMF(LPCBYTE lpStream, const DWORD dwMemLength)
-//-----------------------------------------------------------
+bool CSoundFile::ReadAMF(const LPCBYTE lpStream, const DWORD dwMemLength)
+//-----------------------------------------------------------------------
{
const AMFFILEHEADER *pfh = (AMFFILEHEADER *)lpStream;
DWORD dwMemPos;
Modified: trunk/OpenMPT/soundlib/LOAD_DBM.CPP
===================================================================
--- trunk/OpenMPT/soundlib/LOAD_DBM.CPP 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/LOAD_DBM.CPP 2010-07-10 18:30:08 UTC (rev 640)
@@ -107,7 +107,7 @@
void ConvertDBMEffect(uint8 *command, uint8 *param)
-//----------------------------------
+//-------------------------------------------------
{
if(*command < ARRAYELEMCOUNT(dbm_efftrans))
*command = dbm_efftrans[*command];
@@ -176,8 +176,8 @@
}
-bool CSoundFile::ReadDBM(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+bool CSoundFile::ReadDBM(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
{
const DBMFILEHEADER *pfh = (DBMFILEHEADER *)lpStream;
DWORD dwMemPos;
Modified: trunk/OpenMPT/soundlib/LOAD_DMF.CPP
===================================================================
--- trunk/OpenMPT/soundlib/LOAD_DMF.CPP 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/LOAD_DMF.CPP 2010-07-10 18:30:08 UTC (rev 640)
@@ -86,8 +86,8 @@
#endif
-bool CSoundFile::ReadDMF(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+bool CSoundFile::ReadDMF(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
{
const DMFHEADER *pfh = (DMFHEADER *)lpStream;
DMFINFO *psi;
Modified: trunk/OpenMPT/soundlib/LOAD_DSM.CPP
===================================================================
--- trunk/OpenMPT/soundlib/LOAD_DSM.CPP 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/LOAD_DSM.CPP 2010-07-10 18:30:08 UTC (rev 640)
@@ -85,8 +85,8 @@
#pragma pack()
-bool CSoundFile::ReadDSM(LPCBYTE lpStream, DWORD dwMemLength)
-//-----------------------------------------------------------
+bool CSoundFile::ReadDSM(const LPCBYTE lpStream, const DWORD dwMemLength)
+//-----------------------------------------------------------------------
{
DSMFILEHEADER *pfh = (DSMFILEHEADER *)lpStream;
DSMSONG *psong;
Modified: trunk/OpenMPT/soundlib/Load_669.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_669.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_669.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -39,8 +39,8 @@
} SAMPLE669;
-bool CSoundFile::Read669(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+bool CSoundFile::Read669(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
{
BOOL b669Ext;
const FILEHEADER669 *pfh = (const FILEHEADER669 *)lpStream;
Modified: trunk/OpenMPT/soundlib/Load_ams.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_ams.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_ams.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -45,8 +45,8 @@
-bool CSoundFile::ReadAMS(LPCBYTE lpStream, DWORD dwMemLength)
-//-----------------------------------------------------------
+bool CSoundFile::ReadAMS(const LPCBYTE lpStream, const DWORD dwMemLength)
+//-----------------------------------------------------------------------
{
BYTE pkinf[MAX_SAMPLES];
AMSFILEHEADER *pfh = (AMSFILEHEADER *)lpStream;
Modified: trunk/OpenMPT/soundlib/Load_far.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_far.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_far.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -58,8 +58,8 @@
#pragma pack()
-bool CSoundFile::ReadFAR(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+bool CSoundFile::ReadFAR(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
{
if(dwMemLength < sizeof(FARHEADER1))
return false;
Modified: trunk/OpenMPT/soundlib/Load_imf.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_imf.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_imf.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -239,11 +239,11 @@
}
}
-static void load_imf_envelope(INSTRUMENTENVELOPE *env, IMFINSTRUMENT *imfins, int e)
-//----------------------------------------------------------------------------------
+static void load_imf_envelope(INSTRUMENTENVELOPE *env, const IMFINSTRUMENT *imfins, const int e)
+//----------------------------------------------------------------------------------------------
{
UINT min = 0; // minimum tick value for next node
- int shift = (e == IMF_ENV_VOL) ? 0 : 2;
+ const int shift = (e == IMF_ENV_VOL) ? 0 : 2;
env->dwFlags = ((imfins->env[e].flags & 1) ? ENV_ENABLED : 0) | ((imfins->env[e].flags & 2) ? ENV_SUSTAIN : 0) | ((imfins->env[e].flags & 4) ? ENV_LOOP : 0);
env->nNodes = CLAMP(imfins->env[e].points, 2, 25);
Modified: trunk/OpenMPT/soundlib/Load_it.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_it.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_it.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -287,7 +287,7 @@
//BOOL CSoundFile::ITInstrToMPT(const void *p, MODINSTRUMENT *pIns, UINT trkvers)
long CSoundFile::ITInstrToMPT(const void *p, MODINSTRUMENT *pIns, UINT trkvers) //rewbs.modularInstData
-//--------------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
{
// Envelope point count. Limited to 25 in IT format.
const int iEnvMax = (m_nType & MOD_TYPE_MPT) ? MAX_ENVPOINTS : 25;
@@ -457,7 +457,7 @@
// -> CODE#0023
// -> DESC="IT project files (.itp)"
bool CSoundFile::ReadITProject(LPCBYTE lpStream, const DWORD dwMemLength)
-//-----------------------------------------------------------------
+//-----------------------------------------------------------------------
{
UINT i,n,nsmp;
DWORD id,len,size;
Modified: trunk/OpenMPT/soundlib/Load_mdl.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mdl.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_mdl.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -226,8 +226,8 @@
-bool CSoundFile::ReadMDL(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+bool CSoundFile::ReadMDL(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
{
DWORD dwMemPos, dwPos, blocklen, dwTrackPos;
const MDLSONGHEADER *pmsh = (const MDLSONGHEADER *)lpStream;
Modified: trunk/OpenMPT/soundlib/Load_med.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_med.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_med.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -474,8 +474,8 @@
}
-bool CSoundFile::ReadMed(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+bool CSoundFile::ReadMed(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
{
const MEDMODULEHEADER *pmmh;
const MMD0SONGHEADER *pmsh;
Modified: trunk/OpenMPT/soundlib/Load_ptm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_ptm.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_ptm.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -62,8 +62,8 @@
#pragma pack()
-bool CSoundFile::ReadPTM(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+bool CSoundFile::ReadPTM(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
{
if(lpStream == nullptr || dwMemLength < sizeof(PTMFILEHEADER))
return false;
Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_s3m.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_s3m.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -217,8 +217,8 @@
}
-bool CSoundFile::ReadS3M(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+bool CSoundFile::ReadS3M(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
{
if ((!lpStream) || (dwMemLength <= sizeof(S3MFILEHEADER) + 64)) return false;
Modified: trunk/OpenMPT/soundlib/Load_stm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_stm.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_stm.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -59,8 +59,8 @@
-bool CSoundFile::ReadSTM(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+bool CSoundFile::ReadSTM(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
{
STMHEADER *phdr = (STMHEADER *)lpStream;
DWORD dwMemPos = 0;
Modified: trunk/OpenMPT/soundlib/Load_ult.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_ult.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_ult.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -303,8 +303,8 @@
};
-bool CSoundFile::ReadUlt(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+bool CSoundFile::ReadUlt(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
{
DWORD dwMemPos = 0;
uint8 ult_version;
Modified: trunk/OpenMPT/soundlib/Load_umx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_umx.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_umx.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -12,8 +12,8 @@
#define MODMAGIC_OFFSET (20+31*30+130)
-bool CSoundFile::ReadUMX(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+bool CSoundFile::ReadUMX(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
{
if ((!lpStream) || (dwMemLength < 0x800)) return false;
// Rip Mods from UMX
Modified: trunk/OpenMPT/soundlib/Load_wav.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_wav.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_wav.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -17,8 +17,8 @@
/////////////////////////////////////////////////////////////
// WAV file support
-bool CSoundFile::ReadWav(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+bool CSoundFile::ReadWav(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
{
DWORD dwMemPos = 0;
WAVEFILEHEADER *phdr = (WAVEFILEHEADER *)lpStream;
Modified: trunk/OpenMPT/soundlib/Load_xm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_xm.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_xm.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -235,8 +235,8 @@
return dwMemPos;
}
-bool CSoundFile::ReadXM(const BYTE *lpStream, DWORD dwMemLength)
-//--------------------------------------------------------------
+bool CSoundFile::ReadXM(const BYTE *lpStream, const DWORD dwMemLength)
+//--------------------------------------------------------------------
{
XMFILEHEADER xmheader;
XMSAMPLEHEADER xmsh;
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2010-07-10 18:30:08 UTC (rev 640)
@@ -660,7 +660,7 @@
void SetRepeatCount(int n) { m_nRepeatCount = n; }
int GetRepeatCount() const { return m_nRepeatCount; }
- BOOL IsPaused() const { return (m_dwSongFlags & SONG_PAUSED) ? TRUE : FALSE; }
+ bool IsPaused() const { return (m_dwSongFlags & SONG_PAUSED) ? true : false; }
void LoopPattern(PATTERNINDEX nPat, ROWINDEX nRow = 0);
void CheckCPUUsage(UINT nCPU);
BOOL SetPatternName(PATTERNINDEX nPat, LPCSTR lpszName);
@@ -672,38 +672,38 @@
void ResetChannelState(CHANNELINDEX chn, BYTE resetStyle);
// Module Loaders
- bool ReadXM(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadS3M(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadMod(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadMed(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadMTM(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadSTM(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadIT(LPCBYTE lpStream, const DWORD dwMemLength);
- //bool ReadMPT(LPCBYTE lpStream, const DWORD dwMemLength);
- bool ReadITProject(LPCBYTE lpStream, const DWORD dwMemLength); // -> CODE#0023 -> DESC="IT project files (.itp)" -! NEW_FEATURE#0023
- bool Read669(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadUlt(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadWav(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadDSM(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadFAR(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadAMS(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadAMS2(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadMDL(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadOKT(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadDMF(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadPTM(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadDBM(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadAMF(LPCBYTE lpStream, const DWORD dwMemLength);
- bool ReadMT2(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadPSM(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadPSM16(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadUMX(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadMO3(LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadXM(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadS3M(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadMod(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadMed(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadMTM(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadSTM(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadIT(const LPCBYTE lpStream, const DWORD dwMemLength);
+ //bool ReadMPT(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadITProject(const LPCBYTE lpStream, const DWORD dwMemLength); // -> CODE#0023 -> DESC="IT project files (.itp)" -! NEW_FEATURE#0023
+ bool Read669(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadUlt(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadWav(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadDSM(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadFAR(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadAMS(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadAMS2(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadMDL(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadOKT(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadDMF(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadPTM(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadDBM(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadAMF(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadMT2(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadPSM(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadPSM16(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadUMX(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadMO3(const LPCBYTE lpStream, const DWORD dwMemLength);
bool ReadGDM(const LPCBYTE lpStream, const DWORD dwMemLength);
bool ReadIMF(const LPCBYTE lpStream, const DWORD dwMemLength);
bool ReadAM(const LPCBYTE lpStream, const DWORD dwMemLength);
bool ReadJ2B(const LPCBYTE lpStream, const DWORD dwMemLength);
- bool ReadMID(LPCBYTE lpStream, DWORD dwMemLength);
+ bool ReadMID(const LPCBYTE lpStream, DWORD dwMemLength);
// Save Functions
#ifndef MODPLUG_NO_FILESAVE
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-07-10 17:35:53
|
Revision: 639
http://modplug.svn.sourceforge.net/modplug/?rev=639&view=rev
Author: saga-games
Date: 2010-07-10 17:35:43 +0000 (Sat, 10 Jul 2010)
Log Message:
-----------
[Fix] OKT Loader: Files were not converted to IT, although this should be done with the new loader.
[Fix] MTM Loader: The "beats per track" (means lines per pattern) setting is now taken into account.
[Mod] OpenMPT: Version is now 1.18.02.03
[Ref] More documentation in Sndfile.h!
[Ref] Adding some const to that ungzip loader.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/Moddoc.cpp
trunk/OpenMPT/mptrack/version.h
trunk/OpenMPT/soundlib/Load_mtm.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/ungzip/ungzip.cpp
trunk/OpenMPT/ungzip/ungzip.h
Modified: trunk/OpenMPT/mptrack/Moddoc.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Moddoc.cpp 2010-07-10 13:37:44 UTC (rev 638)
+++ trunk/OpenMPT/mptrack/Moddoc.cpp 2010-07-10 17:35:43 UTC (rev 639)
@@ -347,7 +347,6 @@
m_SndFile.ChangeModTypeTo(MOD_TYPE_MOD);
break;
case MOD_TYPE_MED:
- case MOD_TYPE_OKT:
case MOD_TYPE_AMS:
m_SndFile.ChangeModTypeTo(MOD_TYPE_XM);
if ((m_SndFile.m_nDefaultTempo == 125) && (m_SndFile.m_nDefaultSpeed == 6) && (!m_SndFile.m_nInstruments))
@@ -358,9 +357,6 @@
m_SndFile.m_nType = MOD_TYPE_XM;
}
break;
- case MOD_TYPE_MT2:
- m_SndFile.ChangeModTypeTo(MOD_TYPE_IT);
- break;
case MOD_TYPE_FAR:
case MOD_TYPE_PTM:
case MOD_TYPE_STM:
@@ -370,6 +366,8 @@
break;
case MOD_TYPE_PSM:
case MOD_TYPE_ULT:
+ case MOD_TYPE_OKT:
+ case MOD_TYPE_MT2:
default:
m_SndFile.ChangeModTypeTo(MOD_TYPE_IT);
}
Modified: trunk/OpenMPT/mptrack/version.h
===================================================================
--- trunk/OpenMPT/mptrack/version.h 2010-07-10 13:37:44 UTC (rev 638)
+++ trunk/OpenMPT/mptrack/version.h 2010-07-10 17:35:43 UTC (rev 639)
@@ -15,7 +15,7 @@
#define VER_MAJORMAJOR 1
#define VER_MAJOR 18
#define VER_MINOR 02
-#define VER_MINORMINOR 02
+#define VER_MINORMINOR 03
//Creates version number from version parts that appears in version string.
//For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of
Modified: trunk/OpenMPT/soundlib/Load_mtm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mtm.cpp 2010-07-10 13:37:44 UTC (rev 638)
+++ trunk/OpenMPT/soundlib/Load_mtm.cpp 2010-07-10 17:35:43 UTC (rev 639)
@@ -4,14 +4,13 @@
* Copied to OpenMPT from libmodplug.
*
* Authors: Olivier Lapicque <oli...@jp...>
- *
+ * OpenMPT Devs
+ *
*/
#include "stdafx.h"
#include "sndfile.h"
-#pragma warning(disable:4244) //"conversion from 'type1' to 'type2', possible loss of data"
-
//////////////////////////////////////////////////////////
// MTM file support (import only)
@@ -19,29 +18,30 @@
typedef struct tagMTMSAMPLE
{
- char samplename[22];
- DWORD length;
- DWORD reppos;
- DWORD repend;
- CHAR finetune;
- BYTE volume;
- BYTE attribute;
+ char samplename[22];
+ uint32 length;
+ uint32 reppos;
+ uint32 repend;
+ int8 finetune;
+ uint8 volume;
+ uint8 attribute;
} MTMSAMPLE;
typedef struct tagMTMHEADER
{
- char id[4]; // MTM file marker + version
- char songname[20]; // ASCIIZ songname
- WORD numtracks; // number of tracks saved
- BYTE lastpattern; // last pattern number saved
- BYTE lastorder; // last order number to play (songlength-1)
- WORD commentsize; // length of comment field
- BYTE numsamples; // number of samples saved
- BYTE attribute; // attribute byte (unused)
- BYTE beatspertrack;
- BYTE numchannels; // number of channels used
- BYTE panpos[32]; // voice pan positions
+ char id[3]; // MTM file marker
+ uint8 version; // Tracker version
+ char songname[20]; // ASCIIZ songname
+ uint16 numtracks; // number of tracks saved
+ uint8 lastpattern; // last pattern number saved
+ uint8 lastorder; // last order number to play (songlength-1)
+ uint16 commentsize; // length of comment field
+ uint8 numsamples; // number of samples saved
+ uint8 attribute; // attribute byte (unused)
+ uint8 beatspertrack; // numbers of rows in every pattern
+ uint8 numchannels; // number of channels used
+ uint8 panpos[32]; // channel pan positions
} MTMHEADER;
@@ -51,11 +51,12 @@
bool CSoundFile::ReadMTM(LPCBYTE lpStream, DWORD dwMemLength)
//-----------------------------------------------------------
{
- MTMHEADER *pmh = (MTMHEADER *)lpStream;
DWORD dwMemPos = 66;
if ((!lpStream) || (dwMemLength < 0x100)) return false;
- if ((strncmp(pmh->id, "MTM", 3)) || (pmh->numchannels > 32)
+
+ MTMHEADER *pmh = (MTMHEADER *)lpStream;
+ if ((memcmp(pmh->id, "MTM", 3)) || (pmh->numchannels > 32)
|| (pmh->numsamples >= MAX_SAMPLES) || (!pmh->numsamples)
|| (!pmh->numtracks) || (!pmh->numchannels)
|| (!pmh->lastpattern) || (pmh->lastpattern > MAX_PATTERNS)) return false;
@@ -75,8 +76,8 @@
SpaceToNullStringFixed(m_szNames[i], 22);
Samples[i].nVolume = pms->volume << 2;
Samples[i].nGlobalVol = 64;
- DWORD len = pms->length;
- if ((len > 4) && (len <= MAX_SAMPLE_LENGTH))
+ UINT len = pms->length;
+ if ((len > 2) && (len <= MAX_SAMPLE_LENGTH))
{
Samples[i].nLength = len;
Samples[i].nLoopStart = pms->reppos;
@@ -97,31 +98,32 @@
dwMemPos += 37;
}
// Setting Channel Pan Position
- for (UINT ich=0; ich<m_nChannels; ich++)
+ for (CHANNELINDEX ich = 0; ich < m_nChannels; ich++)
{
ChnSettings[ich].nPan = ((pmh->panpos[ich] & 0x0F) << 4) + 8;
ChnSettings[ich].nVolume = 64;
}
// Reading pattern order
- Order.ReadAsByte(lpStream+dwMemPos, pmh->lastorder+1, dwMemLength-dwMemPos);
+ Order.ReadAsByte(lpStream + dwMemPos, pmh->lastorder + 1, dwMemLength - dwMemPos);
dwMemPos += 128;
// Reading Patterns
+ ROWINDEX nPatRows = CLAMP(pmh->beatspertrack, 1, MAX_PATTERN_ROWS);
LPCBYTE pTracks = lpStream + dwMemPos;
dwMemPos += 192 * pmh->numtracks;
LPWORD pSeq = (LPWORD)(lpStream + dwMemPos);
- for (UINT pat=0; pat<=pmh->lastpattern; pat++)
+ for (PATTERNINDEX pat = 0; pat <= pmh->lastpattern; pat++)
{
- if(Patterns.Insert(pat, 64)) break;
+ if(Patterns.Insert(pat, nPatRows)) break;
for (UINT n=0; n<32; n++) if ((pSeq[n]) && (pSeq[n] <= pmh->numtracks) && (n < m_nChannels))
{
LPCBYTE p = pTracks + 192 * (pSeq[n]-1);
MODCOMMAND *m = Patterns[pat] + n;
- for (UINT i=0; i<64; i++, m+=m_nChannels, p+=3)
+ for (UINT i = 0; i < nPatRows; i++, m += m_nChannels, p += 3)
{
if (p[0] & 0xFC) m->note = (p[0] >> 2) + 37;
m->instr = ((p[0] & 0x03) << 4) | (p[1] >> 4);
- UINT cmd = p[1] & 0x0F;
- UINT param = p[2];
+ uint8 cmd = p[1] & 0x0F;
+ uint8 param = p[2];
if (cmd == 0x0A)
{
if (param & 0xF0) param &= 0xF0; else param &= 0x0F;
@@ -133,7 +135,7 @@
}
pSeq += 32;
}
- dwMemPos += 64*(pmh->lastpattern+1);
+ dwMemPos += 64 * (pmh->lastpattern + 1);
if ((pmh->commentsize) && (dwMemPos + pmh->commentsize < dwMemLength))
{
UINT n = pmh->commentsize;
@@ -146,7 +148,7 @@
{
if (!m_lpszSongComments[i])
{
- m_lpszSongComments[i] = ((i+1) % 40) ? 0x20 : 0x0D;
+ m_lpszSongComments[i] = ((i + 1) % 40) ? 0x20 : 0x0D;
}
}
}
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2010-07-10 13:37:44 UTC (rev 638)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2010-07-10 17:35:43 UTC (rev 639)
@@ -1437,7 +1437,7 @@
{
if ((!m_nSamples) || (!m_nChannels)) return MOD_TYPE_NONE;
if (!m_nType) return MOD_TYPE_NONE;
- if (m_nType & (MOD_TYPE_MOD|MOD_TYPE_OKT))
+ if (m_nType & (MOD_TYPE_MOD/*|MOD_TYPE_OKT*/))
return MOD_TYPE_MOD;
if (m_nType & (MOD_TYPE_S3M|MOD_TYPE_STM|MOD_TYPE_ULT|MOD_TYPE_FAR|MOD_TYPE_PTM))
return MOD_TYPE_S3M;
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2010-07-10 13:37:44 UTC (rev 638)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2010-07-10 17:35:43 UTC (rev 639)
@@ -26,22 +26,21 @@
// Sample Struct
struct MODSAMPLE
{
- UINT nLength,nLoopStart,nLoopEnd;
- //nLength <-> Number of 'frames'?
- UINT nSustainStart, nSustainEnd;
- LPSTR pSample;
- UINT nC5Speed;
- WORD nPan;
- WORD nVolume;
- WORD nGlobalVol;
- WORD uFlags;
- signed char RelativeTone;
- signed char nFineTune;
- BYTE nVibType;
- BYTE nVibSweep;
- BYTE nVibDepth;
- BYTE nVibRate;
- CHAR name[32];
+ UINT nLength, nLoopStart, nLoopEnd; // In samples, not bytes
+ UINT nSustainStart, nSustainEnd; // Dito
+ LPSTR pSample; // Pointer to sample data
+ UINT nC5Speed; // Frequency of middle c, in Hz (for IT/S3M/MPTM)
+ WORD nPan; // Default sample panning (if pan flag is set)
+ WORD nVolume; // Default volume
+ WORD nGlobalVol; // Global volume (sample volume is multiplied by this)
+ WORD uFlags; // Sample flags
+ signed char RelativeTone; // Relative note to middle c (for MOD/XM)
+ signed char nFineTune; // Finetune period (for MOD/XM)
+ BYTE nVibType; // Auto vibrato type
+ BYTE nVibSweep; // Auto vibrato sweep (i.e. how long it takes until the vibrato effect reaches its full strength)
+ BYTE nVibDepth; // Auto vibrato depth
+ BYTE nVibRate; // Auto vibrato rate (speed)
+ //CHAR name[32]; // Maybe it would be nicer to have sample names here, but that would require some refactoring. Also, would this slow down the mixer (cache misses)?
CHAR filename[MAX_SAMPLEFILENAME];
// Return the size of one (elementary) sample in bytes.
@@ -90,53 +89,53 @@
// Instrument Struct
struct MODINSTRUMENT
{
- UINT nFadeOut;
- DWORD dwFlags;
- UINT nGlobalVol;
- UINT nPan;
+ UINT nFadeOut; // Instrument fadeout speed
+ DWORD dwFlags; // Instrument flags
+ UINT nGlobalVol; // Global volume (all sample volumes are multiplied with this)
+ UINT nPan; // Default pan (overrides sample panning), if the appropriate flag is set
- INSTRUMENTENVELOPE VolEnv;
- INSTRUMENTENVELOPE PanEnv;
- INSTRUMENTENVELOPE PitchEnv;
+ INSTRUMENTENVELOPE VolEnv; // Volume envelope data
+ INSTRUMENTENVELOPE PanEnv; // Panning envelope data
+ INSTRUMENTENVELOPE PitchEnv; // Pitch / filter envelope data
BYTE NoteMap[128]; // Note mapping, f.e. C-5 => D-5
WORD Keyboard[128]; // Sample mapping, f.e. C-5 => Sample 1
- BYTE nNNA;
- BYTE nDCT;
- BYTE nDNA;
- BYTE nPanSwing;
- BYTE nVolSwing;
- BYTE nIFC;
- BYTE nIFR;
+ BYTE nNNA; // New note action
+ BYTE nDCT; // Duplicate check type (i.e. which condition will trigger the duplicate note action)
+ BYTE nDNA; // Duplicate note action
+ BYTE nPanSwing; // Random panning factor
+ BYTE nVolSwing; // Random volume factor
+ BYTE nIFC; // Default filter cutoff
+ BYTE nIFR; // Default filter resonance
- WORD wMidiBank;
- BYTE nMidiProgram;
- BYTE nMidiChannel;
- BYTE nMidiDrumKey;
- signed char nPPS; //Pitch to Pan Separator?
- unsigned char nPPC; //Pitch Centre?
+ WORD wMidiBank; // MIDI bank
+ BYTE nMidiProgram; // MIDI program
+ BYTE nMidiChannel; // MIDI channel
+ BYTE nMidiDrumKey; // Drum set note mapping (currently only used by the .MID loader)
+ signed char nPPS; //Pitch/Pan separation (i.e. how wide the panning spreads)
+ unsigned char nPPC; //Pitch/Pan centre
CHAR name[32]; // Note: not guaranteed to be null-terminated.
CHAR filename[32];
- PLUGINDEX nMixPlug; //rewbs.instroVSTi
+ PLUGINDEX nMixPlug; // Plugin assigned to this instrument
// -> CODE#0027
// -> DESC="per-instrument volume ramping setup (refered as attack)"
- USHORT nVolRamp;
+ USHORT nVolRamp; // Default sample ramping
// -! NEW_FEATURE#0027
- UINT nResampling;
- BYTE nCutSwing;
- BYTE nResSwing;
- BYTE nFilterMode;
- WORD wPitchToTempoLock;
- BYTE nPluginVelocityHandling;
- BYTE nPluginVolumeHandling;
+ UINT nResampling; // Resampling mode
+ BYTE nCutSwing; // Random cutoff factor
+ BYTE nResSwing; // Random resonance factor
+ BYTE nFilterMode; // Default filter mode
+ WORD wPitchToTempoLock; // BPM at which the samples assigned to this instrument loop correctly
+ BYTE nPluginVelocityHandling; // How to deal with plugin velocity
+ BYTE nPluginVolumeHandling; // How to deal with plugin volume
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// WHEN adding new members here, ALSO update Sndfile.cpp (instructions near the top of this file)!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- CTuning* pTuning;
+ CTuning* pTuning; // sample tuning assigned to this instrument
static CTuning* s_DefaultTuning;
void SetTuning(CTuning* pT)
@@ -575,7 +574,7 @@
m_nGlobalVolumeDestination, m_nSamplePreAmp, m_nVSTiVolume;
long m_lHighResRampingGlobalVolume;
UINT m_nFreqFactor, m_nTempoFactor, m_nOldGlbVolSlide;
- LONG m_nMinPeriod, m_nMaxPeriod;
+ LONG m_nMinPeriod, m_nMaxPeriod; // min period = highest possible frequency, max period = lowest possible frequency
LONG m_nRepeatCount; // -1 means repeat infinitely.
DWORD m_nGlobalFadeSamples, m_nGlobalFadeMaxSamples;
UINT m_nMaxOrderPosition, m_nPatternNames;
@@ -592,7 +591,7 @@
MODMIDICFG m_MidiCfg; // Midi macro config table
SNDMIXPLUGIN m_MixPlugins[MAX_MIXPLUGINS]; // Mix plugins
SNDMIXSONGEQ m_SongEQ; // Default song EQ preset
- CHAR CompressionTable[16];
+ CHAR CompressionTable[16]; // ADPCM compression LUT
bool m_bChannelMuteTogglePending[MAX_BASECHANNELS];
CSoundFilePlayConfig* m_pConfig;
@@ -620,11 +619,6 @@
inline bool TypeIsMOD_S3M() const {return (m_nType & (MOD_TYPE_MOD | MOD_TYPE_S3M)) != 0;}
CModDoc* GetpModDoc() {return m_pModDoc;}
-
- //Return the number of channels in the pattern. In 1.17.02.45
- //it returned the number of channels with volume != 0
- CHANNELINDEX GetNumChannels() const {return static_cast<CHANNELINDEX>(m_nChannels);}
-
void SetMasterVolume(UINT vol, bool adjustAGC = false);
UINT GetMasterVolume() const { return m_nMasterVolume; }
PATTERNINDEX GetNumPatterns() const;
@@ -636,6 +630,7 @@
UINT GetSongComments(LPSTR s, UINT cbsize, UINT linesize=32);
UINT GetRawSongComments(LPSTR s, UINT cbsize, UINT linesize=32);
UINT GetMaxPosition() const;
+ CHANNELINDEX GetNumChannels() const { return m_nChannels; }
IMixPlugin* GetInstrumentPlugin(INSTRUMENTINDEX instr);
const CModSpecifications& GetModSpecifications() const {return *m_pModSpecs;}
Modified: trunk/OpenMPT/ungzip/ungzip.cpp
===================================================================
--- trunk/OpenMPT/ungzip/ungzip.cpp 2010-07-10 13:37:44 UTC (rev 638)
+++ trunk/OpenMPT/ungzip/ungzip.cpp 2010-07-10 17:35:43 UTC (rev 639)
@@ -30,8 +30,8 @@
}
-bool CGzipArchive::IsArchive()
-//----------------------------
+bool CGzipArchive::IsArchive() const
+//----------------------------------
{
if(m_lpStream == nullptr || m_dwStreamLen <= (sizeof(GZheader) + sizeof(GZtrailer)))
return false;
Modified: trunk/OpenMPT/ungzip/ungzip.h
===================================================================
--- trunk/OpenMPT/ungzip/ungzip.h 2010-07-10 13:37:44 UTC (rev 638)
+++ trunk/OpenMPT/ungzip/ungzip.h 2010-07-10 17:35:43 UTC (rev 639)
@@ -56,7 +56,7 @@
LPBYTE GetOutputFile() const { return m_pOutputFile; }
DWORD GetOutputFileLength() const { return m_dwOutputLen; }
- bool IsArchive();
+ bool IsArchive() const;
bool ExtractFile();
CGzipArchive(LPBYTE lpStream, DWORD dwMemLength);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-07-10 13:37:51
|
Revision: 638
http://modplug.svn.sourceforge.net/modplug/?rev=638&view=rev
Author: saga-games
Date: 2010-07-10 13:37:44 +0000 (Sat, 10 Jul 2010)
Log Message:
-----------
[Imp] OKT Loader: Compltely new IFF-based loader, translated from SchismTracker code with permission from Storlek. This loader is a *lot* more accurate, but still misses a few pattern effects.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/Mptrack.cpp
trunk/OpenMPT/soundlib/Load_okt.cpp
Modified: trunk/OpenMPT/mptrack/Mptrack.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Mptrack.cpp 2010-07-10 12:09:43 UTC (rev 637)
+++ trunk/OpenMPT/mptrack/Mptrack.cpp 2010-07-10 13:37:44 UTC (rev 638)
@@ -1857,7 +1857,7 @@
"coda for sample drawing code|"
"http://coda.s3m.us/|"
"Storlek for all the IT compatibility hints and testcases|"
- "as well as the IMF and ULT loaders|"
+ "as well as the IMF, OKT and ULT loaders|"
"http://schismtracker.org/|"
"kode54 for the PSM and J2B loaders|"
"http://kode54.foobar2000.org/|"
Modified: trunk/OpenMPT/soundlib/Load_okt.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_okt.cpp 2010-07-10 12:09:43 UTC (rev 637)
+++ trunk/OpenMPT/soundlib/Load_okt.cpp 2010-07-10 13:37:44 UTC (rev 638)
@@ -1,12 +1,10 @@
/*
- * This source code is public domain.
+ * Purpose: Load OKT (Oktalyzer) modules
+ * Authors: Storlek (Original author - http://schismtracker.org/)
+ * Johannes Schultz (OpenMPT Port, tweaks)
*
- * Copied to OpenMPT from libmodplug.
- *
- * Authors: Olivier Lapicque <oli...@jp...>,
- * Adam Goode <ad...@ev...> (endian and char fixes for PPC)
- *
-*/
+ * Thanks to Storlek for allowing me to use this code!
+ */
//////////////////////////////////////////////
// Oktalyzer (OKT) module loader //
@@ -14,189 +12,432 @@
#include "stdafx.h"
#include "sndfile.h"
-#pragma warning(disable:4244) //"conversion from 'type1' to 'type2', possible loss of data"
+// IFF chunk names
+#define OKTCHUNKID_CMOD 0x434D4F44
+#define OKTCHUNKID_SAMP 0x53414D50
+#define OKTCHUNKID_SPEE 0x53504545
+#define OKTCHUNKID_SLEN 0x534C454E
+#define OKTCHUNKID_PLEN 0x504C454E
+#define OKTCHUNKID_PATT 0x50415454
+#define OKTCHUNKID_PBOD 0x50424F44
+#define OKTCHUNKID_SBOD 0x53424F44
-typedef struct OKTFILEHEADER
+#pragma pack(1)
+
+struct OKT_IFFCHUNK
{
- DWORD okta; // "OKTA"
- DWORD song; // "SONG"
- DWORD cmod; // "CMOD"
- DWORD fixed8;
- BYTE chnsetup[8];
- DWORD samp; // "SAMP"
- DWORD samplen;
-} OKTFILEHEADER;
+ uint32 signature; // IFF chunk name
+ uint32 chunksize; // chunk size without header
+};
+struct OKT_SAMPLE
+{
+ char name[20];
+ uint32 length; // length in bytes
+ uint16 loopstart; // *2 for real value
+ uint16 looplen; // dito
+ uint16 volume; // default volume
+ uint16 type; // 7-/8-bit sample
+};
-typedef struct OKTSAMPLE
+STATIC_ASSERT(sizeof(OKT_SAMPLE) == 32);
+
+#pragma pack()
+
+
+// just for keeping track of offsets and stuff...
+struct OKT_SAMPLEINFO
{
- CHAR name[20];
- DWORD length;
- WORD loopstart;
- WORD looplen;
- BYTE pad1;
- BYTE volume;
- BYTE pad2;
- BYTE pad3;
-} OKTSAMPLE;
+ DWORD start; // start position of the IFF block
+ DWORD length; // length of the IFF block
+};
-bool CSoundFile::ReadOKT(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+// Parse the sample header block
+void Read_OKT_Samples(const BYTE *lpStream, const DWORD dwMemLength, vector<bool> &sample7bit, CSoundFile *pSndFile)
+//------------------------------------------------------------------------------------------------------------------
{
- OKTFILEHEADER *pfh = (OKTFILEHEADER *)lpStream;
- DWORD dwMemPos = sizeof(OKTFILEHEADER);
- UINT nsamples = 0, npatterns = 0, norders = 0;
+ pSndFile->m_nSamples = min((SAMPLEINDEX)(dwMemLength / 32), MAX_SAMPLES - 1); // typically 36
+ sample7bit.resize(pSndFile->GetNumSamples());
- if ((!lpStream) || (dwMemLength < 1024)) return false;
- if ((pfh->okta != 0x41544B4F) || (pfh->song != 0x474E4F53)
- || (pfh->cmod != 0x444F4D43) || (pfh->chnsetup[0]) || (pfh->chnsetup[2])
- || (pfh->chnsetup[4]) || (pfh->chnsetup[6]) || (pfh->fixed8 != 0x08000000)
- || (pfh->samp != 0x504D4153)) return false;
- m_nType = MOD_TYPE_OKT;
- m_nChannels = 4 + pfh->chnsetup[1] + pfh->chnsetup[3] + pfh->chnsetup[5] + pfh->chnsetup[7];
- if (m_nChannels > MAX_CHANNELS) m_nChannels = MAX_CHANNELS;
- nsamples = BigEndian(pfh->samplen) >> 5;
- m_nSamples = nsamples;
- if (m_nSamples >= MAX_SAMPLES) m_nSamples = MAX_SAMPLES-1;
- // Reading samples
- for (UINT smp=1; smp <= nsamples; smp++)
+ for(SAMPLEINDEX nSmp = 1; nSmp <= pSndFile->GetNumSamples(); nSmp++)
{
- if (dwMemPos >= dwMemLength) return true;
- if (smp < MAX_SAMPLES)
+ MODSAMPLE *pSmp = &pSndFile->Samples[nSmp];
+ OKT_SAMPLE oktsmp;
+ memcpy(&oktsmp, lpStream + (nSmp - 1) * 32, sizeof(OKT_SAMPLE));
+
+ oktsmp.length = min(BigEndian(oktsmp.length), MAX_SAMPLE_LENGTH);
+ oktsmp.loopstart = BigEndianW(oktsmp.loopstart) * 2;
+ oktsmp.looplen = BigEndianW(oktsmp.looplen) * 2;
+ oktsmp.volume = BigEndianW(oktsmp.volume);
+ oktsmp.type = BigEndianW(oktsmp.type);
+
+ MemsetZero(*pSmp);
+ strncpy(pSndFile->m_szNames[nSmp], oktsmp.name, 20);
+ SpaceToNullStringFixed(pSndFile->m_szNames[nSmp], 20);
+
+ pSmp->nC5Speed = 8287;
+ pSmp->nGlobalVol = 64;
+ pSmp->nVolume = min(oktsmp.volume, 64) * 4;
+ pSmp->nLength = oktsmp.length & ~1; // round down
+ // parse loops
+ if (oktsmp.looplen > 2 && ((UINT)oktsmp.loopstart) + ((UINT)oktsmp.looplen) <= pSmp->nLength)
{
- OKTSAMPLE *psmp = (OKTSAMPLE *)(lpStream + dwMemPos);
- MODSAMPLE *pSmp = &Samples[smp];
-
- memcpy(m_szNames[smp], psmp->name, 20);
- SpaceToNullStringFixed(m_szNames[smp], 20);
- pSmp->uFlags = 0;
- pSmp->nLength = BigEndian(psmp->length) & ~1;
- pSmp->nLoopStart = BigEndianW(psmp->loopstart);
- pSmp->nLoopEnd = pSmp->nLoopStart + BigEndianW(psmp->looplen);
- if (pSmp->nLoopStart + 2 < pSmp->nLoopEnd) pSmp->uFlags |= CHN_LOOP;
- pSmp->nGlobalVol = 64;
- pSmp->nVolume = psmp->volume << 2;
- pSmp->nC5Speed = 8363;
+ pSmp->nSustainStart = oktsmp.loopstart;
+ pSmp->nSustainEnd = oktsmp.loopstart + oktsmp.looplen;
+ if (pSmp->nSustainStart < pSmp->nLength && pSmp->nSustainEnd <= pSmp->nLength)
+ pSmp->uFlags |= CHN_SUSTAINLOOP;
+ else
+ pSmp->nSustainStart = pSmp->nSustainEnd = 0;
}
- dwMemPos += sizeof(OKTSAMPLE);
+ sample7bit[nSmp - 1] = (oktsmp.type == 0 || oktsmp.type == 2) ? true : false;
}
- // SPEE
- if (dwMemPos >= dwMemLength) return true;
- if (*((DWORD *)(lpStream + dwMemPos)) == 0x45455053)
+}
+
+
+// Parse a pattern block
+void Read_OKT_Pattern(const BYTE *lpStream, const DWORD dwMemLength, const PATTERNINDEX nPat, CSoundFile *pSndFile)
+//-----------------------------------------------------------------------------------------------------------------
+{
+ #define ASSERT_CAN_READ(x) \
+ if( dwMemPos > dwMemLength || x > dwMemLength - dwMemPos ) return;
+
+ DWORD dwMemPos = 0;
+
+ ASSERT_CAN_READ(2);
+ ROWINDEX nRows = CLAMP(BigEndianW(*(uint16 *)(lpStream + dwMemPos)), 1, MAX_PATTERN_ROWS);
+ dwMemPos += 2;
+
+ if(pSndFile->Patterns.Insert(nPat, nRows))
+ return;
+
+ const CHANNELINDEX nChns = pSndFile->GetNumChannels();
+ MODCOMMAND *mrow = pSndFile->Patterns[nPat], *m;
+
+ for(ROWINDEX nRow = 0; nRow < nRows; nRow++, mrow += nChns)
{
- m_nDefaultSpeed = lpStream[dwMemPos+9];
- dwMemPos += BigEndian(*((DWORD *)(lpStream + dwMemPos + 4))) + 8;
- }
- // SLEN
- if (dwMemPos >= dwMemLength) return true;
- if (*((DWORD *)(lpStream + dwMemPos)) == 0x4E454C53)
- {
- npatterns = lpStream[dwMemPos+9];
- dwMemPos += BigEndian(*((DWORD *)(lpStream + dwMemPos + 4))) + 8;
- }
- // PLEN
- if (dwMemPos >= dwMemLength) return true;
- if (*((DWORD *)(lpStream + dwMemPos)) == 0x4E454C50)
- {
- norders = lpStream[dwMemPos+9];
- dwMemPos += BigEndian(*((DWORD *)(lpStream + dwMemPos + 4))) + 8;
- }
- // PATT
- if (dwMemPos >= dwMemLength) return true;
- if (*((DWORD *)(lpStream + dwMemPos)) == 0x54544150)
- {
- UINT orderlen = norders;
- if (orderlen >= MAX_ORDERS) orderlen = MAX_ORDERS-1;
- Order.resize(orderlen);
- for (UINT i=0; i<orderlen; i++) Order[i] = lpStream[dwMemPos+10+i];
- for (UINT j=orderlen; j>1; j--) { if (Order[j-1]) break; Order[j-1] = 0xFF; }
- dwMemPos += BigEndian(*((DWORD *)(lpStream + dwMemPos + 4))) + 8;
- }
- // PBOD
- UINT npat = 0;
- while ((dwMemPos < dwMemLength-10) && (*((DWORD *)(lpStream + dwMemPos)) == 0x444F4250))
- {
- DWORD dwPos = dwMemPos + 10;
- UINT rows = lpStream[dwMemPos+9];
- if (!rows) rows = 64;
- if (npat < MAX_PATTERNS)
+ m = mrow;
+ for(CHANNELINDEX nChn = 0; nChn < nChns; nChn++, m++)
{
- if(Patterns.Insert(npat, rows))
- return true;
- MODCOMMAND *m = Patterns[npat];
- UINT imax = m_nChannels*rows;
- for (UINT i=0; i<imax; i++, m++, dwPos+=4)
+ ASSERT_CAN_READ(4);
+ m->note = lpStream[dwMemPos++];
+ m->instr = lpStream[dwMemPos++];
+ int8 fxcmd = lpStream[dwMemPos++];
+ m->param = lpStream[dwMemPos++];
+
+ if(m->note > 0 && m->note <= 36)
{
- if (dwPos+4 > dwMemLength) break;
- const BYTE *p = lpStream+dwPos;
- UINT note = p[0];
- if (note)
+ m->note += 48;
+ m->instr++;
+ } else
+ {
+ m->instr = 0;
+ }
+
+ switch(fxcmd)
+ {
+ case 0: // Nothing
+ m->param = 0;
+ break;
+
+ case 1: // 1 Portamento Down (Period)
+ m->command = CMD_PORTAMENTODOWN;
+ m->param &= 0x0F;
+ break;
+ case 2: // 2 Portamento Up (Period)
+ m->command = CMD_PORTAMENTOUP;
+ m->param &= 0x0F;
+ break;
+
+#if 0
+ /* these aren't like Jxx: "down" means to *subtract* the offset from the note.
+ For now I'm going to leave these unimplemented. */
+ case 10: // A Arpeggio 1 (down, orig, up)
+ case 11: // B Arpeggio 2 (orig, up, orig, down)
+ if (note->param)
+ note->command = CMD_ARPEGGIO;
+ break;
+#endif
+ // This one is close enough to "standard" arpeggio -- I think!
+ case 12: // C Arpeggio 3 (up, up, orig)
+ if (m->param)
+ m->command = CMD_ARPEGGIO;
+ break;
+
+ case 13: // D Slide Down (Notes)
+ if (m->param)
{
- m->note = note + 48;
- m->instr = p[1] + 1;
+ m->command = CMD_NOTESLIDEDOWN;
+ m->param = 0x10 | min(0x0F, m->param);
}
- UINT command = p[2];
- UINT param = p[3];
- m->param = param;
- switch(command)
+ break;
+ case 30: // U Slide Up (Notes)
+ if (m->param)
{
- // 0: no effect
- case 0:
+ m->command = CMD_NOTESLIDEUP;
+ m->param = 0x10 | min(0x0F, m->param);
+ }
+ break;
+ /* We don't have fine note slide, but this is supposed to happen once
+ per row. Sliding every 5 (non-note) ticks kind of works (at least at
+ speed 6), but implementing fine slides would of course be better. */
+ case 21: // L Slide Down Once (Notes)
+ if (m->param)
+ {
+ m->command = CMD_NOTESLIDEDOWN;
+ m->param = 0x50 | min(0x0F, m->param);
+ }
+ break;
+ case 17: // H Slide Up Once (Notes)
+ if (m->param)
+ {
+ m->command = CMD_NOTESLIDEUP;
+ m->param = 0x50 | min(0x0F, m->param);
+ }
+ break;
+
+ case 15: // F Set Filter <>00:ON
+ // Not implemented, but let's import it anyway...
+ m->command = CMD_MODCMDEX;
+ m->param = !!m->param;
+ break;
+
+ case 25: // P Pos Jump
+ m->command = CMD_POSITIONJUMP;
+ break;
+
+ case 27: // R Release sample (apparently not listed in the help!)
+ m->Clear();
+ m->note = NOTE_KEYOFF;
+ break;
+
+ case 28: // S Speed
+ m->command = CMD_SPEED; // or tempo?
+ break;
+
+ case 31: // V Volume
+ m->command = CMD_VOLUMESLIDE;
+ switch (m->param >> 4)
+ {
+ case 4:
+ if (m->param != 0x40)
+ {
+ m->param &= 0x0F; // D0x
+ break;
+ }
+ // 0x40 is set volume -- fall through
+ case 0: case 1: case 2: case 3:
+ m->volcmd = VOLCMD_VOLUME;
+ m->vol = m->param;
+ m->command = CMD_NONE;
+ m->param = 0;
break;
- // 1: Portamento Up
- case 1:
- case 17:
- case 30:
- if (param) m->command = CMD_PORTAMENTOUP;
+ case 5:
+ m->param = (m->param & 0x0F) << 4; // Dx0
break;
- // 2: Portamento Down
- case 2:
- case 13:
- case 21:
- if (param) m->command = CMD_PORTAMENTODOWN;
+ case 6:
+ m->param = 0xF0 | min(m->param & 0x0F, 0x0E); // DFx
break;
- // 10: Arpeggio
- case 10:
- case 11:
- case 12:
- m->command = CMD_ARPEGGIO;
+ case 7:
+ m->param = (min(m->param & 0x0F, 0x0E) << 4) | 0x0F; // DxF
break;
- // 15: Filter
- case 15:
- m->command = CMD_MODCMDEX;
- m->param = param & 0x0F;
+ default:
+ // Junk.
+ m->command = m->param = 0;
break;
- // 25: Position Jump
- case 25:
- m->command = CMD_POSITIONJUMP;
- break;
- // 28: Set Speed
- case 28:
- m->command = CMD_SPEED;
- break;
- // 31: Volume Control
- case 31:
- if (param <= 0x40) m->command = CMD_VOLUME; else
- if (param <= 0x50) { m->command = CMD_VOLUMESLIDE; m->param &= 0x0F; if (!m->param) m->param = 0x0F; } else
- if (param <= 0x60) { m->command = CMD_VOLUMESLIDE; m->param = (param & 0x0F) << 4; if (!m->param) m->param = 0xF0; } else
- if (param <= 0x70) { m->command = CMD_MODCMDEX; m->param = 0xB0 | (param & 0x0F); if (!(param & 0x0F)) m->param = 0xBF; } else
- if (param <= 0x80) { m->command = CMD_MODCMDEX; m->param = 0xA0 | (param & 0x0F); if (!(param & 0x0F)) m->param = 0xAF; }
- break;
}
+ break;
+
+#if 0
+ case 24: // O Old Volume (???)
+ m->command = CMD_VOLUMESLIDE;
+ m->param = 0;
+ break;
+#endif
+
+ default:
+ m->command = m->param = 0;
+ //ASSERT(false);
+ break;
}
}
- npat++;
- dwMemPos += BigEndian(*((DWORD *)(lpStream + dwMemPos + 4))) + 8;
}
- // SBOD
- UINT nsmp = 1;
- while ((dwMemPos < dwMemLength - 10) && (*((DWORD *)(lpStream + dwMemPos)) == 0x444F4253))
+
+ #undef ASSERT_CAN_READ
+}
+
+
+bool CSoundFile::ReadOKT(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
+{
+ #define ASSERT_CAN_READ(x) \
+ if( dwMemPos > dwMemLength || x > dwMemLength - dwMemPos ) return false;
+
+ DWORD dwMemPos = 0;
+
+ ASSERT_CAN_READ(8);
+ if (memcmp(lpStream, "OKTASONG", 8) != 0)
+ return false;
+ dwMemPos += 8;
+
+ OKT_IFFCHUNK iffHead;
+ // prepare some arrays to store offsets etc.
+ vector<DWORD> patternOffsets;
+ vector<bool> sample7bit; // 7-/8-bit sample
+ vector<OKT_SAMPLEINFO> samplePos;
+ PATTERNINDEX nPatterns = 0;
+ ORDERINDEX nOrders = 0;
+
+ MemsetZero(m_szNames);
+ m_nChannels = 0;
+ m_nSamples = 0;
+
+ // Go through IFF chunks...
+ while(dwMemPos < dwMemLength)
{
- if (nsmp < MAX_SAMPLES) ReadSample(&Samples[nsmp], RS_PCM8S, (LPSTR)(lpStream+dwMemPos+8), dwMemLength-dwMemPos-8);
- dwMemPos += BigEndian(*((DWORD *)(lpStream + dwMemPos + 4))) + 8;
- nsmp++;
+ ASSERT_CAN_READ(sizeof(OKT_IFFCHUNK));
+ memcpy(&iffHead, lpStream + dwMemPos, sizeof(OKT_IFFCHUNK));
+ iffHead.signature = BigEndian(iffHead.signature);
+ iffHead.chunksize = BigEndian(iffHead.chunksize);
+ dwMemPos += sizeof(OKT_IFFCHUNK);
+
+ switch(iffHead.signature)
+ {
+ case OKTCHUNKID_CMOD:
+ // read that weird channel setup table
+ if(m_nChannels > 0)
+ break;
+ ASSERT_CAN_READ(8);
+ for(CHANNELINDEX nChn = 0; nChn < 4; nChn++)
+ {
+ if(lpStream[dwMemPos + nChn * 2] || lpStream[dwMemPos + nChn * 2 + 1])
+ {
+ ChnSettings[m_nChannels++].nPan = (((nChn & 3) == 1) || ((nChn & 3) == 2)) ? 0xC0 : 0x40;
+ }
+ ChnSettings[m_nChannels++].nPan = (((nChn & 3) == 1) || ((nChn & 3) == 2)) ? 0xC0 : 0x40;
+ }
+ break;
+
+ case OKTCHUNKID_SAMP:
+ // convert sample headers
+ if(m_nSamples > 0)
+ break;
+ ASSERT_CAN_READ(iffHead.chunksize);
+ Read_OKT_Samples(lpStream + dwMemPos, iffHead.chunksize, sample7bit, this);
+ break;
+
+ case OKTCHUNKID_SPEE:
+ // read default speed
+ {
+ ASSERT_CAN_READ(2);
+ uint16 defspeed = BigEndianW(*((uint16 *)(lpStream + dwMemPos)));
+ m_nDefaultSpeed = CLAMP(defspeed, 1, 255);
+ }
+ break;
+
+ case OKTCHUNKID_SLEN:
+ // number of patterns, we don't need this.
+ break;
+
+ case OKTCHUNKID_PLEN:
+ // read number of valid orders
+ ASSERT_CAN_READ(2);
+ nOrders = BigEndianW(*((uint16 *)(lpStream + dwMemPos)));
+ break;
+
+ case OKTCHUNKID_PATT:
+ // read the orderlist
+ ASSERT_CAN_READ(iffHead.chunksize);
+ Order.ReadAsByte(lpStream + dwMemPos, min(iffHead.chunksize, MAX_ORDERS), iffHead.chunksize);
+ break;
+
+ case OKTCHUNKID_PBOD:
+ // don't read patterns for now, as the number of channels might be unknown at this point.
+ if(nPatterns < MAX_PATTERNS)
+ {
+ if(iffHead.chunksize > 0)
+ patternOffsets.push_back(dwMemPos);
+ nPatterns++;
+ }
+ break;
+
+ case OKTCHUNKID_SBOD:
+ // sample data - same as with patterns, as we need to know the sample format / length
+ if(samplePos.size() < MAX_SAMPLES - 1)
+ {
+ ASSERT_CAN_READ(iffHead.chunksize);
+ if(iffHead.chunksize)
+ {
+ OKT_SAMPLEINFO sinfo;
+ sinfo.start = dwMemPos;
+ sinfo.length = iffHead.chunksize;
+ samplePos.push_back(sinfo);
+ }
+ }
+ break;
+ }
+
+ dwMemPos += iffHead.chunksize;
}
+
+ // If there wasn't even a CMOD chunk, we can't really load this.
+ if(m_nChannels == 0)
+ return false;
+
+ m_nDefaultTempo = 125;
+ m_nDefaultGlobalVolume = 256;
+ m_nSamplePreAmp = m_nVSTiVolume = 48;
+ m_nType = MOD_TYPE_OKT;
+ m_nMinPeriod = 0x71 << 2;
+ m_nMaxPeriod = 0x358 << 2;
+
+ // Fix orderlist
+ for(ORDERINDEX nOrd = nOrders; nOrd < Order.GetLengthTailTrimmed(); nOrd++)
+ {
+ Order[nOrd] = Order.GetInvalidPatIndex();
+ }
+
+ // Read patterns
+ for(PATTERNINDEX nPat = 0; nPat < nPatterns; nPat++)
+ {
+ if(patternOffsets[nPat] > 0)
+ Read_OKT_Pattern(lpStream + patternOffsets[nPat], dwMemLength - patternOffsets[nPat], nPat, this);
+ else
+ Patterns.Insert(nPat, 64); // invent empty pattern
+ }
+
+ // Read samples
+ size_t nFileSmp = 0;
+ for(SAMPLEINDEX nSmp = 1; nSmp < m_nSamples; nSmp++)
+ {
+ if(nFileSmp >= samplePos.size())
+ break;
+
+ MODSAMPLE *pSmp = &Samples[nSmp];
+ if(pSmp->nLength == 0)
+ continue;
+
+ // weird stuff?
+ if(pSmp->nLength != samplePos[nFileSmp].length)
+ {
+ pSmp->nLength = min(pSmp->nLength, samplePos[nFileSmp].length);
+ }
+
+ ReadSample(pSmp, RS_PCM8S, (LPCSTR)(lpStream + samplePos[nFileSmp].start), dwMemLength - samplePos[nFileSmp].start);
+
+ // 7-bit to 8-bit hack
+ if(sample7bit[nSmp - 1] && pSmp->pSample)
+ {
+ for(size_t i = 0; i < pSmp->nLength; i++)
+ pSmp->pSample[i] = CLAMP(pSmp->pSample[i] * 2, -128, 127);
+ }
+
+ nFileSmp++;
+ }
+
+ SetModFlag(MSF_COMPATIBLE_PLAY, true);
+
return true;
+
+ #undef ASSERT_CAN_READ
}
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-07-10 12:09:49
|
Revision: 637
http://modplug.svn.sourceforge.net/modplug/?rev=637&view=rev
Author: saga-games
Date: 2010-07-10 12:09:43 +0000 (Sat, 10 Jul 2010)
Log Message:
-----------
[Fix] Instrument Editor: Panning ranges were not updated properly when converting between IT <-> MPTM (see previous commit).
Modified Paths:
--------------
trunk/OpenMPT/mptrack/Ctrl_ins.cpp
Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2010-07-10 12:03:54 UTC (rev 636)
+++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2010-07-10 12:09:43 UTC (rev 637)
@@ -1125,6 +1125,9 @@
else
m_SpinFadeOut.SetRange(0, 8192);
+ // Panning ranges
+ m_SpinPanning.SetRange(0, (m_pModDoc->GetModType() & MOD_TYPE_IT) ? 64 : 256);
+
m_NoteMap.EnableWindow(bITandXM);
m_CbnResampling.EnableWindow(bITandXM);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-07-10 12:04:00
|
Revision: 636
http://modplug.svn.sourceforge.net/modplug/?rev=636&view=rev
Author: saga-games
Date: 2010-07-10 12:03:54 +0000 (Sat, 10 Jul 2010)
Log Message:
-----------
[Fix] IT Saver: Instrument panning was not converted properly.
[Imp] Instrument editor: Panning ranges from 0 to 256 again for MPTM, and from 0 to 64 for IT files.
[Imp] J2B Loader: Added some security checks for sample and pattern length
[Mod] Sample Generator (still unused): Using the fmod command for module operations.
[Ref] Some refactoring, especially regarding the "instrumentModified" array.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/Ctrl_ins.cpp
trunk/OpenMPT/mptrack/Moddoc.cpp
trunk/OpenMPT/mptrack/Modedit.cpp
trunk/OpenMPT/mptrack/SampleGenerator.h
trunk/OpenMPT/mptrack/View_tre.cpp
trunk/OpenMPT/soundlib/Load_it.cpp
trunk/OpenMPT/soundlib/Load_mod.cpp
trunk/OpenMPT/soundlib/Snd_defs.h
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/load_j2b.cpp
trunk/OpenMPT/soundlib/patternContainer.h
Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2010-07-04 14:41:38 UTC (rev 635)
+++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2010-07-10 12:03:54 UTC (rev 636)
@@ -870,7 +870,7 @@
// Global Volume
m_SpinGlobalVol.SetRange(0, 64);
// Panning
- m_SpinPanning.SetRange(0, 255);
+ m_SpinPanning.SetRange(0, (m_pModDoc->GetModType() & MOD_TYPE_IT) ? 64 : 256);
// Midi Program
m_SpinMidiPR.SetRange(0, 128);
// rewbs.MidiBank
@@ -1172,7 +1172,7 @@
// Global Volume
SetDlgItemInt(IDC_EDIT8, pIns->nGlobalVol);
// Panning
- SetDlgItemInt(IDC_EDIT9, pIns->nPan);
+ SetDlgItemInt(IDC_EDIT9, (m_pModDoc->GetModType() & MOD_TYPE_IT) ? (pIns->nPan / 4) : pIns->nPan);
m_CheckPanning.SetCheck((pIns->dwFlags & INS_SETPANNING) ? TRUE : FALSE);
// Midi
if (pIns->nMidiProgram>0 && pIns->nMidiProgram<=128)
@@ -1838,14 +1838,14 @@
}
if(smpPanningInUse)
{
- if(MessageBox("Some of the samples used in the instrument have \"Set Pan\" enabled. "
+ if(MessageBox(_T("Some of the samples used in the instrument have \"Set Pan\" enabled. "
"When instrument is played with such sample, sample pan setting overrides instrument pan. "
"Do you wish to disable panning from those samples so that instrument pan setting is effective "
- "for the whole instrument?",
- "",
+ "for the whole instrument?"),
+ _T(""),
MB_YESNO) == IDYES)
{
- for(BYTE i = 0; i<ARRAYELEMCOUNT(pIns->Keyboard); i++)
+ for(BYTE i = 0; i < ARRAYELEMCOUNT(pIns->Keyboard); i++)
{
const SAMPLEINDEX smp = pIns->Keyboard[i];
if(smp <= m_pSndFile->GetNumSamples())
@@ -1874,6 +1874,8 @@
if ((!IsLocked()) && (pIns))
{
int nPan = GetDlgItemInt(IDC_EDIT9);
+ if(m_pModDoc->GetModType() & MOD_TYPE_IT) // IT panning ranges from 0 to 64
+ nPan *= 4;
if (nPan < 0) nPan = 0;
if (nPan > 256) nPan = 256;
if (nPan != (int)pIns->nPan)
@@ -1882,7 +1884,7 @@
if (m_pSndFile->m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT)) m_pModDoc->SetModified();
// -> CODE#0023
// -> DESC="IT project files (.itp)"
- m_pSndFile->instrumentModified[m_nInstrument-1] = TRUE;
+ m_pSndFile->instrumentModified[m_nInstrument - 1] = true;
m_pModDoc->UpdateAllViews(NULL, HINT_INSNAMES, this);
// -! NEW_FEATURE#0023
}
@@ -1903,7 +1905,7 @@
// -> CODE#0023
// -> DESC="IT project files (.itp)"
- m_pSndFile->instrumentModified[m_nInstrument-1] = TRUE;
+ m_pSndFile->instrumentModified[m_nInstrument - 1] = true;
m_pModDoc->UpdateAllViews(NULL, HINT_INSNAMES, this);
// -! NEW_FEATURE#0023
Modified: trunk/OpenMPT/mptrack/Moddoc.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Moddoc.cpp 2010-07-04 14:41:38 UTC (rev 635)
+++ trunk/OpenMPT/mptrack/Moddoc.cpp 2010-07-10 12:03:54 UTC (rev 636)
@@ -452,10 +452,10 @@
{
if((m_SndFile.m_nType & MOD_TYPE_IT) && m_SndFile.m_dwSongFlags & SONG_ITPROJECT && !(m_SndFile.m_dwSongFlags & SONG_ITPEMBEDIH)){
- BOOL unsavedInstrument = FALSE;
+ bool unsavedInstrument = false;
for(UINT i = 0 ; i < m_SndFile.m_nInstruments ; i++){
- if(m_SndFile.instrumentModified[i]) { unsavedInstrument = TRUE; break; }
+ if(m_SndFile.instrumentModified[i]) { unsavedInstrument = true; break; }
}
if(unsavedInstrument && ::MessageBox(NULL,"Do you want to save modified instruments ?",NULL,MB_ICONQUESTION | MB_YESNO | MB_APPLMODAL) == IDYES){
@@ -463,8 +463,8 @@
for(INSTRUMENTINDEX i = 0 ; i < m_SndFile.m_nInstruments ; i++){
if(m_SndFile.m_szInstrumentPath[i][0] != '\0'){
int size = strlen(m_SndFile.m_szInstrumentPath[i]);
- BOOL iti = _stricmp(&m_SndFile.m_szInstrumentPath[i][size-3],"iti") == 0;
- BOOL xi = _stricmp(&m_SndFile.m_szInstrumentPath[i][size-2],"xi") == 0;
+ bool iti = _stricmp(&m_SndFile.m_szInstrumentPath[i][size-3],"iti") == 0;
+ bool xi = _stricmp(&m_SndFile.m_szInstrumentPath[i][size-2],"xi") == 0;
if(iti || (!iti && !xi && m_SndFile.m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT)))
m_SndFile.SaveITIInstrument(i+1, m_SndFile.m_szInstrumentPath[i]);
Modified: trunk/OpenMPT/mptrack/Modedit.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Modedit.cpp 2010-07-04 14:41:38 UTC (rev 635)
+++ trunk/OpenMPT/mptrack/Modedit.cpp 2010-07-10 12:03:54 UTC (rev 636)
@@ -822,7 +822,7 @@
// -> CODE#0023
// -> DESC="IT project files (.itp)"
strcpy(m_SndFile.m_szInstrumentPath[newins - 1], m_SndFile.m_szInstrumentPath[nDuplicate - 1]);
- m_SndFile.instrumentModified[newins-1] = FALSE;
+ m_SndFile.instrumentModified[newins - 1] = false;
// -! NEW_FEATURE#0023
} else
{
Modified: trunk/OpenMPT/mptrack/SampleGenerator.h
===================================================================
--- trunk/OpenMPT/mptrack/SampleGenerator.h 2010-07-04 14:41:38 UTC (rev 635)
+++ trunk/OpenMPT/mptrack/SampleGenerator.h 2010-07-10 12:03:54 UTC (rev 636)
@@ -17,7 +17,7 @@
#define SMPGEN_MAXLENGTH MAX_SAMPLE_LENGTH
// sample frequency
#define SMPGEN_MINFREQ 1
-#define SMPGEN_MAXFREQ 96000
+#define SMPGEN_MAXFREQ 96000 // MAX_SAMPLE_RATE
// 16-bit sample quality - when changing this, also change CSampleGenerator::sampling_type and 16-bit flags in SampleGenerator.cpp!
#define SMPGEN_MIXBYTES 2
@@ -53,13 +53,13 @@
// Rendering callback functions
// functions
static mu::value_type ClipCallback(mu::value_type val, mu::value_type min, mu::value_type max) { return CLAMP(val, min, max); };
- static mu::value_type PWMCallback(mu::value_type pos, mu::value_type duty, mu::value_type width) { if((int)width == 0) return 0; else return (((int)pos % (int)width) < ((duty / 100) * width)) ? 1 : -1; };
- static mu::value_type RndCallback(mu::value_type v) { return v*std::rand()/(mu::value_type)(RAND_MAX+1.0); }
+ static mu::value_type PWMCallback(mu::value_type pos, mu::value_type duty, mu::value_type width) { if(width == 0) return 0; else return (fmod(pos, width) < ((duty / 100) * width)) ? 1 : -1; };
+ static mu::value_type RndCallback(mu::value_type v) { return v*std::rand()/(mu::value_type)(RAND_MAX+1.0); };
static mu::value_type SampleDataCallback(mu::value_type v);
static mu::value_type TriangleCallback(mu::value_type pos, mu::value_type width) { if((int)width == 0) return 0; else return abs(((int)pos % (int)(width)) - width / 2) / (width / 4) - 1; };
// binary operators
- static mu::value_type ModuloCallback(mu::value_type x, mu::value_type y) { if((int)y == 0) return 0; else return ((int)x) % ((int)y); };
+ static mu::value_type ModuloCallback(mu::value_type x, mu::value_type y) { if(y == 0) return 0; else return fmod(x , y); };
void ShowError(mu::Parser::exception_type *e);
@@ -136,10 +136,10 @@
public:
- int GetFrequency() { return sample_frequency; };
- int GetLength() { return sample_length; };
- smpgen_clip_methods GetClipping() { return sample_clipping; }
- mu::string_type GetExpression() { return expression; };
+ const int GetFrequency() { return sample_frequency; };
+ const int GetLength() { return sample_length; };
+ const smpgen_clip_methods GetClipping() { return sample_clipping; }
+ const mu::string_type GetExpression() { return expression; };
bool CanApply() { return apply; };
CSmpGenDialog(int freq, int len, smpgen_clip_methods clipping, mu::string_type expr):CDialog(IDD_SAMPLE_GENERATOR, CMainFrame::GetMainFrame())
Modified: trunk/OpenMPT/mptrack/View_tre.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_tre.cpp 2010-07-04 14:41:38 UTC (rev 635)
+++ trunk/OpenMPT/mptrack/View_tre.cpp 2010-07-10 12:03:54 UTC (rev 636)
@@ -968,8 +968,8 @@
if((pSndFile->m_dwSongFlags & SONG_ITPROJECT) != 0)
{
// path info for ITP instruments
- BOOL pathOk = pSndFile->m_szInstrumentPath[nIns-1][0] != '\0';
- BOOL instOk = pSndFile->instrumentModified[nIns-1] == FALSE;
+ bool pathOk = pSndFile->m_szInstrumentPath[nIns-1][0] != '\0';
+ bool instOk = pSndFile->instrumentModified[nIns-1] == false;
wsprintf(s, pathOk ? (instOk ? "%3d: %s" : "%3d: * %s") : "%3d: ? %s", nIns, (LPCTSTR)pSndFile->GetInstrumentName(nIns));
} else
{
@@ -3058,7 +3058,7 @@
if(xi || (!xi && !iti && pSndFile->m_nType == MOD_TYPE_XM))
pSndFile->SaveXIInstrument((INSTRUMENTINDEX)modItemID, pSndFile->m_szInstrumentPath[modItemID - 1]);
- pSndFile->instrumentModified[modItemID - 1] = FALSE;
+ pSndFile->instrumentModified[modItemID - 1] = false;
}
if(pModDoc) pModDoc->UpdateAllViews(NULL, HINT_MODTYPE);
Modified: trunk/OpenMPT/soundlib/Load_it.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_it.cpp 2010-07-04 14:41:38 UTC (rev 635)
+++ trunk/OpenMPT/soundlib/Load_it.cpp 2010-07-10 12:03:54 UTC (rev 636)
@@ -2065,7 +2065,7 @@
iti.pps = pIns->nPPS;
iti.ppc = pIns->nPPC;
iti.gbv = (BYTE)(pIns->nGlobalVol << 1);
- iti.dfp = (BYTE)pIns->nPan >> 2;
+ iti.dfp = (BYTE)(pIns->nPan >> 2);
if (!(pIns->dwFlags & INS_SETPANNING)) iti.dfp |= 0x80;
iti.rv = pIns->nVolSwing;
iti.rp = pIns->nPanSwing;
@@ -2664,7 +2664,7 @@
iti.pps = pIns->nPPS;
iti.ppc = pIns->nPPC;
iti.gbv = (BYTE)(pIns->nGlobalVol << 1);
- iti.dfp = (BYTE)pIns->nPan >> 2;
+ iti.dfp = (BYTE)(pIns->nPan >> 2);
if (!(pIns->dwFlags & INS_SETPANNING)) iti.dfp |= 0x80;
iti.rv = pIns->nVolSwing;
iti.rp = pIns->nPanSwing;
Modified: trunk/OpenMPT/soundlib/Load_mod.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mod.cpp 2010-07-04 14:41:38 UTC (rev 635)
+++ trunk/OpenMPT/soundlib/Load_mod.cpp 2010-07-10 12:03:54 UTC (rev 636)
@@ -428,7 +428,7 @@
}
// Reading samples
- DWORD dwErrCheck = 0;
+ bool bSamplesPresent = false;
for (UINT ismp = 1; ismp <= m_nSamples; ismp++) if (Samples[ismp].nLength)
{
LPSTR p = (LPSTR)(lpStream + dwMemPos);
@@ -446,13 +446,13 @@
if (dwSize)
{
dwMemPos += dwSize;
- dwErrCheck++;
+ bSamplesPresent = true;
}
}
#ifdef MODPLUG_TRACKER
return true;
#else
- return (dwErrCheck) ? true : false;
+ return bSamplesPresent;
#endif
}
Modified: trunk/OpenMPT/soundlib/Snd_defs.h
===================================================================
--- trunk/OpenMPT/soundlib/Snd_defs.h 2010-07-04 14:41:38 UTC (rev 635)
+++ trunk/OpenMPT/soundlib/Snd_defs.h 2010-07-10 12:03:54 UTC (rev 636)
@@ -16,6 +16,7 @@
typedef uint32 ROWINDEX;
const ROWINDEX ROWINDEX_MAX = uint32_max;
+ const ROWINDEX ROWINDEX_INVALID = ROWINDEX_MAX;
typedef uint16 CHANNELINDEX;
const CHANNELINDEX CHANNELINDEX_MAX = uint16_max;
const CHANNELINDEX CHANNELINDEX_INVALID = CHANNELINDEX_MAX;
@@ -358,15 +359,19 @@
NUM_SRC_MODES
};
-enum {
+// Envelope reset choices
+enum enmResetEnv
+{
ENV_RESET_ALL,
ENV_RESET_VOL,
ENV_RESET_PAN,
ENV_RESET_PITCH,
- ENV_RELEASE_NODE_UNSET=0xFF,
- NOT_YET_RELEASED=-1
};
+// Release node defines
+#define ENV_RELEASE_NODE_UNSET 0xFF
+#define NOT_YET_RELEASED (-1)
+
enum {
CHANNEL_ONLY = 0,
INSTRUMENT_ONLY = 1,
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2010-07-04 14:41:38 UTC (rev 635)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2010-07-10 12:03:54 UTC (rev 636)
@@ -2057,8 +2057,8 @@
return TRUE;
}
-void CSoundFile::resetEnvelopes(MODCHANNEL* pChn, int envToReset)
-//---------------------------------------------------------------
+void CSoundFile::resetEnvelopes(MODCHANNEL* pChn, enmResetEnv envToReset)
+//-----------------------------------------------------------------------
{
switch (envToReset)
{
@@ -4153,8 +4153,7 @@
{
if(bAutoSet)
SetRowVisited(nOrd, nRow, true);
- else
- return false;
+ return false;
}
if(m_bVisitedRows[nOrd][nRow])
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2010-07-04 14:41:38 UTC (rev 635)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2010-07-10 12:03:54 UTC (rev 636)
@@ -481,9 +481,10 @@
// -> CODE#0023
// -> DESC="IT project files (.itp)"
- for(UINT i = 0 ; i < MAX_INSTRUMENTS ; i++){
+ for(UINT i = 0; i < MAX_INSTRUMENTS; i++)
+ {
m_szInstrumentPath[i][0] = '\0';
- instrumentModified[i] = FALSE;
+ instrumentModified[i] = false;
}
// -! NEW_FEATURE#0023
@@ -3137,7 +3138,7 @@
const CModSpecifications& CSoundFile::GetModSpecifications(const MODTYPE type)
//----------------------------------------------------------------------------
{
- const CModSpecifications* p = 0;
+ const CModSpecifications* p = nullptr;
SetModSpecsPointer(p, type);
return *p;
}
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2010-07-04 14:41:38 UTC (rev 635)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2010-07-10 12:03:54 UTC (rev 636)
@@ -949,7 +949,7 @@
public:
int getVolEnvValueFromPosition(int position, MODINSTRUMENT* pIns);
- void resetEnvelopes(MODCHANNEL* pChn, int envToReset = ENV_RESET_ALL);
+ void resetEnvelopes(MODCHANNEL* pChn, enmResetEnv envToReset = ENV_RESET_ALL);
void SetDefaultInstrumentValues(MODINSTRUMENT *pIns);
private:
UINT __cdecl GetChannelPlugin(UINT nChan, bool respectMutes);
Modified: trunk/OpenMPT/soundlib/load_j2b.cpp
===================================================================
--- trunk/OpenMPT/soundlib/load_j2b.cpp 2010-07-04 14:41:38 UTC (rev 635)
+++ trunk/OpenMPT/soundlib/load_j2b.cpp 2010-07-10 12:03:54 UTC (rev 636)
@@ -217,7 +217,7 @@
ASSERT_CAN_READ(1);
- ROWINDEX nRows = lpStream[0] + 1;
+ ROWINDEX nRows = CLAMP(lpStream[0] + 1, 1, MAX_PATTERN_ROWS);
if(pSndFile == nullptr || pSndFile->Patterns.Insert(nPat, nRows))
return false;
@@ -610,7 +610,7 @@
Samples[nSmp].nPan = smpchunk->pan << 2;
Samples[nSmp].nVolume = smpchunk->volume << 2;
Samples[nSmp].nGlobalVol = 64;
- Samples[nSmp].nLength = LittleEndian(smpchunk->length);
+ Samples[nSmp].nLength = min(LittleEndian(smpchunk->length), MAX_SAMPLE_LENGTH);
Samples[nSmp].nLoopStart = LittleEndian(smpchunk->loopstart);
Samples[nSmp].nLoopEnd = LittleEndian(smpchunk->loopend);
Samples[nSmp].nC5Speed = LittleEndian(smpchunk->samplerate);
@@ -731,7 +731,7 @@
Samples[nSmp].nPan = LittleEndianW(smpchunk->pan) * 256 / 32767;
Samples[nSmp].nVolume = LittleEndianW(smpchunk->volume) * 256 / 32767;
Samples[nSmp].nGlobalVol = 64;
- Samples[nSmp].nLength = LittleEndian(smpchunk->length);
+ Samples[nSmp].nLength = min(LittleEndian(smpchunk->length), MAX_SAMPLE_LENGTH);
Samples[nSmp].nLoopStart = LittleEndian(smpchunk->loopstart);
Samples[nSmp].nLoopEnd = LittleEndian(smpchunk->loopend);
Samples[nSmp].nC5Speed = LittleEndian(smpchunk->samplerate);
Modified: trunk/OpenMPT/soundlib/patternContainer.h
===================================================================
--- trunk/OpenMPT/soundlib/patternContainer.h 2010-07-04 14:41:38 UTC (rev 635)
+++ trunk/OpenMPT/soundlib/patternContainer.h 2010-07-10 12:03:54 UTC (rev 636)
@@ -35,7 +35,7 @@
void ClearPatterns() {m_Patterns.assign(m_Patterns.size(), MODPATTERN(*this));}
//Insert (default)pattern to given position. If pattern already exists at that position,
- //ignoring request.
+ //ignoring request. Returns true on failure, false otherwise.
bool Insert(const PATTERNINDEX index, const ROWINDEX rows);
//Insert pattern to position with the lowest index, and return that index, PATTERNINDEX_INVALID
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-07-04 14:41:45
|
Revision: 635
http://modplug.svn.sourceforge.net/modplug/?rev=635&view=rev
Author: saga-games
Date: 2010-07-04 14:41:38 +0000 (Sun, 04 Jul 2010)
Log Message:
-----------
[Imp] Instrument Editor / XM Saver: For XM, allow fadeout values up to 32767 again, as FT2 can actually handle them (and other apps like Milky support them as well)
[New] Sample Editor: It's not also possible to create sample selections using shift+click.
[Ref] A bit of refactoring
Modified Paths:
--------------
trunk/OpenMPT/mptrack/Ctrl_ins.cpp
trunk/OpenMPT/mptrack/View_smp.cpp
trunk/OpenMPT/soundlib/Load_xm.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/Sndfile.h
Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2010-07-01 21:47:33 UTC (rev 634)
+++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2010-07-04 14:41:38 UTC (rev 635)
@@ -183,13 +183,14 @@
if ((pIns) && (nPos >= 0) && (nPos < NOTE_MAX) && (pIns->NoteMap[nPos]))
{
UINT n = pIns->NoteMap[nPos];
- if (n == NOTE_KEYOFF) strcpy(s, "==="); else
- if (n == NOTE_NOTECUT) strcpy(s, "^^^"); else
- if (n <= NOTE_MAX)
+ if(n < NOTE_MIN_SPECIAL)
{
string temp = pSndFile->GetNoteName(n, m_nInstrument);
temp.resize(4);
wsprintf(s, "%s", temp.c_str());
+ } else
+ {
+ strcpy(s, szSpecialNoteNames[pIns->NoteMap[n] - NOTE_MIN_SPECIAL]);
}
}
FillRect(hdc, &rect, (bHighLight) ? CMainFrame::brushHighLight : CMainFrame::brushWindow);
@@ -658,7 +659,7 @@
case VK_TAB:
return true;
case VK_RETURN:
- if (m_pModDoc)
+ if (m_pModDoc && m_pModDoc->GetSoundFile())
{
MODINSTRUMENT *pIns = m_pModDoc->GetSoundFile()->Instruments[m_nInstrument];
if(pIns)
@@ -680,20 +681,24 @@
return false;
}
+
void CNoteMapWnd::PlayNote(int note)
+//----------------------------------
{
- if (m_nPlayingNote >=0) return; //no polyphony in notemap window
+ if(m_nPlayingNote >= 0) return; //no polyphony in notemap window
m_pModDoc->PlayNote(note, m_nInstrument, 0, FALSE);
- m_nPlayingNote=note;
+ m_nPlayingNote = note;
}
+
void CNoteMapWnd::StopNote(int note = -1)
+//----------------------------------
{
- if (note<0) note = m_nPlayingNote;
- if (note<0) return;
+ if(note < 0) note = m_nPlayingNote;
+ if(note < 0) return;
m_pModDoc->NoteOff(note, TRUE, m_nInstrument);
- m_nPlayingNote=-1;
+ m_nPlayingNote = -1;
}
//end rewbs.customKeys
@@ -872,7 +877,8 @@
m_SpinMidiBK.SetRange(0, 128);
// Midi Channel
//rewbs.instroVSTi: we no longer combine midi chan and FX in same cbbox
- for (UINT ich=0; ich<17; ich++) {
+ for (UINT ich=0; ich<17; ich++)
+ {
UINT n = 0;
s[0] = 0;
if (!ich) { strcpy(s, "None"); n=0; }
@@ -1115,7 +1121,7 @@
m_SpinFadeOut.EnableWindow(bITandXM);
if(m_pSndFile->m_nType & MOD_TYPE_XM)
- m_SpinFadeOut.SetRange(0, 4095);
+ m_SpinFadeOut.SetRange(0, 32767);
else
m_SpinFadeOut.SetRange(0, 8192);
@@ -1768,9 +1774,9 @@
if ((!IsLocked()) && (pIns))
{
int nVol = GetDlgItemInt(IDC_EDIT7);
- if (nVol < 0) nVol = 0;
- if (nVol > 16384) nVol = 16384;
- if (nVol != (int)pIns->nFadeOut)
+ nVol = CLAMP(nVol, 0, 32767);
+
+ if(nVol != (int)pIns->nFadeOut)
{
pIns->nFadeOut = nVol;
m_pModDoc->SetModified();
Modified: trunk/OpenMPT/mptrack/View_smp.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_smp.cpp 2010-07-01 21:47:33 UTC (rev 634)
+++ trunk/OpenMPT/mptrack/View_smp.cpp 2010-07-04 14:41:38 UTC (rev 635)
@@ -1340,35 +1340,45 @@
if ((m_dwStatus & SMPSTATUS_MOUSEDRAG) || (!pModDoc)) return;
pSndFile = pModDoc->GetSoundFile();
len = pSndFile->Samples[m_nSample].nLength;
- if (len)
+ if (!len)
+ return;
+
+ m_dwStatus |= SMPSTATUS_MOUSEDRAG;
+ SetFocus();
+ SetCapture();
+ bool oldsel = (m_dwBeginSel != m_dwEndSel) ? true : false;
+
+ // shift + click = update selection
+ if(CMainFrame::GetInputHandler()->ShiftPressed())
{
- m_dwStatus |= SMPSTATUS_MOUSEDRAG;
- SetFocus();
- SetCapture();
- BOOL oldsel = (m_dwBeginSel != m_dwEndSel) ? TRUE : FALSE;
+ oldsel = true;
+ m_dwEndDrag = ScreenToSample(point.x);
+ SetCurSel(m_dwBeginDrag, m_dwEndDrag);
+ } else
+ {
m_dwBeginDrag = ScreenToSample(point.x);
if (m_dwBeginDrag >= len) m_dwBeginDrag = len-1;
m_dwEndDrag = m_dwBeginDrag;
- if (oldsel) SetCurSel(m_dwBeginDrag, m_dwEndDrag);
- // set initial point for sample drawing
- if (m_bDrawingEnabled)
- {
- pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_replace);
- if(pSndFile->Samples[m_nSample].GetElementarySampleSize() == 2)
- SetInitialDrawPoint<int16, uint16>(pSndFile->Samples[m_nSample].pSample, point);
- else if(pSndFile->Samples[m_nSample].GetElementarySampleSize() == 1)
- SetInitialDrawPoint<int8, uint8>(pSndFile->Samples[m_nSample].pSample, point);
+ }
+ if (oldsel) SetCurSel(m_dwBeginDrag, m_dwEndDrag);
+ // set initial point for sample drawing
+ if (m_bDrawingEnabled)
+ {
+ pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_replace);
+ if(pSndFile->Samples[m_nSample].GetElementarySampleSize() == 2)
+ SetInitialDrawPoint<int16, uint16>(pSndFile->Samples[m_nSample].pSample, point);
+ else if(pSndFile->Samples[m_nSample].GetElementarySampleSize() == 1)
+ SetInitialDrawPoint<int8, uint8>(pSndFile->Samples[m_nSample].pSample, point);
- InvalidateSample();
- pModDoc->SetModified();
- }
- else
- {
- // ctrl + click = play from cursor pos
- if(CMainFrame::GetInputHandler()->CtrlPressed())
- PlayNote(NOTE_MIDDLEC, ScreenToSample(point.x));
- }
+ InvalidateSample();
+ pModDoc->SetModified();
}
+ else
+ {
+ // ctrl + click = play from cursor pos
+ if(CMainFrame::GetInputHandler()->CtrlPressed())
+ PlayNote(NOTE_MIDDLEC, ScreenToSample(point.x));
+ }
}
@@ -1822,6 +1832,7 @@
if (pSmp->uFlags & (CHN_LOOP|CHN_SUSTAINLOOP))
{
WAVESAMPLERINFO *psmpl = (WAVESAMPLERINFO *)psh;
+ MemsetZero(psmpl->wsiLoops);
if (pSmp->uFlags & CHN_SUSTAINLOOP)
{
psmpl->wsiHdr.dwSampleLoops = 2;
Modified: trunk/OpenMPT/soundlib/Load_xm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_xm.cpp 2010-07-01 21:47:33 UTC (rev 634)
+++ trunk/OpenMPT/soundlib/Load_xm.cpp 2010-07-04 14:41:38 UTC (rev 635)
@@ -956,7 +956,7 @@
{
memcpy(xmih.name, pIns->name, 22);
xmih.type = pIns->nMidiProgram;
- xmsh.volfade = LittleEndianW(min(pIns->nFadeOut, 0xFFF)); // FFF is maximum in FT2
+ xmsh.volfade = LittleEndianW(min(pIns->nFadeOut, 0x7FFF)); // FFF is maximum in the FT2 GUI, but it can also accept other values. MilkyTracker just allows 0...4095 and 32767 ("cut")
xmsh.vnum = (BYTE)pIns->VolEnv.nNodes;
xmsh.pnum = (BYTE)pIns->PanEnv.nNodes;
if (xmsh.vnum > 12) xmsh.vnum = 12;
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2010-07-01 21:47:33 UTC (rev 634)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2010-07-04 14:41:38 UTC (rev 635)
@@ -3038,17 +3038,16 @@
return 0;
}
-string CSoundFile::GetNoteName(const CTuning::NOTEINDEXTYPE& note, const int inst) const
+string CSoundFile::GetNoteName(const CTuning::NOTEINDEXTYPE& note, const INSTRUMENTINDEX inst) const
//----------------------------------------------------------------------------------
{
- if(inst >= MAX_INSTRUMENTS || inst < -1 || note < 1 || note > NOTE_MAX) return "BUG";
- if(inst == -1)
- return szDefaultNoteNames[note-1];
-
- if(m_nType == MOD_TYPE_MPT && Instruments[inst] && Instruments[inst]->pTuning)
- return Instruments[inst]->pTuning->GetNoteName(note-NOTE_MIDDLEC);
+ if((inst >= MAX_INSTRUMENTS && inst != INSTRUMENTINDEX_INVALID) || note < 1 || note > NOTE_MAX) return "BUG";
+
+ // For MPTM instruments with custom tuning, find the appropriate note name. Else, use default note names.
+ if(inst != INSTRUMENTINDEX_INVALID && m_nType == MOD_TYPE_MPT && Instruments[inst] && Instruments[inst]->pTuning)
+ return Instruments[inst]->pTuning->GetNoteName(note - NOTE_MIDDLEC);
else
- return szDefaultNoteNames[note-1];
+ return szDefaultNoteNames[note - 1];
}
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2010-07-01 21:47:33 UTC (rev 634)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2010-07-04 14:41:38 UTC (rev 635)
@@ -99,8 +99,8 @@
INSTRUMENTENVELOPE PanEnv;
INSTRUMENTENVELOPE PitchEnv;
- BYTE NoteMap[128];
- WORD Keyboard[128];
+ BYTE NoteMap[128]; // Note mapping, f.e. C-5 => D-5
+ WORD Keyboard[128]; // Sample mapping, f.e. C-5 => Sample 1
BYTE nNNA;
BYTE nDCT;
@@ -495,7 +495,7 @@
static CTuningCollection& GetLocalTunings() {return *s_pTuningsSharedLocal;}
CTuningCollection& GetTuneSpecificTunings() {return *m_pTuningsTuneSpecific;}
- std::string GetNoteName(const int16&, const int inst = -1) const;
+ std::string GetNoteName(const int16&, const INSTRUMENTINDEX inst = INSTRUMENTINDEX_INVALID) const;
private:
CTuningCollection* m_pTuningsTuneSpecific;
static CTuningCollection* s_pTuningsSharedBuiltIn;
@@ -724,13 +724,13 @@
void SaveExtendedInstrumentProperties(MODINSTRUMENT *instruments[], UINT nInstruments, FILE* f);
void SaveExtendedSongProperties(FILE* f);
void LoadExtendedSongProperties(const MODTYPE modtype, LPCBYTE ptr, const LPCBYTE startpos, const size_t seachlimit, bool* pInterpretMptMade = nullptr);
+#endif // MODPLUG_NO_FILESAVE
// Reads extended instrument properties(XM/IT/MPTM).
// If no errors occur and song extension tag is found, returns pointer to the beginning
// of the tag, else returns NULL.
LPCBYTE LoadExtendedInstrumentProperties(const LPCBYTE pStart, const LPCBYTE pEnd, bool* pInterpretMptMade = nullptr);
-#endif // MODPLUG_NO_FILESAVE
// MOD Convert function
MODTYPE GetBestSaveFormat() const;
MODTYPE GetSaveFormats() const;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-07-01 21:47:40
|
Revision: 634
http://modplug.svn.sourceforge.net/modplug/?rev=634&view=rev
Author: saga-games
Date: 2010-07-01 21:47:33 +0000 (Thu, 01 Jul 2010)
Log Message:
-----------
[Fix] S3M Compatibility: SD0 was not ignored properly when there was a row delay effect on the same row. Now it should be ignored in any case.
[Imp] Treeview: Don't ask for deleting for order items, as it was a bit annoying restoring them isn't a difficult task anyway.
[Imp] Sample Editor: When using the spin buttons for finetune, the finetune value is always in/decreased by 16 in MOD format. Not perfect yet, but at least better than before.
[Mod] Changes some keyboard manager shortcut names
[Mod] OpenMPT: Version is now 1.18.02.02
[Ref] Some minor code changes
Modified Paths:
--------------
trunk/OpenMPT/mptrack/CommandSet.cpp
trunk/OpenMPT/mptrack/Ctrl_seq.cpp
trunk/OpenMPT/mptrack/Ctrl_smp.cpp
trunk/OpenMPT/mptrack/View_tre.cpp
trunk/OpenMPT/mptrack/version.h
trunk/OpenMPT/soundlib/Load_gdm.cpp
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/load_j2b.cpp
Modified: trunk/OpenMPT/mptrack/CommandSet.cpp
===================================================================
--- trunk/OpenMPT/mptrack/CommandSet.cpp 2010-06-26 14:04:46 UTC (rev 633)
+++ trunk/OpenMPT/mptrack/CommandSet.cpp 2010-07-01 21:47:33 UTC (rev 634)
@@ -1822,7 +1822,7 @@
commands[kcFileSaveAsMP3].isDummy = false;
commands[kcFileSaveMidi].UID = 1353;
- commands[kcFileSaveMidi].Message = "File/Export to Midi";
+ commands[kcFileSaveMidi].Message = "File/Export as MIDI";
commands[kcFileSaveMidi].isHidden = false;
commands[kcFileSaveMidi].isDummy = false;
@@ -2266,7 +2266,7 @@
commands[kcChangeLoopStatus].Message = "Toggle loop pattern";
commands[kcFileExportCompat].UID = 1777;
- commands[kcFileExportCompat].Message = "File/Export to standard IT/XM";
+ commands[kcFileExportCompat].Message = "File/Export to standard IT/XM/S3M";
commands[kcFileExportCompat].isHidden = false;
commands[kcFileExportCompat].isDummy = false;
Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2010-06-26 14:04:46 UTC (rev 633)
+++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2010-07-01 21:47:33 UTC (rev 634)
@@ -316,7 +316,7 @@
pSndFile->m_nCurrentPattern = m_nScrollPos;
pSndFile->SetCurrentOrder(m_nScrollPos);
pSndFile->m_dwSongFlags |= dwPaused;
- if (!(dwPaused & SONG_PATTERNLOOP)) pSndFile->GetLength(TRUE);
+ if (!(dwPaused & SONG_PATTERNLOOP)) pSndFile->GetLength(TRUE); // update channel parameters
if (bIsPlaying) pMainFrm->ResetNotificationBuffer();
END_CRITICAL();
}
Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2010-06-26 14:04:46 UTC (rev 633)
+++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2010-07-01 21:47:33 UTC (rev 634)
@@ -2956,7 +2956,7 @@
m_EditFineTune.SetWindowText(s);
} else
{
- LONG d = CLAMP(pSmp->nFineTune + pos, -128, 127);
+ LONG d = CLAMP(pSmp->nFineTune + pos * ((m_pSndFile->GetType() & MOD_TYPE_MOD) ? 16 : 1), -128, 127);
pSmp->nFineTune = (signed char)d;
wsprintf(s, "%d", d);
m_EditFineTune.SetWindowText(s);
Modified: trunk/OpenMPT/mptrack/View_tre.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_tre.cpp 2010-06-26 14:04:46 UTC (rev 633)
+++ trunk/OpenMPT/mptrack/View_tre.cpp 2010-07-01 21:47:33 UTC (rev 634)
@@ -1411,8 +1411,6 @@
break;
case MODITEM_ORDER:
- wsprintf(s, _T("Delete order %d?"), modItemID & 0xFFFF);
- if(MessageBox(s, _T("Confirmation"), MB_YESNO | MB_DEFBUTTON2) == IDNO) break;
if ((pModDoc) && (pModDoc->RemoveOrder((SEQUENCEINDEX)(modItemID >> 16), (ORDERINDEX)(modItemID & 0xFFFF))))
{
pModDoc->UpdateAllViews(NULL, HINT_MODSEQUENCE, NULL);
Modified: trunk/OpenMPT/mptrack/version.h
===================================================================
--- trunk/OpenMPT/mptrack/version.h 2010-06-26 14:04:46 UTC (rev 633)
+++ trunk/OpenMPT/mptrack/version.h 2010-07-01 21:47:33 UTC (rev 634)
@@ -15,7 +15,7 @@
#define VER_MAJORMAJOR 1
#define VER_MAJOR 18
#define VER_MINOR 02
-#define VER_MINORMINOR 01
+#define VER_MINORMINOR 02
//Creates version number from version parts that appears in version string.
//For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of
Modified: trunk/OpenMPT/soundlib/Load_gdm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_gdm.cpp 2010-06-26 14:04:46 UTC (rev 633)
+++ trunk/OpenMPT/soundlib/Load_gdm.cpp 2010-07-01 21:47:33 UTC (rev 634)
@@ -71,8 +71,7 @@
#pragma pack()
-#define GDMHeader_Origin_Count 9
-static MODTYPE GDMHeader_Origin[GDMHeader_Origin_Count] =
+static 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
};
@@ -94,7 +93,7 @@
return false;
// 1-MOD, 2-MTM, 3-S3M, 4-669, 5-FAR, 6-ULT, 7-STM, 8-MED
- m_nType = GDMHeader_Origin[pHeader->FormOrigin % GDMHeader_Origin_Count];
+ m_nType = GDMHeader_Origin[pHeader->FormOrigin % ARRAYELEMCOUNT(GDMHeader_Origin)];
if(m_nType == MOD_TYPE_NONE)
return false;
@@ -175,7 +174,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.mod)
+ // 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)
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2010-06-26 14:04:46 UTC (rev 633)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2010-07-01 21:47:33 UTC (rev 634)
@@ -1293,7 +1293,7 @@
nStartTick = 1;
//ST3 ignores notes with SD0 completely
else if(GetType() == MOD_TYPE_S3M)
- nStartTick = m_nMusicSpeed;
+ nStartTick = UINT_MAX;
}
//IT compatibility 08. Handling of out-of-range delay command.
Modified: trunk/OpenMPT/soundlib/load_j2b.cpp
===================================================================
--- trunk/OpenMPT/soundlib/load_j2b.cpp 2010-06-26 14:04:46 UTC (rev 633)
+++ trunk/OpenMPT/soundlib/load_j2b.cpp 2010-07-01 21:47:33 UTC (rev 634)
@@ -467,6 +467,8 @@
else return false;
dwMemPos += 4;
m_nChannels = 0;
+ m_nSamples = 0;
+ m_nInstruments = 0;
// go through all chunks now
while(dwMemPos < dwMemLength)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-06-26 14:04:53
|
Revision: 633
http://modplug.svn.sourceforge.net/modplug/?rev=633&view=rev
Author: saga-games
Date: 2010-06-26 14:04:46 +0000 (Sat, 26 Jun 2010)
Log Message:
-----------
[Imp] General Tab: To prevent OpenMPT from hanging while switching between plugins (or switching to the general tab), the preset box is only filled when it gets the focus. This makes working with Synth1 a lot easier, since it has an insane amount of presets... :)
[Mod] General Tab: Changed tab order of the lower panel (now it's more logical to me)
Modified Paths:
--------------
trunk/OpenMPT/mptrack/View_gen.cpp
trunk/OpenMPT/mptrack/View_gen.h
trunk/OpenMPT/mptrack/mptrack.rc
Modified: trunk/OpenMPT/mptrack/View_gen.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_gen.cpp 2010-06-25 21:00:37 UTC (rev 632)
+++ trunk/OpenMPT/mptrack/View_gen.cpp 2010-06-26 14:04:46 UTC (rev 633)
@@ -84,6 +84,7 @@
// -> CODE#0002
// -> DESC="VST plugins presets"
ON_CBN_SELCHANGE(IDC_COMBO8, OnProgramChanged)
+ ON_CBN_SETFOCUS(IDC_COMBO8, OnFillProgramCombo)
// -! NEW_FEATURE#0002
// -> CODE#0028
@@ -482,30 +483,18 @@
// -> CODE#0002
// -> DESC="VST plugins presets"
- CHAR s2[128];
- //UINT k = 0, nProg = min(pVstPlugin->GetNumPrograms(), 256); //Limit number of progs to 256 because of insane plugs like synth1
- UINT k = 0, nProg = pVstPlugin->GetNumPrograms();
+ // For now, only display the "current" preset.
+ // This prevents the program from hanging when switching between plugin slots or
+ // switching to the general tab and the first plugin in the list has a lot of presets.
+ // Some plugins like Synth1 have so many presets that this *does* indeed make a difference,
+ // even on fairly modern CPUs. The rest of the presets are just added when the combo box
+ // gets the focus, i.e. just when they're needed.
m_CbnPreset.SetRedraw(FALSE);
m_CbnPreset.ResetContent();
- wsprintf(s2, "current");
- m_CbnPreset.SetItemData(m_CbnPreset.AddString(s2), 0);
- for (i=0; i<nProg; i++)
- {
- k = 0;
- pVstPlugin->GetProgramNameIndexed(i, 0, sname);
-
- if(sname[0] < 32)
- wsprintf(s2, "%02X - Program %d",i,i);
- else{
- while(k < sizeof(sname)-1 && sname[k] != 0 && sname[k] < 'a' && sname[k] < 'z' && sname[k] < 'A' && sname[k] < 'Z') k++;
- wsprintf(s2, "%02X - %s",i,&sname[k]);
- }
-
- m_CbnPreset.SetItemData(m_CbnPreset.AddString(s2), i+1);
- }
- m_nCurrentPreset = 0;
+ m_CbnPreset.SetItemData(m_CbnPreset.AddString(_T("current")), 0);
m_CbnPreset.SetRedraw(TRUE);
m_CbnPreset.SetCurSel(0);
+
m_sbValue.EnableWindow(TRUE);
m_sbDryRatio.EnableWindow(TRUE);
::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT14), TRUE);
@@ -519,7 +508,7 @@
m_nCurrentParam = 0;
// -> CODE#0002
// -> DESC="VST plugins presets"
- CHAR s2[32];
+ CHAR s2[16];
m_CbnPreset.SetRedraw(FALSE);
m_CbnPreset.ResetContent();
wsprintf(s2, "none");
@@ -1485,6 +1474,7 @@
}
+
void CViewGlobals::OnClonePlug()
//------------------------------
{
@@ -1492,6 +1482,51 @@
}
+// The preset box is only filled when it gets the focus (done here).
+void CViewGlobals::OnFillProgramCombo()
+//-------------------------------------
+{
+ // no need to fill it again.
+ if(m_CbnPreset.GetCount() > 1)
+ return;
+
+ if(GetDocument() == nullptr) return;
+ CSoundFile *pSndFile = GetDocument()->GetSoundFile();
+ if(pSndFile == nullptr) return;
+ if (m_nCurrentPlugin >= MAX_MIXPLUGINS) m_nCurrentPlugin = 0;
+ PSNDMIXPLUGIN pPlugin = &(pSndFile->m_MixPlugins[m_nCurrentPlugin]);
+ CVstPlugin *pVstPlugin = (pPlugin->pMixPlugin) ? (CVstPlugin *)pPlugin->pMixPlugin : nullptr;
+ if(pVstPlugin == nullptr) return;
+
+ CHAR sname[64];
+ CHAR s2[128];
+ UINT nProg = pVstPlugin->GetNumPrograms();
+ m_CbnPreset.SetRedraw(FALSE);
+ m_CbnPreset.ResetContent();
+ wsprintf(s2, _T("current"));
+ m_CbnPreset.SetItemData(m_CbnPreset.AddString(s2), 0);
+ for (UINT i = 0; i < nProg; i++)
+ {
+ pVstPlugin->GetProgramNameIndexed(i, 0, sname);
+
+ if(sname[0] < ' ')
+ {
+ wsprintf(s2, "%02X - Program %d", i, i);
+ } else
+ {
+ size_t k = 0;
+ while(k < ARRAYELEMCOUNT(sname) - 1 && sname[k] <= ' ') k++;
+ wsprintf(s2, "%02X - %s",i,&sname[k]);
+ }
+
+ m_CbnPreset.SetItemData(m_CbnPreset.AddString(s2), i+1);
+ }
+ m_nCurrentPreset = 0;
+ m_CbnPreset.SetRedraw(TRUE);
+ m_CbnPreset.SetCurSel(0);
+}
+
+
// This is used for retrieving the correct background colour for the
// frames on the general tab when using WinXP Luna or Vista/Win7 Aero.
typedef HRESULT (__stdcall * ETDT)(HWND, DWORD);
Modified: trunk/OpenMPT/mptrack/View_gen.h
===================================================================
--- trunk/OpenMPT/mptrack/View_gen.h 2010-06-25 21:00:37 UTC (rev 632)
+++ trunk/OpenMPT/mptrack/View_gen.h 2010-06-26 14:04:46 UTC (rev 633)
@@ -115,6 +115,7 @@
afx_msg void OnParamChanged();
// -> CODE#0002
// -> DESC="VST plugins presets"
+ afx_msg void OnFillProgramCombo();
afx_msg void OnProgramChanged();
afx_msg void OnLoadParam();
afx_msg void OnSaveParam();
Modified: trunk/OpenMPT/mptrack/mptrack.rc
===================================================================
--- trunk/OpenMPT/mptrack/mptrack.rc 2010-06-25 21:00:37 UTC (rev 632)
+++ trunk/OpenMPT/mptrack/mptrack.rc 2010-06-26 14:04:46 UTC (rev 633)
@@ -755,102 +755,102 @@
END
IDD_VIEW_GLOBALS DIALOGEX 0, 0, 471, 337
-STYLE DS_SETFONT | DS_3DLOOK | WS_CHILD
+STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- GROUPBOX "Channel 1",IDC_TEXT1,5,18,99,157
+ CONTROL "",IDC_TABCTRL1,"SysTabControl32",0x0,0,0,412,14
EDITTEXT IDC_EDIT9,10,30,89,12,ES_AUTOHSCROLL
- LTEXT "Initial Volume:",IDC_STATIC,10,48,45,8
- LTEXT "Initial Pan:",IDC_STATIC,10,89,34,8
- CONTROL "Slider2",IDC_SLIDER1,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | WS_TABSTOP,10,59,92,22
- CONTROL "Slider2",IDC_SLIDER2,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | WS_TABSTOP,10,100,92,22
+ EDITTEXT IDC_EDIT10,113,30,89,12,ES_AUTOHSCROLL
+ EDITTEXT IDC_EDIT11,216,30,89,12,ES_AUTOHSCROLL
+ EDITTEXT IDC_EDIT12,319,30,89,12,ES_AUTOHSCROLL
EDITTEXT IDC_EDIT1,63,46,36,12,ES_NUMBER
CONTROL "Spin1",IDC_SPIN1,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY,95,45,11,14
+ EDITTEXT IDC_EDIT3,166,46,36,12,ES_NUMBER
+ CONTROL "Spin1",IDC_SPIN3,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY,198,45,11,14
+ EDITTEXT IDC_EDIT5,269,46,36,12,ES_NUMBER
+ CONTROL "Spin1",IDC_SPIN5,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY,301,45,11,14
+ EDITTEXT IDC_EDIT7,372,46,36,12,ES_NUMBER
+ CONTROL "Spin1",IDC_SPIN7,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY,396,45,11,14
+ CONTROL "Slider2",IDC_SLIDER1,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | WS_TABSTOP,10,59,92,22
+ CONTROL "Slider2",IDC_SLIDER3,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | WS_TABSTOP,113,59,92,22
+ CONTROL "Slider2",IDC_SLIDER5,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | WS_TABSTOP,216,59,92,22
+ CONTROL "Slider2",IDC_SLIDER7,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | WS_TABSTOP,319,59,92,22
EDITTEXT IDC_EDIT2,63,88,36,12,ES_NUMBER
CONTROL "Spin1",IDC_SPIN2,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY,95,86,11,14
+ EDITTEXT IDC_EDIT4,166,88,36,12,ES_NUMBER
+ CONTROL "Spin1",IDC_SPIN4,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY,198,86,11,14
+ EDITTEXT IDC_EDIT6,269,88,36,12,ES_NUMBER
+ CONTROL "Spin1",IDC_SPIN6,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY,301,86,11,14
+ EDITTEXT IDC_EDIT8,372,88,36,12,ES_NUMBER
+ CONTROL "Spin1",IDC_SPIN8,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY,401,86,11,14
+ CONTROL "Slider2",IDC_SLIDER2,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | WS_TABSTOP,10,100,92,22
+ CONTROL "Slider2",IDC_SLIDER4,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | WS_TABSTOP,113,100,92,22
+ CONTROL "Slider2",IDC_SLIDER6,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | WS_TABSTOP,216,100,92,22
+ CONTROL "Slider2",IDC_SLIDER8,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | WS_TABSTOP,319,100,92,22
CONTROL "Mute",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | WS_TABSTOP,13,129,42,12
CONTROL "Surround",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | WS_TABSTOP,57,129,42,12
- COMBOBOX IDC_COMBO1,10,155,89,99,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- LTEXT "Effect:",IDC_STATIC,10,146,29,8
- GROUPBOX "Channel 2",IDC_TEXT2,108,18,99,157
- EDITTEXT IDC_EDIT10,113,30,89,12,ES_AUTOHSCROLL
- LTEXT "Initial Volume:",IDC_STATIC,113,48,45,8
- LTEXT "Initial Pan:",IDC_STATIC,113,89,34,8
- CONTROL "Slider2",IDC_SLIDER3,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | WS_TABSTOP,113,59,92,22
- CONTROL "Slider2",IDC_SLIDER4,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | WS_TABSTOP,113,100,92,22
- EDITTEXT IDC_EDIT3,166,46,36,12,ES_NUMBER
- CONTROL "Spin1",IDC_SPIN3,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY,198,45,11,14
- EDITTEXT IDC_EDIT4,166,88,36,12,ES_NUMBER
- CONTROL "Spin1",IDC_SPIN4,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY,198,86,11,14
CONTROL "Mute",IDC_CHECK3,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | WS_TABSTOP,116,129,42,12
CONTROL "Surround",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | WS_TABSTOP,159,129,42,12
- COMBOBOX IDC_COMBO2,113,155,89,99,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- LTEXT "Effect:",IDC_STATIC,113,146,29,8
- GROUPBOX "Channel 3",IDC_TEXT3,211,18,99,157
- EDITTEXT IDC_EDIT11,216,30,89,12,ES_AUTOHSCROLL
- LTEXT "Initial Volume:",IDC_STATIC,216,48,45,8
- LTEXT "Initial Pan:",IDC_STATIC,216,89,34,8
- CONTROL "Slider2",IDC_SLIDER5,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | WS_TABSTOP,216,59,92,22
- CONTROL "Slider2",IDC_SLIDER6,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | WS_TABSTOP,216,100,92,22
- EDITTEXT IDC_EDIT5,269,46,36,12,ES_NUMBER
- CONTROL "Spin1",IDC_SPIN5,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY,301,45,11,14
- EDITTEXT IDC_EDIT6,269,88,36,12,ES_NUMBER
- CONTROL "Spin1",IDC_SPIN6,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY,301,86,11,14
CONTROL "Mute",IDC_CHECK5,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | WS_TABSTOP,219,129,42,12
CONTROL "Surround",IDC_CHECK6,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | WS_TABSTOP,262,129,42,12
- COMBOBOX IDC_COMBO3,216,155,89,99,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- LTEXT "Effect:",IDC_STATIC,216,146,29,8
- EDITTEXT IDC_EDIT12,319,30,89,12,ES_AUTOHSCROLL
- LTEXT "Initial Volume:",IDC_STATIC,319,48,45,8
- LTEXT "Initial Pan:",IDC_STATIC,319,89,34,8
- CONTROL "Slider2",IDC_SLIDER7,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | WS_TABSTOP,319,59,92,22
- CONTROL "Slider2",IDC_SLIDER8,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | WS_TABSTOP,319,100,92,22
- EDITTEXT IDC_EDIT7,372,46,36,12,ES_NUMBER
- CONTROL "Spin1",IDC_SPIN7,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY,396,45,11,14
- EDITTEXT IDC_EDIT8,372,88,36,12,ES_NUMBER
- CONTROL "Spin1",IDC_SPIN8,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY,401,86,11,14
CONTROL "Mute",IDC_CHECK7,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | WS_TABSTOP,322,129,42,12
CONTROL "Surround",IDC_CHECK8,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | WS_TABSTOP,365,129,42,12
+ COMBOBOX IDC_COMBO1,10,155,89,99,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ COMBOBOX IDC_COMBO2,113,155,89,99,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ COMBOBOX IDC_COMBO3,216,155,89,99,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_COMBO4,319,155,89,99,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- LTEXT "Effect:",IDC_STATIC,319,146,29,8
- GROUPBOX "Plugins",IDC_STATIC,5,177,408,131
COMBOBOX IDC_COMBO5,53,191,135,148,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- CTEXT "Display name",IDC_STATIC,263,191,48,13,SS_CENTERIMAGE,WS_EX_STATICEDGE
- EDITTEXT IDC_EDIT13,310,191,96,13,ES_CENTER | ES_AUTOHSCROLL
PUSHBUTTON "Select...",IDC_BUTTON1,193,191,34,13,0,WS_EX_STATICEDGE
PUSHBUTTON "Edit...",IDC_BUTTON2,231,191,27,13,0,WS_EX_STATICEDGE
- CTEXT "Parameter",IDC_STATIC,16,266,43,13,SS_CENTERIMAGE,WS_EX_STATICEDGE
+ PUSHBUTTON "Insert...",IDC_INSERTFXSLOT,154,207,34,13,0,WS_EX_STATICEDGE
+ PUSHBUTTON "Move...",IDC_MOVEFXSLOT,53,207,34,13,0,WS_EX_STATICEDGE
+ PUSHBUTTON "Clone...",IDC_CLONEPLUG,103,207,34,13,NOT WS_VISIBLE,WS_EX_STATICEDGE
+ PUSHBUTTON "<<",IDC_BUTTON5,11,191,18,13,NOT WS_TABSTOP,WS_EX_STATICEDGE
+ PUSHBUTTON ">>",IDC_BUTTON4,32,191,18,13,NOT WS_TABSTOP,WS_EX_STATICEDGE
+ EDITTEXT IDC_EDIT13,310,191,96,13,ES_CENTER | ES_AUTOHSCROLL
+ COMBOBOX IDC_COMBO8,16,239,102,68,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "Load",IDC_BUTTON6,122,239,27,13,0,WS_EX_STATICEDGE
+ PUSHBUTTON "Save",IDC_BUTTON8,154,239,27,13,0,WS_EX_STATICEDGE
COMBOBOX IDC_COMBO6,61,266,122,162,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "ValSld",IDC_SLIDER9,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,16,283,102,14,WS_EX_STATICEDGE
EDITTEXT IDC_EDIT14,121,283,39,14,ES_AUTOHSCROLL
PUSHBUTTON "Set",IDC_BUTTON3,163,283,20,14,0,WS_EX_STATICEDGE
- CTEXT "Output to",IDC_STATIC,245,261,37,13,SS_CENTERIMAGE,WS_EX_STATICEDGE
- COMBOBOX IDC_COMBO7,285,261,117,68,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- CONTROL "",IDC_TEXT6,"Static",SS_LEFTNOWORDWRAP | SS_CENTERIMAGE | WS_GROUP,311,208,96,13,WS_EX_STATICEDGE
- PUSHBUTTON ">>",IDC_BUTTON4,32,191,18,13,NOT WS_TABSTOP,WS_EX_STATICEDGE
- PUSHBUTTON "<<",IDC_BUTTON5,11,191,18,13,NOT WS_TABSTOP,WS_EX_STATICEDGE
CONTROL "Master",IDC_CHECK9,"Button",BS_AUTOCHECKBOX | BS_FLAT | WS_TABSTOP,199,242,46,10
CONTROL "Bypass",IDC_CHECK10,"Button",BS_AUTOCHECKBOX | BS_FLAT | WS_TABSTOP,199,256,40,10
+ CONTROL "Expand",IDC_CHECK12,"Button",BS_AUTOCHECKBOX | BS_FLAT | WS_TABSTOP,199,271,37,10
CONTROL "Dry mix",IDC_CHECK11,"Button",BS_AUTOCHECKBOX | BS_FLAT | WS_TABSTOP,199,286,37,10
- COMBOBOX IDC_COMBO8,16,239,102,68,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ COMBOBOX IDC_COMBO9,285,241,62,99,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ CONTROL "",IDC_SPIN10,"msctls_updown32",UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS,392,242,9,11
+ COMBOBOX IDC_COMBO7,285,261,117,68,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "",IDC_SLIDER10,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,314,282,88,14,WS_EX_STATICEDGE
- PUSHBUTTON "Load",IDC_BUTTON6,122,239,27,13,0,WS_EX_STATICEDGE
- PUSHBUTTON "Save",IDC_BUTTON8,154,239,27,13,0,WS_EX_STATICEDGE
+ GROUPBOX "Plugins",IDC_STATIC,5,177,408,131
+ GROUPBOX "Channel 1",IDC_TEXT1,5,18,99,157
+ GROUPBOX "Channel 2",IDC_TEXT2,108,18,99,157
+ GROUPBOX "Channel 3",IDC_TEXT3,211,18,99,157
+ GROUPBOX "Channel 4",IDC_TEXT4,314,18,99,157
+ LTEXT "Initial Volume:",IDC_STATIC,10,48,45,8
+ LTEXT "Initial Volume:",IDC_STATIC,113,48,45,8
+ LTEXT "Initial Volume:",IDC_STATIC,216,48,45,8
+ LTEXT "Initial Volume:",IDC_STATIC,319,48,45,8
+ LTEXT "Initial Pan:",IDC_STATIC,10,89,34,8
+ LTEXT "Initial Pan:",IDC_STATIC,113,89,34,8
+ LTEXT "Initial Pan:",IDC_STATIC,216,89,34,8
+ LTEXT "Initial Pan:",IDC_STATIC,319,89,34,8
+ LTEXT "Effect:",IDC_STATIC,10,146,29,8
+ LTEXT "Effect:",IDC_STATIC,113,146,29,8
+ LTEXT "Effect:",IDC_STATIC,216,146,29,8
+ LTEXT "Effect:",IDC_STATIC,319,146,29,8
+ CTEXT "Display name",IDC_STATIC,263,191,48,13,SS_CENTERIMAGE,WS_EX_STATICEDGE
+ CTEXT "Parameter",IDC_STATIC,16,266,43,13,SS_CENTERIMAGE,WS_EX_STATICEDGE
+ CTEXT "Output to",IDC_STATIC,245,261,37,13,SS_CENTERIMAGE,WS_EX_STATICEDGE
+ CONTROL "",IDC_TEXT6,"Static",SS_LEFTNOWORDWRAP | SS_CENTERIMAGE | WS_GROUP,311,208,96,13,WS_EX_STATICEDGE
CTEXT "Wet Dry Ratio",IDC_STATIC8,245,282,65,14,SS_CENTERIMAGE,WS_EX_STATICEDGE
- CONTROL "Expand",IDC_CHECK12,"Button",BS_AUTOCHECKBOX | BS_FLAT | WS_TABSTOP,199,271,37,10
- COMBOBOX IDC_COMBO9,285,241,62,99,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CTEXT "Mix mode",IDC_STATIC,245,241,37,13,SS_CENTERIMAGE,WS_EX_STATICEDGE
- CONTROL "",IDC_SPIN10,"msctls_updown32",UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS,392,242,9,11
LTEXT "Gain: x 1.0",IDC_STATIC2,353,241,34,14,SS_CENTERIMAGE
GROUPBOX "Mix settings",IDC_STATIC,193,226,214,78
GROUPBOX "Factory preset",IDC_STATIC,11,226,177,34
GROUPBOX "",IDC_STATIC,11,255,177,49
CTEXT "I/O Type:",IDC_STATIC,263,208,47,13,SS_CENTERIMAGE,WS_EX_STATICEDGE
- PUSHBUTTON "Move...",IDC_MOVEFXSLOT,53,207,34,13,0,WS_EX_STATICEDGE
- PUSHBUTTON "Clone...",IDC_CLONEPLUG,103,207,34,13,NOT WS_VISIBLE,WS_EX_STATICEDGE
- PUSHBUTTON "Insert...",IDC_INSERTFXSLOT,154,207,34,13,0,WS_EX_STATICEDGE
- GROUPBOX "Channel 4",IDC_TEXT4,314,18,99,157
- CONTROL "",IDC_TABCTRL1,"SysTabControl32",0x0,0,0,412,14
END
IDD_EDIT_FIND DIALOGEX 0, 0, 182, 145
@@ -1071,7 +1071,7 @@
END
IDD_OPTIONS_SOUNDCARD DIALOGEX 0, 0, 272, 276
-STYLE DS_SETFONT | DS_3DLOOK | WS_CHILD | WS_DISABLED | WS_CAPTION
+STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "Sound Card"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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.
|
|
From: <sag...@us...> - 2010-06-24 20:59:06
|
Revision: 631
http://modplug.svn.sourceforge.net/modplug/?rev=631&view=rev
Author: saga-games
Date: 2010-06-24 20:58:59 +0000 (Thu, 24 Jun 2010)
Log Message:
-----------
[Imp] J2B Loader: J2B files with extended instrument settings and multiple samples per instrument work properly now. Such J2B files were not used in the game but have been created by JJ2 players using MOD2J2B. Also made the code more readable + various other small changes.
[Mod] OpenMPT: Version is now 1.18.02.01
Modified Paths:
--------------
trunk/OpenMPT/mptrack/version.h
trunk/OpenMPT/soundlib/load_j2b.cpp
Modified: trunk/OpenMPT/mptrack/version.h
===================================================================
--- trunk/OpenMPT/mptrack/version.h 2010-06-22 18:15:10 UTC (rev 630)
+++ trunk/OpenMPT/mptrack/version.h 2010-06-24 20:58:59 UTC (rev 631)
@@ -15,7 +15,7 @@
#define VER_MAJORMAJOR 1
#define VER_MAJOR 18
#define VER_MINOR 02
-#define VER_MINORMINOR 00
+#define VER_MINORMINOR 01
//Creates version number from version parts that appears in version string.
//For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of
Modified: trunk/OpenMPT/soundlib/load_j2b.cpp
===================================================================
--- trunk/OpenMPT/soundlib/load_j2b.cpp 2010-06-22 18:15:10 UTC (rev 630)
+++ trunk/OpenMPT/soundlib/load_j2b.cpp 2010-06-24 20:58:59 UTC (rev 631)
@@ -4,7 +4,8 @@
* Purpose: Load RIFF AM and RIFF AMFF modules (Galaxy Sound System).
* Notes : J2B is a compressed variant of RIFF AM and RIFF AMFF files used in Jazz Jackrabbit 2.
* It seems like no other game used the AM(FF) format.
- * Authors: Johannes Schultz (OpenMPT port)
+ * RIFF AM is the newer version of the format, generally following the RIFF standard closely.
+ * Authors: Johannes Schultz (OpenMPT port, reverse engineering + loader implementation of the instrument format)
* Chris Moeller (foo_dumb - this is almost a complete port of his code, thanks)
*
*/
@@ -16,6 +17,38 @@
#endif // ZLIB_WINAPI
#include "../zlib/zlib.h"
+// 32-Bit J2B header identifiers
+#define J2BHEAD_MUSE 0x4553554D
+#define J2BHEAD_DEADBEAF 0xAFBEADDE
+#define J2BHEAD_DEADBABE 0xBEBAADDE
+
+// 32-Bit chunk identifiers
+#define AMCHUNKID_RIFF 0x46464952
+#define AMCHUNKID_AMFF 0x46464D41
+#define AMCHUNKID_AM__ 0x20204D41
+#define AMCHUNKID_MAIN 0x4E49414D
+#define AMCHUNKID_INIT 0x54494E49
+#define AMCHUNKID_ORDR 0x5244524F
+#define AMCHUNKID_PATT 0x54544150
+#define AMCHUNKID_INST 0x54534E49
+#define AMCHUNKID_SAMP 0x504D4153
+#define AMCHUNKID_AI__ 0x20204941
+#define AMCHUNKID_AS__ 0x20205341
+
+// Envelope flags
+#define AMENV_ENABLED 0x01
+#define AMENV_SUSTAIN 0x02
+#define AMENV_LOOP 0x04
+
+// Sample flags
+#define AMSMP_16BIT 0x04
+#define AMSMP_LOOP 0x08
+#define AMSMP_PINGPONG 0x10
+#define AMSMP_PANNING 0x20
+#define AMSMP_EXISTS 0x80
+// some flags are still missing... what is f.e. 0x8000?
+
+
#pragma pack(1)
// header for compressed j2b files
@@ -45,18 +78,40 @@
uint8 channels;
uint8 speed;
uint8 tempo;
- uint32 unknown;
+ uint32 unknown; // 0x16078035 if original file was MOD, 0xC50100FF for everything else?
uint8 globalvolume;
};
+// AMFF instrument envelope point
+struct AMFFINST_ENVPOINT
+{
+ uint16 tick;
+ uint8 pointval; // 0...64
+};
+
+// AMFF instrument header
struct AMFFCHUNK_INSTRUMENT
{
- uint8 unknown; // 0x00
- uint8 sample; // sample number
- char name[28];
- char stuff[195]; // lots of NULs?
+ uint8 unknown; // 0x00
+ uint8 index; // actual instrument number
+ char name[28];
+ uint8 numsamples;
+ uint8 samplemap[120];
+ uint8 autovib_type;
+ uint16 autovib_sweep;
+ uint16 autovib_depth;
+ uint16 autovib_rate;
+ uint8 envflags; // high nibble = pan env flags, low nibble = vol env flags (both nibbles work the same way)
+ uint8 envnumpoints; // high nibble = pan env length, low nibble = vol env length
+ uint8 envsustainpoints; // you guessed it... high nibble = pan env sustain point, low nibble = vol env sustain point
+ uint8 envloopstarts; // i guess you know the pattern now.
+ uint8 envloopends; // same here.
+ AMFFINST_ENVPOINT volenv[10];
+ AMFFINST_ENVPOINT panenv[10];
+ uint16 fadeout;
};
+// AMFF sample header
struct AMFFCHUNK_SAMPLE
{
uint32 signature; // "SAMP"
@@ -73,13 +128,44 @@
uint32 reserved2;
};
+// AM instrument envelope point
+struct AMINST_ENVPOINT
+{
+ uint16 tick;
+ uint16 pointval;
+};
+
+// AM instrument envelope
+struct AMINST_ENVELOPE
+{
+ uint16 flags;
+ uint8 numpoints; // actually, it's num. points - 1, and 0xFF if there is no envelope
+ uint8 suslooppoint;
+ uint8 loopstart;
+ uint8 loopend;
+ AMINST_ENVPOINT values[10];
+ uint16 fadeout; // why is this here? it's only needed for the volume envelope...
+};
+
+// AM instrument header
struct AMCHUNK_INSTRUMENT
{
- uint8 unknown; // 0x00
- uint8 sample; // sample number
- char name[32];
+ uint8 unknown1; // 0x00
+ uint8 index; // actual instrument number
+ char name[32];
+ uint8 samplemap[128];
+ uint8 autovib_type;
+ uint16 autovib_sweep;
+ uint16 autovib_depth;
+ uint16 autovib_rate;
+ uint8 unknown2[7];
+ AMINST_ENVELOPE volenv;
+ AMINST_ENVELOPE pitchenv;
+ AMINST_ENVELOPE panenv;
+ uint16 numsamples;
};
+// AM sample header
struct AMCHUNK_SAMPLE
{
uint32 signature; // "SAMP"
@@ -89,7 +175,7 @@
uint16 pan;
uint16 volume;
uint16 flags;
- uint16 unkown;
+ uint16 unkown; // 0x0000 / 0x0080?
uint32 length;
uint32 loopstart;
uint32 loopend;
@@ -98,7 +184,10 @@
#pragma pack()
-static uint8 riffam_efftrans[26] =
+
+// And here are some nice lookup tables!
+
+static uint8 riffam_efftrans[] =
{
CMD_ARPEGGIO, CMD_PORTAMENTOUP, CMD_PORTAMENTODOWN, CMD_TONEPORTAMENTO,
CMD_VIBRATO, CMD_TONEPORTAVOL, CMD_VIBRATOVOL, CMD_TREMOLO,
@@ -109,9 +198,17 @@
CMD_TREMOR, CMD_XFINEPORTAUPDOWN,
};
-bool Convert_RIFF_AM_Pattern(PATTERNINDEX nPat, const LPCBYTE lpStream, DWORD dwMemLength, bool bIsAM, CSoundFile *pSndFile)
-//--------------------------------------------------------------------------------------------------------------------------
+
+static uint8 riffam_autovibtrans[] =
{
+ VIB_SINE, VIB_SQUARE, VIB_RAMP_UP, VIB_RAMP_DOWN, VIB_RANDOM,
+};
+
+
+// Convert RIFF AM(FF) pattern data to MPT pattern data.
+bool Convert_RIFF_AM_Pattern(const PATTERNINDEX nPat, const LPCBYTE lpStream, const DWORD dwMemLength, const bool bIsAM, CSoundFile *pSndFile)
+//--------------------------------------------------------------------------------------------------------------------------------------------
+{
// version false = AMFF, true = AM
#define ASSERT_CAN_READ(x) \
if( dwMemPos > dwMemLength || x > dwMemLength - dwMemPos ) return false;
@@ -134,12 +231,11 @@
MODCOMMAND *mrow = pSndFile->Patterns[nPat];
MODCOMMAND *m = mrow;
ROWINDEX nRow = 0;
- uint8 flags;
while((nRow < nRows) && (dwMemPos < dwMemLength))
{
ASSERT_CAN_READ(1);
- flags = lpStream[dwMemPos];
+ const uint8 flags = lpStream[dwMemPos];
dwMemPos++;
if (flags == 0)
{
@@ -159,7 +255,7 @@
m->param = lpStream[dwMemPos];
dwMemPos += 2;
- if(m->command <= 25)
+ if(m->command < ARRAYELEMCOUNT(riffam_efftrans))
{
// command translation
m->command = riffam_efftrans[m->command];
@@ -170,6 +266,15 @@
case CMD_ARPEGGIO:
if(m->param == 0) m->command = CMD_NONE;
break;
+ case CMD_VOLUME:
+ if(m->volcmd == VOLCMD_NONE)
+ {
+ m->volcmd = VOLCMD_VOLUME;
+ m->vol = CLAMP(m->param, 0, 64);
+ m->command = CMD_NONE;
+ m->param = 0;
+ }
+ break;
case CMD_TONEPORTAVOL:
case CMD_VIBRATOVOL:
case CMD_VOLUMESLIDE:
@@ -185,7 +290,7 @@
m->param = ((m->param >> 4) * 10) + (m->param & 0x0F);
break;
case CMD_MODCMDEX:
- pSndFile->MODExx2S3MSxx(m);
+ CSoundFile::MODExx2S3MSxx(m);
break;
case CMD_TEMPO:
if(m->param <= 0x1F) m->command = CMD_SPEED;
@@ -221,7 +326,8 @@
ASSERT_CAN_READ(2);
m->instr = lpStream[dwMemPos];
m->note = lpStream[dwMemPos + 1];
- if(m->note > NOTE_MAX) m->note = NOTE_NOTECUT;
+ if(m->note == 0x80) m->note = NOTE_KEYOFF;
+ else if(m->note > 0x80) m->note = NOTE_FADE; // I guess the support for IT "note fade" notes was not intended in mod2j2b, but hey, it works! :-D
dwMemPos += 2;
}
@@ -243,8 +349,99 @@
#undef ASSERT_CAN_READ
}
+
+// Convert envelope data from a RIFF AMFF module (old format) to MPT envelope data.
+void Convert_RIFF_AMFF_Envelope(const uint8 flags, const uint8 numpoints, const uint8 sustainpoint, const uint8 loopstart, const uint8 loopend, const AMFFINST_ENVPOINT *envelope, INSTRUMENTENVELOPE *pMPTEnv)
+//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+{
+ if(envelope == nullptr || pMPTEnv == nullptr)
+ return;
+
+ pMPTEnv->dwFlags = (flags & AMENV_ENABLED) ? ENV_ENABLED : 0;
+ if(flags & AMENV_SUSTAIN) pMPTEnv->dwFlags |= ENV_SUSTAIN;
+ if(flags & AMENV_LOOP) pMPTEnv->dwFlags |= ENV_LOOP;
+
+ pMPTEnv->nReleaseNode = ENV_RELEASE_NODE_UNSET;
+ pMPTEnv->nNodes = min(numpoints, 10); // the buggy mod2j2b converter will actually NOT limit this to 10 points if the envelope is longer.
+
+ pMPTEnv->nSustainStart = pMPTEnv->nSustainEnd = sustainpoint;
+ if(pMPTEnv->nSustainStart > pMPTEnv->nNodes)
+ pMPTEnv->dwFlags &= ~ENV_SUSTAIN;
+
+ pMPTEnv->nLoopStart = loopstart;
+ pMPTEnv->nLoopEnd = loopend;
+ if(pMPTEnv->nLoopStart > pMPTEnv->nLoopEnd || pMPTEnv->nLoopStart > pMPTEnv->nNodes)
+ pMPTEnv->dwFlags &= ~ENV_LOOP;
+
+ for(size_t i = 0; i < 10; i++)
+ {
+ pMPTEnv->Ticks[i] = LittleEndianW(envelope[i].tick) >> 4;
+ if(i == 0)
+ pMPTEnv->Ticks[0] = 0;
+ else if(pMPTEnv->Ticks[i] < pMPTEnv->Ticks[i - 1])
+ pMPTEnv->Ticks[i] = pMPTEnv->Ticks[i - 1] + 1;
+
+ pMPTEnv->Values[i] = CLAMP(envelope[i].pointval, 0, 0x40);
+ }
+
+}
+
+
+// Convert envelope data from a RIFF AM module (new format) to MPT envelope data.
+void Convert_RIFF_AM_Envelope(const AMINST_ENVELOPE *pAMEnv, INSTRUMENTENVELOPE *pMPTEnv, const enmEnvelopeTypes env)
+//-------------------------------------------------------------------------------------------------------------------
+{
+ if(pAMEnv == nullptr || pMPTEnv == nullptr)
+ return;
+
+ if(pAMEnv->numpoints == 0xFF || pAMEnv->numpoints == 0x00)
+ return;
+
+ uint16 flags = LittleEndianW(pAMEnv->flags);
+ pMPTEnv->dwFlags = (flags & AMENV_ENABLED) ? ENV_ENABLED : 0;
+ if(flags & AMENV_SUSTAIN) pMPTEnv->dwFlags |= ENV_SUSTAIN;
+ if(flags & AMENV_LOOP) pMPTEnv->dwFlags |= ENV_LOOP;
+
+ pMPTEnv->nReleaseNode = ENV_RELEASE_NODE_UNSET;
+ pMPTEnv->nNodes = min(pAMEnv->numpoints + 1, 10);
+
+ pMPTEnv->nSustainStart = pMPTEnv->nSustainEnd = pAMEnv->suslooppoint;
+ if(pMPTEnv->nSustainStart > pMPTEnv->nNodes)
+ pMPTEnv->dwFlags &= ~ENV_SUSTAIN;
+
+ pMPTEnv->nLoopStart = pAMEnv->loopstart;
+ pMPTEnv->nLoopEnd = pAMEnv->loopend;
+ if(pMPTEnv->nLoopStart > pMPTEnv->nLoopEnd || pMPTEnv->nLoopStart > pMPTEnv->nNodes)
+ pMPTEnv->dwFlags &= ~ENV_LOOP;
+
+ for(size_t i = 0; i < 10; i++)
+ {
+ pMPTEnv->Ticks[i] = LittleEndianW(pAMEnv->values[i].tick >> 4);
+ if(i == 0)
+ pMPTEnv->Ticks[i] = 0;
+ else if(pMPTEnv->Ticks[i] < pMPTEnv->Ticks[i - 1])
+ pMPTEnv->Ticks[i] = pMPTEnv->Ticks[i - 1] + 1;
+
+ const uint16 val = LittleEndianW(pAMEnv->values[i].pointval);
+ switch(env)
+ {
+ case ENV_VOLUME: // 0....32767
+ pMPTEnv->Values[i] = (BYTE)((val + 1) >> 9);
+ break;
+ case ENV_PITCH: // -4096....4096
+ pMPTEnv->Values[i] = (BYTE)((((int16)val) + 0x1001) >> 7);
+ break;
+ case ENV_PANNING: // -32768...32767
+ pMPTEnv->Values[i] = (BYTE)((((int16)val) + 0x8001) >> 10);
+ break;
+ }
+ pMPTEnv->Values[i] = CLAMP(pMPTEnv->Values[i], ENVELOPE_MIN, ENVELOPE_MAX);
+ }
+}
+
+
bool CSoundFile::ReadAM(const LPCBYTE lpStream, const DWORD dwMemLength)
-//------------------------------------------------------------------------
+//----------------------------------------------------------------------
{
#define ASSERT_CAN_READ(x) \
if( dwMemPos > dwMemLength || x > dwMemLength - dwMemPos ) return false;
@@ -256,7 +453,7 @@
ASSERT_CAN_READ(sizeof(AMFF_RIFFCHUNK));
AMFF_RIFFCHUNK *chunkheader = (AMFF_RIFFCHUNK *)lpStream;
- if(LittleEndian(chunkheader->signature) != 0x46464952 // "RIFF"
+ if(LittleEndian(chunkheader->signature) != AMCHUNKID_RIFF // "RIFF"
|| LittleEndian(chunkheader->chunksize) != dwMemLength - sizeof(AMFF_RIFFCHUNK)
) return false;
@@ -265,8 +462,8 @@
bool bIsAM; // false: AMFF, true: AM
ASSERT_CAN_READ(4);
- if(LittleEndian(*(uint32 *)(lpStream + dwMemPos)) == 0x46464D41) bIsAM = false; // "AMFF"
- else if(LittleEndian(*(uint32 *)(lpStream + dwMemPos)) == 0x20204D41) bIsAM = true; // "AM "
+ if(LittleEndian(*(uint32 *)(lpStream + dwMemPos)) == AMCHUNKID_AMFF) bIsAM = false; // "AMFF"
+ else if(LittleEndian(*(uint32 *)(lpStream + dwMemPos)) == AMCHUNKID_AM__) bIsAM = true; // "AM "
else return false;
dwMemPos += 4;
m_nChannels = 0;
@@ -279,12 +476,12 @@
dwMemPos += sizeof(AMFF_RIFFCHUNK);
ASSERT_CAN_READ(LittleEndian(chunkheader->chunksize));
- DWORD dwChunkEnd = dwMemPos + LittleEndian(chunkheader->chunksize);
+ const DWORD dwChunkEnd = dwMemPos + LittleEndian(chunkheader->chunksize);
switch(LittleEndian(chunkheader->signature))
{
- case 0x4E49414D: // "MAIN" - Song info (AMFF)
- case 0x54494E49: // "INIT" - Song info (AM)
+ case AMCHUNKID_MAIN: // "MAIN" - Song info (AMFF)
+ case AMCHUNKID_INIT: // "INIT" - Song info (AM)
if((LittleEndian(chunkheader->signature) == 0x4E49414D && !bIsAM) || (LittleEndian(chunkheader->signature) == 0x54494E49 && bIsAM))
{
ASSERT_CAN_READ_CHUNK(sizeof(AMFFCHUNK_MAIN));
@@ -304,6 +501,7 @@
m_nDefaultGlobalVolume = mainchunk->globalvolume << 1;
m_nSamplePreAmp = m_nVSTiVolume = 48;
m_nType = MOD_TYPE_IT;
+ ASSERT(LittleEndian(mainchunk->unknown) == 0xFF0001C5 || LittleEndian(mainchunk->unknown) == 0x35800716);
// It seems like there's no way to differentiate between
// Muted and Surround channels (they're all 0xA0) - might
@@ -330,132 +528,237 @@
}
break;
- case 0x5244524F: // "ORDR" - Order list
+ case AMCHUNKID_ORDR: // "ORDR" - Order list
ASSERT_CAN_READ_CHUNK(1);
Order.ReadAsByte(&lpStream[dwMemPos + 1], lpStream[dwMemPos] + 1, dwChunkEnd - (dwMemPos + 1));
break;
- case 0x54544150: // "PATT" - Pattern data for one pattern
+ case AMCHUNKID_PATT: // "PATT" - Pattern data for one pattern
ASSERT_CAN_READ_CHUNK(5);
Convert_RIFF_AM_Pattern(lpStream[dwMemPos], (LPCBYTE)(lpStream + dwMemPos + 5), LittleEndian(*(DWORD *)(lpStream + dwMemPos + 1)), bIsAM, this);
break;
- case 0x54534E49: // "INST" - Instrument (only in RIFF AMFF)
+ case AMCHUNKID_INST: // "INST" - Instrument (only in RIFF AMFF)
if(!bIsAM)
{
ASSERT_CAN_READ_CHUNK(sizeof(AMFFCHUNK_INSTRUMENT));
- AMFFCHUNK_INSTRUMENT *inschunk = (AMFFCHUNK_INSTRUMENT *)(lpStream + dwMemPos);
+ AMFFCHUNK_INSTRUMENT *instheader = (AMFFCHUNK_INSTRUMENT *)(lpStream + dwMemPos);
dwMemPos += sizeof(AMFFCHUNK_INSTRUMENT);
- SAMPLEINDEX nSmp = inschunk->sample + 1;
- if(nSmp >= MAX_SAMPLES)
+ const INSTRUMENTINDEX nIns = instheader->index + 1;
+ if(nIns >= MAX_INSTRUMENTS)
break;
- m_nSamples = max(m_nSamples, nSmp);
- memcpy(m_szNames[nSmp], inschunk->name, 28);
- SpaceToNullStringFixed(m_szNames[nSmp], 28);
+ if(Instruments[nIns] != nullptr)
+ delete Instruments[nIns];
- ASSERT_CAN_READ_CHUNK(sizeof(AMFFCHUNK_SAMPLE));
- AMFFCHUNK_SAMPLE *smpchunk = (AMFFCHUNK_SAMPLE *)(lpStream + dwMemPos);
- dwMemPos += sizeof(AMFFCHUNK_SAMPLE);
+ MODINSTRUMENT *pIns = new MODINSTRUMENT;
+ if(pIns == nullptr)
+ break;
+ Instruments[nIns] = pIns;
+ MemsetZero(*pIns);
+ SetDefaultInstrumentValues(pIns);
- if(smpchunk->signature != 0x504D4153) break; // SAMP
+ m_nInstruments = max(m_nInstruments, nIns);
- memcpy(m_szNames[nSmp], smpchunk->name, 28);
- SpaceToNullStringFixed(m_szNames[nSmp], 28);
-
- Samples[nSmp].nPan = smpchunk->pan << 2;
- Samples[nSmp].nVolume = smpchunk->volume << 2;
- Samples[nSmp].nGlobalVol = 64;
- Samples[nSmp].nLength = LittleEndian(smpchunk->length);
- Samples[nSmp].nLoopStart = LittleEndian(smpchunk->loopstart);
- Samples[nSmp].nLoopEnd = LittleEndian(smpchunk->loopend);
- Samples[nSmp].nC5Speed = LittleEndian(smpchunk->samplerate);
+ memcpy(pIns->name, instheader->name, 28);
+ SpaceToNullStringFixed(pIns->name, 28);
- uint16 flags = LittleEndianW(smpchunk->flags);
- if(flags & 0x04)
- Samples[nSmp].uFlags |= CHN_16BIT;
- if(flags & 0x08)
- Samples[nSmp].uFlags |= CHN_LOOP;
- if(flags & 0x10)
- Samples[nSmp].uFlags |= CHN_PINGPONGLOOP;
- if(flags & 0x20)
- Samples[nSmp].uFlags |= CHN_PANNING;
+ for(BYTE i = 0; i < 128; i++)
+ {
+ pIns->NoteMap[i] = i + 1;
+ pIns->Keyboard[i] = instheader->samplemap[i] + m_nSamples + 1;
+ }
- dwMemPos += ReadSample(&Samples[nSmp], (flags & 0x04) ? RS_PCM16S : RS_PCM8S, (LPCSTR)(lpStream + dwMemPos), dwMemLength - dwMemPos);
+ pIns->nGlobalVol = 64;
+ pIns->nPan = 128;
+ pIns->nFadeOut = LittleEndianW(instheader->fadeout) << 5;
+ pIns->nPPC = NOTE_MIDDLEC - 1;
+
+ // interleaved envelope data... meh. gotta split it up here and decode it separately.
+ // note: mod2j2b is BUGGY and always writes ($original_num_points & 0x0F) in the header,
+ // but just has room for 10 envelope points. That means that long (>= 16 points)
+ // envelopes are cut off, and envelopes have to be trimmed to 10 points, even if
+ // the header claims that they are longer.
+ Convert_RIFF_AMFF_Envelope(instheader->envflags & 0x0F, instheader->envnumpoints & 0x0F, instheader->envsustainpoints & 0x0F, instheader->envloopstarts & 0x0F, instheader->envloopends & 0x0F, instheader->volenv, &pIns->VolEnv);
+ Convert_RIFF_AMFF_Envelope(instheader->envflags >> 4, instheader->envnumpoints >> 4, instheader->envsustainpoints >> 4, instheader->envloopstarts >> 4, instheader->envloopends >> 4, instheader->panenv, &pIns->PanEnv);
+
+ const size_t nTotalSmps = LittleEndianW(instheader->numsamples);
+
+ // read sample sub-chunks - this is a rather "flat" format compared to RIFF AM and has no nested RIFF chunks.
+ for(size_t nSmpCnt = 0; nSmpCnt < nTotalSmps; nSmpCnt++)
+ {
+
+ if(m_nSamples + 1 >= MAX_SAMPLES)
+ break;
+
+ const SAMPLEINDEX nSmp = ++m_nSamples;
+
+ MemsetZero(Samples[nSmp]);
+
+ ASSERT_CAN_READ_CHUNK(sizeof(AMFFCHUNK_SAMPLE));
+ AMFFCHUNK_SAMPLE *smpchunk = (AMFFCHUNK_SAMPLE *)(lpStream + dwMemPos);
+ dwMemPos += sizeof(AMFFCHUNK_SAMPLE);
+
+ if(smpchunk->signature != AMCHUNKID_SAMP) break; // SAMP
+
+ memcpy(m_szNames[nSmp], smpchunk->name, 28);
+ SpaceToNullStringFixed(m_szNames[nSmp], 28);
+
+ Samples[nSmp].nPan = smpchunk->pan << 2;
+ Samples[nSmp].nVolume = smpchunk->volume << 2;
+ Samples[nSmp].nGlobalVol = 64;
+ Samples[nSmp].nLength = LittleEndian(smpchunk->length);
+ Samples[nSmp].nLoopStart = LittleEndian(smpchunk->loopstart);
+ Samples[nSmp].nLoopEnd = LittleEndian(smpchunk->loopend);
+ Samples[nSmp].nC5Speed = LittleEndian(smpchunk->samplerate);
+
+ if(instheader->autovib_type < ARRAYELEMCOUNT(riffam_autovibtrans))
+ Samples[nSmp].nVibType = riffam_autovibtrans[instheader->autovib_type];
+ Samples[nSmp].nVibSweep = (BYTE)(LittleEndianW(instheader->autovib_sweep));
+ Samples[nSmp].nVibRate = (BYTE)(LittleEndianW(instheader->autovib_rate) >> 4);
+ Samples[nSmp].nVibDepth = (BYTE)(LittleEndianW(instheader->autovib_depth) >> 2);
+
+ const uint16 flags = LittleEndianW(smpchunk->flags);
+ if(flags & AMSMP_16BIT)
+ Samples[nSmp].uFlags |= CHN_16BIT;
+ if(flags & AMSMP_LOOP)
+ Samples[nSmp].uFlags |= CHN_LOOP;
+ if(flags & AMSMP_PINGPONG)
+ Samples[nSmp].uFlags |= CHN_PINGPONGLOOP;
+ if(flags & AMSMP_PANNING)
+ Samples[nSmp].uFlags |= CHN_PANNING;
+
+ dwMemPos += ReadSample(&Samples[nSmp], (flags & 0x04) ? RS_PCM16S : RS_PCM8S, (LPCSTR)(lpStream + dwMemPos), dwMemLength - dwMemPos);
+ }
}
break;
- case 0x46464952: // "RIFF" - Instrument (only in RIFF AM)
+ case AMCHUNKID_RIFF: // "RIFF" - Instrument (only in RIFF AM)
if(bIsAM)
{
ASSERT_CAN_READ_CHUNK(4);
- if(LittleEndian(*(uint32 *)(lpStream + dwMemPos)) != 0x20204941) break; // "AI "
+ if(LittleEndian(*(uint32 *)(lpStream + dwMemPos)) != AMCHUNKID_AI__) break; // "AI "
dwMemPos += 4;
ASSERT_CAN_READ_CHUNK(sizeof(AMFF_RIFFCHUNK));
- AMFF_RIFFCHUNK *instchunk = (AMFF_RIFFCHUNK *)(lpStream + dwMemPos);
+ const AMFF_RIFFCHUNK *instchunk = (AMFF_RIFFCHUNK *)(lpStream + dwMemPos);
dwMemPos += sizeof(AMFF_RIFFCHUNK);
ASSERT_CAN_READ_CHUNK(LittleEndian(instchunk->chunksize));
- if(LittleEndian(instchunk->signature) != 0x54534E49) break; // "INST"
+ if(LittleEndian(instchunk->signature) != AMCHUNKID_INST) break; // "INST"
ASSERT_CAN_READ_CHUNK(4);
- DWORD dwHeadlen = LittleEndian(*(uint32 *)(lpStream + dwMemPos));
- dwMemPos +=4 ;
+ const DWORD dwHeadlen = LittleEndian(*(uint32 *)(lpStream + dwMemPos));
+ ASSERT(dwHeadlen == sizeof(AMCHUNK_INSTRUMENT));
+ dwMemPos += 4;
ASSERT_CAN_READ_CHUNK(sizeof(AMCHUNK_INSTRUMENT));
- AMCHUNK_INSTRUMENT *instheadchunk = (AMCHUNK_INSTRUMENT *)(lpStream + dwMemPos);
- dwMemPos += dwHeadlen;
+ const AMCHUNK_INSTRUMENT *instheader = (AMCHUNK_INSTRUMENT *)(lpStream + dwMemPos);
+ dwMemPos += sizeof(AMCHUNK_INSTRUMENT);
- SAMPLEINDEX nSmp = instheadchunk->sample + 1;
- if(nSmp >= MAX_SAMPLES)
+ const INSTRUMENTINDEX nIns = instheader->index + 1;
+ if(nIns >= MAX_INSTRUMENTS)
break;
- m_nSamples = max(m_nSamples, nSmp);
- memcpy(m_szNames[nSmp], instheadchunk->name, 32);
- SpaceToNullStringFixed(m_szNames[nSmp], 31);
+ if(Instruments[nIns] != nullptr)
+ delete Instruments[nIns];
- ASSERT_CAN_READ_CHUNK(sizeof(AMFF_RIFFCHUNK));
- instchunk = (AMFF_RIFFCHUNK *)(lpStream + dwMemPos);
- dwMemPos += sizeof(AMFF_RIFFCHUNK);
- ASSERT_CAN_READ_CHUNK(LittleEndian(instchunk->chunksize));
- if(LittleEndian(instchunk->signature) != 0x46464952) break; // yet another "RIFF"...
+ MODINSTRUMENT *pIns = new MODINSTRUMENT;
+ if(pIns == nullptr)
+ break;
+ Instruments[nIns] = pIns;
+ MemsetZero(*pIns);
+ SetDefaultInstrumentValues(pIns);
- ASSERT_CAN_READ_CHUNK(4);
- if(LittleEndian(*(uint32 *)(lpStream + dwMemPos)) != 0x20205341) break; // "AS " (ain't this boring?)
- dwMemPos += 4;
+ m_nInstruments = max(m_nInstruments, nIns);
- ASSERT_CAN_READ_CHUNK(sizeof(AMCHUNK_SAMPLE));
- AMCHUNK_SAMPLE *smpchunk = (AMCHUNK_SAMPLE *)(lpStream + dwMemPos);
+ memcpy(pIns->name, instheader->name, 32);
+ SpaceToNullStringFixed(pIns->name, 31);
- if(smpchunk->signature != 0x504D4153) break; // SAMP
+ for(BYTE i = 0; i < 128; i++)
+ {
+ pIns->NoteMap[i] = i + 1;
+ pIns->Keyboard[i] = instheader->samplemap[i] + m_nSamples + 1;
+ }
- memcpy(m_szNames[nSmp], smpchunk->name, 32);
- SpaceToNullStringFixed(m_szNames[nSmp], 31);
+ pIns->nGlobalVol = 64;
+ pIns->nPan = 128;
+ pIns->nFadeOut = LittleEndianW(instheader->volenv.fadeout) << 5;
+ pIns->nPPC = NOTE_MIDDLEC - 1;
- if(LittleEndianW(smpchunk->pan) > 0x7FFF || LittleEndianW(smpchunk->volume) > 0x7FFF)
- break;
+ Convert_RIFF_AM_Envelope(&instheader->volenv, &pIns->VolEnv, ENV_VOLUME);
+ Convert_RIFF_AM_Envelope(&instheader->pitchenv, &pIns->PitchEnv, ENV_PITCH);
+ Convert_RIFF_AM_Envelope(&instheader->panenv, &pIns->PanEnv, ENV_PANNING);
- Samples[nSmp].nPan = LittleEndianW(smpchunk->pan) * 256 / 32767;
- Samples[nSmp].nVolume = LittleEndianW(smpchunk->volume) * 256 / 32767;
- Samples[nSmp].nGlobalVol = 64;
- Samples[nSmp].nLength = LittleEndian(smpchunk->length);
- Samples[nSmp].nLoopStart = LittleEndian(smpchunk->loopstart);
- Samples[nSmp].nLoopEnd = LittleEndian(smpchunk->loopend);
- Samples[nSmp].nC5Speed = LittleEndian(smpchunk->samplerate);
+ const size_t nTotalSmps = LittleEndianW(instheader->numsamples);
- uint16 flags = LittleEndianW(smpchunk->flags);
- if(flags & 0x04)
- Samples[nSmp].uFlags |= CHN_16BIT;
- if(flags & 0x08)
- Samples[nSmp].uFlags |= CHN_LOOP;
- if(flags & 0x10)
- Samples[nSmp].uFlags |= CHN_PINGPONGLOOP;
- if(flags & 0x20)
- Samples[nSmp].uFlags |= CHN_PANNING;
+ DWORD dwChunkPos;
- dwMemPos += LittleEndian(smpchunk->headsize) + 12; // doesn't include the 3 first DWORDs
- dwMemPos += ReadSample(&Samples[nSmp], (flags & 0x04) ? RS_PCM16S : RS_PCM8S, (LPCSTR)(lpStream + dwMemPos), dwMemLength - dwMemPos);
+ // read sample sub-chunks (RIFF nesting ftw)
+ for(size_t nSmpCnt = 0; nSmpCnt < nTotalSmps; nSmpCnt++)
+ {
+ dwChunkPos = dwMemPos;
+
+ ASSERT_CAN_READ_CHUNK(sizeof(AMFF_RIFFCHUNK));
+ instchunk = (AMFF_RIFFCHUNK *)(lpStream + dwChunkPos);
+ dwChunkPos += sizeof(AMFF_RIFFCHUNK);
+ ASSERT_CAN_READ_CHUNK(LittleEndian(instchunk->chunksize));
+ if(LittleEndian(instchunk->signature) != AMCHUNKID_RIFF) break;
+
+ ASSERT_CAN_READ_CHUNK(4);
+ if(LittleEndian(*(uint32 *)(lpStream + dwChunkPos)) != AMCHUNKID_AS__) break;
+ dwChunkPos += 4;
+
+ ASSERT_CAN_READ_CHUNK(sizeof(AMCHUNK_SAMPLE));
+ const AMCHUNK_SAMPLE *smpchunk = (AMCHUNK_SAMPLE *)(lpStream + dwChunkPos);
+
+ if(smpchunk->signature != AMCHUNKID_SAMP) break; // SAMP
+
+ if(m_nSamples + 1 >= MAX_SAMPLES)
+ break;
+ const SAMPLEINDEX nSmp = ++m_nSamples;
+
+ MemsetZero(Samples[nSmp]);
+
+ memcpy(m_szNames[nSmp], smpchunk->name, 32);
+ SpaceToNullStringFixed(m_szNames[nSmp], 31);
+
+ if(LittleEndianW(smpchunk->pan) > 0x7FFF || LittleEndianW(smpchunk->volume) > 0x7FFF)
+ break;
+
+ Samples[nSmp].nPan = LittleEndianW(smpchunk->pan) * 256 / 32767;
+ Samples[nSmp].nVolume = LittleEndianW(smpchunk->volume) * 256 / 32767;
+ Samples[nSmp].nGlobalVol = 64;
+ Samples[nSmp].nLength = LittleEndian(smpchunk->length);
+ Samples[nSmp].nLoopStart = LittleEndian(smpchunk->loopstart);
+ Samples[nSmp].nLoopEnd = LittleEndian(smpchunk->loopend);
+ Samples[nSmp].nC5Speed = LittleEndian(smpchunk->samplerate);
+
+ if(instheader->autovib_type < ARRAYELEMCOUNT(riffam_autovibtrans))
+ Samples[nSmp].nVibType = riffam_autovibtrans[instheader->autovib_type];
+ Samples[nSmp].nVibSweep = (BYTE)(LittleEndianW(instheader->autovib_sweep));
+ Samples[nSmp].nVibRate = (BYTE)(LittleEndianW(instheader->autovib_rate) >> 4);
+ Samples[nSmp].nVibDepth = (BYTE)(LittleEndianW(instheader->autovib_depth) >> 2);
+
+ const uint16 flags = LittleEndianW(smpchunk->flags);
+ if(flags & AMSMP_16BIT)
+ Samples[nSmp].uFlags |= CHN_16BIT;
+ if(flags & AMSMP_LOOP)
+ Samples[nSmp].uFlags |= CHN_LOOP;
+ if(flags & AMSMP_PINGPONG)
+ Samples[nSmp].uFlags |= CHN_PINGPONGLOOP;
+ if(flags & AMSMP_PANNING)
+ Samples[nSmp].uFlags |= CHN_PANNING;
+
+ dwChunkPos += LittleEndian(smpchunk->headsize) + 12; // doesn't include the 3 first DWORDs
+ dwChunkPos += ReadSample(&Samples[nSmp], (flags & 0x04) ? RS_PCM16S : RS_PCM8S, (LPCSTR)(lpStream + dwChunkPos), dwMemLength - dwChunkPos);
+
+ dwMemPos += LittleEndian(instchunk->chunksize) + sizeof(AMFF_RIFFCHUNK);
+ // RIFF AM has a padding byte so that all chunks have an even size.
+ if(LittleEndian(instchunk->chunksize) & 1)
+ dwMemPos++;
+
+ }
}
break;
@@ -483,9 +786,9 @@
ASSERT_CAN_READ(sizeof(J2BHEADER));
J2BHEADER *header = (J2BHEADER *)lpStream;
- if(LittleEndian(header->signature) != 0x4553554D // "MUSE"
- || (LittleEndian(header->deadbeaf) != 0xAFBEADDE // 0xDEADBEAF (RIFF AM)
- && LittleEndian(header->deadbeaf) != 0xBEBAADDE) // 0xDEADBABE (RIFF AMFF)
+ if(LittleEndian(header->signature) != J2BHEAD_MUSE // "MUSE"
+ || (LittleEndian(header->deadbeaf) != J2BHEAD_DEADBEAF // 0xDEADBEAF (RIFF AM)
+ && LittleEndian(header->deadbeaf) != J2BHEAD_DEADBABE) // 0xDEADBABE (RIFF AMFF)
|| LittleEndian(header->j2blength) != dwMemLength
|| LittleEndian(header->packed_length) != dwMemLength - sizeof(J2BHEADER)
|| LittleEndian(header->packed_length) == 0
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-06-22 18:15:17
|
Revision: 630
http://modplug.svn.sourceforge.net/modplug/?rev=630&view=rev
Author: saga-games
Date: 2010-06-22 18:15:10 +0000 (Tue, 22 Jun 2010)
Log Message:
-----------
[Fix] S3M Loader: Now the loop points should be treated properly, without any need for the "PSM2S3M hack".
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_s3m.cpp
Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_s3m.cpp 2010-06-21 07:13:54 UTC (rev 629)
+++ trunk/OpenMPT/soundlib/Load_s3m.cpp 2010-06-22 18:15:10 UTC (rev 630)
@@ -367,7 +367,7 @@
{
Samples[iSmp].nLength = CLAMP(LittleEndian(*((LPDWORD)(s + 0x10))), 4, MAX_SAMPLE_LENGTH);
Samples[iSmp].nLoopStart = CLAMP(LittleEndian(*((LPDWORD)(s + 0x14))), 0, Samples[iSmp].nLength - 1);
- Samples[iSmp].nLoopEnd = CLAMP(LittleEndian(*((LPDWORD)(s+0x18))), 4, Samples[iSmp].nLength);
+ Samples[iSmp].nLoopEnd = CLAMP(LittleEndian(*((LPDWORD)(s+0x18))), 0, Samples[iSmp].nLength);
Samples[iSmp].nVolume = CLAMP(s[0x1C], 0, 64) << 2;
Samples[iSmp].nGlobalVol = 64;
if (s[0x1F] & 1) Samples[iSmp].uFlags |= CHN_LOOP;
@@ -389,10 +389,6 @@
Samples[iSmp].nLoopStart = Samples[iSmp].nLoopEnd = 0;
Samples[iSmp].nPan = 0x80;
- // attempt to fix samples which are not supposed to have loops (for example in S3M files made with PSM2S3M)
- if(Samples[iSmp].nLoopEnd <= 4 && Samples[iSmp].nLength > 8)
- Samples[iSmp].uFlags &= ~CHN_LOOP;
-
} else if(s[0] >= S3I_TYPE_ADMEL)
{
bHasAdlibPatches = true;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-06-21 07:14:00
|
Revision: 629
http://modplug.svn.sourceforge.net/modplug/?rev=629&view=rev
Author: saga-games
Date: 2010-06-21 07:13:54 +0000 (Mon, 21 Jun 2010)
Log Message:
-----------
[Fix] Mod Conversion: Channel settings were not reset properly for MOD/XM/S3M, only the first channel was fixed.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/Modedit.cpp
Modified: trunk/OpenMPT/mptrack/Modedit.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Modedit.cpp 2010-06-19 19:47:53 UTC (rev 628)
+++ trunk/OpenMPT/mptrack/Modedit.cpp 2010-06-21 07:13:54 UTC (rev 629)
@@ -344,12 +344,12 @@
{
if(newTypeIsMOD_XM || newTypeIsS3M)
{
- m_SndFile.ChnSettings->nVolume = 64;
- m_SndFile.ChnSettings->dwFlags &= ~CHN_SURROUND;
+ m_SndFile.ChnSettings[nChn].nVolume = 64;
+ m_SndFile.ChnSettings[nChn].dwFlags &= ~CHN_SURROUND;
}
if(newTypeIsXM)
{
- m_SndFile.ChnSettings->nPan = 128;
+ m_SndFile.ChnSettings[nChn].nPan = 128;
}
}
@@ -369,11 +369,10 @@
//rewbs.cutomKeys: update effect key commands
CInputHandler *ih = CMainFrame::GetMainFrame()->GetInputHandler();
- if (newTypeIsMOD_XM) {
+ if (newTypeIsMOD_XM)
ih->SetXMEffects();
- } else {
+ else
ih->SetITEffects();
- }
//end rewbs.cutomKeys
// Check mod specifications
@@ -555,6 +554,8 @@
m_SndFile.Chn[tmpchn] = m_SndFile.Chn[i];
}
tmpchn++;
+ } else
+ {
if (i >= nRemainingChannels)
{
m_SndFile.InitChannel(i);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-06-19 19:48:00
|
Revision: 628
http://modplug.svn.sourceforge.net/modplug/?rev=628&view=rev
Author: saga-games
Date: 2010-06-19 19:47:53 +0000 (Sat, 19 Jun 2010)
Log Message:
-----------
[Fix] Pattern Editor: New patterns were inserted in the wrong orderlist position for MOD/S3M files (before instead of after the current order). This broke in rev 616 and was supposed to be fixed in rev 622, but I somehow failed to include the patch.
[Fix] (Still unfunctional) Sample Generator: There was an error in one of the preset formulas.
[Imp] Instrument Editor: More helpful value display for the panning envelope in the status bar with indication what's left and what's right.
[Imp] XM Saving: Panbrello is not saved anymore in compatibility mode.
[Imp] Mod Conversion: When converting to XM, rogue note delays are removed from the patterns to avoid interferrence with a FT2 bug.
[Ref] Some refactoring
[Mod] Changed link in the release notes (history.txt -> History.txt for those case-sensitive OSes), added revision number to History.txt
Revision Links:
--------------
http://modplug.svn.sourceforge.net/modplug/?rev=616&view=rev
http://modplug.svn.sourceforge.net/modplug/?rev=622&view=rev
Modified Paths:
--------------
trunk/OpenMPT/mptrack/Ctrl_pat.cpp
trunk/OpenMPT/mptrack/Mpdlgs.cpp
trunk/OpenMPT/mptrack/SampleGenerator.cpp
trunk/OpenMPT/mptrack/View_ins.cpp
trunk/OpenMPT/mptrack/View_pat.cpp
trunk/OpenMPT/packageTemplate/History.txt
trunk/OpenMPT/packageTemplate/OMPT_1.18_ReleaseNotes.html
trunk/OpenMPT/soundlib/Load_mod.cpp
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
Modified: trunk/OpenMPT/mptrack/Ctrl_pat.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2010-06-19 17:12:30 UTC (rev 627)
+++ trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2010-06-19 19:47:53 UTC (rev 628)
@@ -324,11 +324,10 @@
if (dwHintMask & (HINT_MODTYPE|HINT_PATNAMES))
{
UINT nPat;
- if (dwHintMask&HINT_PATNAMES) {
+ if (dwHintMask&HINT_PATNAMES)
nPat = (dwHintMask >> HINT_SHIFT_PAT);
- } else {
+ else
nPat = SendViewMessage(VIEWMSG_GETCURRENTPATTERN);
- }
m_pSndFile->GetPatternName(nPat, s, sizeof(s));
m_EditPatName.SetWindowText(s);
BOOL bXMIT = (m_pSndFile->m_nType & (MOD_TYPE_XM|MOD_TYPE_IT|MOD_TYPE_MPT)) ? TRUE : FALSE;
@@ -781,11 +780,11 @@
ORDERINDEX nCurOrd = m_OrderList.GetCurSel(true).nOrdLo;
PATTERNINDEX pat = pSndFile->Order[nCurOrd];
ROWINDEX rows = 64;
- if ((pat < pSndFile->Patterns.Size()) && (pSndFile->Patterns[pat]) && (pSndFile->m_nType & (MOD_TYPE_XM|MOD_TYPE_IT|MOD_TYPE_MPT)))
+ if(pSndFile->Patterns.IsValidPat(pat))
{
+ nCurOrd++; // only if the current oder is already occupied, create a new pattern at the next position.
rows = pSndFile->Patterns[pat].GetNumRows();
rows = CLAMP(rows, pSndFile->GetModSpecifications().patternRowsMin, pSndFile->GetModSpecifications().patternRowsMax);
- nCurOrd++; // only if the current oder is already occupied, create a new pattern at the next position.
}
PATTERNINDEX nNewPat = m_pModDoc->InsertPattern(nCurOrd, rows);
if ((nNewPat != PATTERNINDEX_INVALID) && (nNewPat < pSndFile->Patterns.Size()))
Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2010-06-19 17:12:30 UTC (rev 627)
+++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2010-06-19 19:47:53 UTC (rev 628)
@@ -9,7 +9,7 @@
#include "snddev.h"
#include ".\mpdlgs.h"
-#define str_preampChangeNote GetStrI18N(_TEXT("Note: Pre-Amp setting affects sample volume only. Changing this setting may cause undesired effects on volume balance between sample based instruments and plugin instrument."))
+#define str_preampChangeNote GetStrI18N(_TEXT("Note: Pre-Amp setting affects sample volume only. Changing this setting may cause undesired effects on volume balance between sample based instruments and plugin instruments."))
//#pragma warning(disable:4244) //"conversion from 'type1' to 'type2', possible loss of data"
@@ -353,13 +353,7 @@
m_CbnBufferLength.GetWindowText(s, sizeof(s));
m_nBufferLength = atoi(s);
//Check given value.
- if(m_nBufferLength < SNDDEV_MINBUFFERLEN)
- m_nBufferLength = SNDDEV_MINBUFFERLEN;
- else
- {
- if(m_nBufferLength > SNDDEV_MAXBUFFERLEN)
- m_nBufferLength = SNDDEV_MAXBUFFERLEN;
- }
+ m_nBufferLength = CLAMP(m_nBufferLength, SNDDEV_MINBUFFERLEN, SNDDEV_MAXBUFFERLEN);
wsprintf(s, "%d ms", m_nBufferLength);
m_CbnBufferLength.SetWindowText(s);
}
Modified: trunk/OpenMPT/mptrack/SampleGenerator.cpp
===================================================================
--- trunk/OpenMPT/mptrack/SampleGenerator.cpp 2010-06-19 17:12:30 UTC (rev 627)
+++ trunk/OpenMPT/mptrack/SampleGenerator.cpp 2010-06-19 19:47:53 UTC (rev 628)
@@ -601,7 +601,7 @@
presets.AddPreset(preset);
preset.description = "Noisy Saw";
- preset.expression = "(x mod 800) / 800 - 0.5 + rnd (0.1)";
+ preset.expression = "(x mod 800) / 800 - 0.5 + rnd(0.1)";
presets.AddPreset(preset);
preset.description = "PWM Filter";
Modified: trunk/OpenMPT/mptrack/View_ins.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_ins.cpp 2010-06-19 17:12:30 UTC (rev 627)
+++ trunk/OpenMPT/mptrack/View_ins.cpp 2010-06-19 19:47:53 UTC (rev 628)
@@ -1387,15 +1387,23 @@
if (nVal < 0) nVal = 0;
if (nVal > 64) nVal = 64;
if (nTick < 0) nTick = 0;
- if (nTick <= EnvGetReleaseNodeTick() + 1 || EnvGetReleaseNode() == ENV_RELEASE_NODE_UNSET) {
- int displayVal = (m_nEnv != ENV_VOLUME && !(m_nEnv == ENV_PITCH && (pIns->PitchEnv.dwFlags & ENV_FILTER))) ? nVal - 32 : nVal;
- wsprintf(s, "Tick %d, [%d]", nTick, displayVal);
- } else {
+ if (nTick <= EnvGetReleaseNodeTick() + 1 || EnvGetReleaseNode() == ENV_RELEASE_NODE_UNSET)
+ {
+ // ticks before release node (or no release node)
+ const int displayVal = (m_nEnv != ENV_VOLUME && !(m_nEnv == ENV_PITCH && (pIns->PitchEnv.dwFlags & ENV_FILTER))) ? nVal - 32 : nVal;
+ if(m_nEnv != ENV_PANNING)
+ wsprintf(s, "Tick %d, [%d]", nTick, displayVal);
+ else // panning envelope: display right/center/left chars
+ wsprintf(s, "Tick %d, [%d %c]", nTick, abs(displayVal), displayVal > 0 ? 'R' : (displayVal < 0 ? 'L' : 'C'));
+ } else
+ {
+ // ticks after release node
int displayVal = (nVal - EnvGetReleaseNodeValue()) * 2;
displayVal = (m_nEnv != ENV_VOLUME) ? displayVal - 32 : displayVal;
wsprintf(s, "Tick %d, [Rel%c%d]", nTick, displayVal > 0 ? '+' : '-', abs(displayVal));
}
UpdateIndicator(s);
+
if ((m_dwStatus & INSSTATUS_DRAGGING) && (m_nDragItem))
{
BOOL bChanged = FALSE;
Modified: trunk/OpenMPT/mptrack/View_pat.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_pat.cpp 2010-06-19 17:12:30 UTC (rev 627)
+++ trunk/OpenMPT/mptrack/View_pat.cpp 2010-06-19 19:47:53 UTC (rev 628)
@@ -777,12 +777,12 @@
//Log("dst: %d; src: %d; blk: %d\n", row, (row-offset/2), (row-1));
switch(i & 7)
{
- case 0: dest->note = src->note; blank->note=0; break;
- case 1: dest->instr = src->instr; blank->instr=0; break;
- case 2: dest->vol = src->vol; blank->vol=0;
- dest->volcmd = src->volcmd; blank->volcmd=0; break;
- case 3: dest->command = src->command; blank->command=0;break;
- case 4: dest->param = src->param; blank->param=0; break;
+ case NOTE_COLUMN: dest->note = src->note; blank->note = 0; break;
+ case INST_COLUMN: dest->instr = src->instr; blank->instr = 0; break;
+ case VOL_COLUMN: dest->vol = src->vol; blank->vol = 0;
+ dest->volcmd = src->volcmd; blank->volcmd = 0; break;
+ case EFFECT_COLUMN: dest->command = src->command; blank->command = 0; break;
+ case PARAM_COLUMN: dest->param = src->param; blank->param = 0; break;
}
}
}
@@ -830,12 +830,12 @@
Log("dst: %d; src: %d\n", row, srcRow);
switch(i & 7)
{
- case 0: dest->note = src->note; break;
- case 1: dest->instr = src->instr; break;
- case 2: dest->vol = src->vol;
- dest->volcmd = src->volcmd; break;
- case 3: dest->command = src->command; break;
- case 4: dest->param = src->param; break;
+ case NOTE_COLUMN: dest->note = src->note; break;
+ case INST_COLUMN: dest->instr = src->instr; break;
+ case VOL_COLUMN: dest->vol = src->vol;
+ dest->volcmd = src->volcmd; break;
+ case EFFECT_COLUMN: dest->command = src->command; break;
+ case PARAM_COLUMN: dest->param = src->param; break;
}
}
}
@@ -2046,18 +2046,18 @@
MODCOMMAND *m = pSndFile->Patterns[m_nPattern] + m_nRow * pSndFile->m_nChannels + ((m_dwCursor & 0xFFFF) >> 3);
switch(m_dwCursor & 7)
{
- case 0:
- case 1:
+ case NOTE_COLUMN:
+ case INST_COLUMN:
m_cmdOld.note = m->note;
m_cmdOld.instr = m->instr;
SendCtrlMessage(CTRLMSG_SETCURRENTINSTRUMENT, m_cmdOld.instr);
break;
- case 2:
+ case VOL_COLUMN:
m_cmdOld.volcmd = m->volcmd;
m_cmdOld.vol = m->vol;
break;
- case 3:
- case 4:
+ case EFFECT_COLUMN:
+ case PARAM_COLUMN:
m_cmdOld.command = m->command;
m_cmdOld.param = m->param;
break;
@@ -2082,11 +2082,11 @@
switch(nCursor)
{
- case 0: p->note = m_cmdOld.note; //Note
- case 1: p->instr = m_cmdOld.instr; break; //Octave
- case 2: p->vol = m_cmdOld.vol; p->volcmd = m_cmdOld.volcmd; break; //Vol
- case 3: //Effect
- case 4: p->command = m_cmdOld.command; p->param = m_cmdOld.param; break;
+ case NOTE_COLUMN: p->note = m_cmdOld.note;
+ case INST_COLUMN: p->instr = m_cmdOld.instr; break;
+ case VOL_COLUMN: p->vol = m_cmdOld.vol; p->volcmd = m_cmdOld.volcmd; break;
+ case EFFECT_COLUMN:
+ case PARAM_COLUMN: p->command = m_cmdOld.command; p->param = m_cmdOld.param; break;
}
pModDoc->SetModified();
@@ -4424,7 +4424,7 @@
// Simply backup the whole row.
pModDoc->GetPatternUndo()->PrepareUndo(m_nPattern, nChn, m_nRow, pSndFile->GetNumChannels(), 1);
- PatternRow prowbase = pSndFile->Patterns[m_nPattern].GetRow(m_nRow);
+ const PatternRow prowbase = pSndFile->Patterns[m_nPattern].GetRow(m_nRow);
MODCOMMAND* p = &prowbase[nChn];
const MODCOMMAND oldcmd = *p; // This is the command we are about to overwrite
Modified: trunk/OpenMPT/packageTemplate/History.txt
===================================================================
--- trunk/OpenMPT/packageTemplate/History.txt 2010-06-19 17:12:30 UTC (rev 627)
+++ trunk/OpenMPT/packageTemplate/History.txt 2010-06-19 19:47:53 UTC (rev 628)
@@ -10,8 +10,8 @@
(tx XYZ): thanks to XYZ for telling us about the bug
-v1.18.02.00 (May 2010)
-----------------------
+v1.18.02.00 (May 2010, revision 610)
+------------------------------------
General tab
[Imp] <Jojo> Disabled tempo slider for MOD files (it was just confusing)
Modified: trunk/OpenMPT/packageTemplate/OMPT_1.18_ReleaseNotes.html
===================================================================
--- trunk/OpenMPT/packageTemplate/OMPT_1.18_ReleaseNotes.html 2010-06-19 17:12:30 UTC (rev 627)
+++ trunk/OpenMPT/packageTemplate/OMPT_1.18_ReleaseNotes.html 2010-06-19 19:47:53 UTC (rev 628)
@@ -186,7 +186,7 @@
<h3>There's more...</h3>
<p>
- For a detailed description of what has changed, check <a href="history.txt">history.txt</a>.
+ For a detailed description of what has changed, check <a href="History.txt">History.txt</a>.
</p>
<h2>Known Issues</h2>
Modified: trunk/OpenMPT/soundlib/Load_mod.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mod.cpp 2010-06-19 17:12:30 UTC (rev 627)
+++ trunk/OpenMPT/soundlib/Load_mod.cpp 2010-06-19 19:47:53 UTC (rev 628)
@@ -58,7 +58,7 @@
case '\\' - 56: command = CMD_SMOOTHMIDI; break; //rewbs.smoothVST: 36 - note: this is actually displayed as "-" in FT2, but seems to be doing nothing.
//case ':' - 21: command = CMD_DELAYCUT; break; //37
case '#' + 3: command = CMD_XPARAM; break; //rewbs.XMfixes - XParam is 38
- default: command = 0;
+ default: command = CMD_NONE;
}
m->command = command;
m->param = param;
@@ -68,7 +68,7 @@
WORD CSoundFile::ModSaveCommand(const MODCOMMAND *m, const bool bXM, const bool bCompatibilityExport) const
//---------------------------------------------------------------------------------------------------------
{
- UINT command = m->command & 0x3F, param = m->param;
+ UINT command = m->command, param = m->param;
switch(command)
{
@@ -77,16 +77,16 @@
case CMD_PORTAMENTOUP:
if (m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_STM|MOD_TYPE_MPT))
{
- if ((param & 0xF0) == 0xE0) { command=0x0E; param=((param & 0x0F) >> 2)|0x10; break; }
- else if ((param & 0xF0) == 0xF0) { command=0x0E; param &= 0x0F; param|=0x10; break; }
+ if ((param & 0xF0) == 0xE0) { command = 0x0E; param = ((param & 0x0F) >> 2) | 0x10; break; }
+ else if ((param & 0xF0) == 0xF0) { command = 0x0E; param &= 0x0F; param |= 0x10; break; }
}
command = 0x01;
break;
case CMD_PORTAMENTODOWN:
if (m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_STM|MOD_TYPE_MPT))
{
- if ((param & 0xF0) == 0xE0) { command=0x0E; param=((param & 0x0F) >> 2)|0x20; break; }
- else if ((param & 0xF0) == 0xF0) { command=0x0E; param &= 0x0F; param|=0x20; break; }
+ if ((param & 0xF0) == 0xE0) { command = 0x0E; param= ((param & 0x0F) >> 2) | 0x20; break; }
+ else if ((param & 0xF0) == 0xF0) { command = 0x0E; param &= 0x0F; param |= 0x20; break; }
}
command = 0x02;
break;
@@ -103,7 +103,7 @@
{
param = min(param << 1, 0xFF);
}
- else if(param == 0xA4)
+ else if(param == 0xA4) // surround
{
if(bCompatibilityExport || !bXM)
{
@@ -135,12 +135,17 @@
case CMD_RETRIG: command = 'R' - 55; break;
case CMD_TREMOR: command = 'T' - 55; break;
case CMD_XFINEPORTAUPDOWN:
- if(bCompatibilityExport && (param & 0xF0) > 2)
+ if(bCompatibilityExport && (param & 0xF0) > 2) // X1x and X2x are legit, everything above are MPT extensions, which don't belong here.
command = param = 0;
else
command = 'X' - 55;
break;
- case CMD_PANBRELLO: command = 'Y' - 55; break;
+ case CMD_PANBRELLO:
+ if(bCompatibilityExport)
+ command = param = 0;
+ else
+ command = 'Y' - 55;
+ break;
case CMD_MIDI:
if(bCompatibilityExport)
command = param = 0;
@@ -153,9 +158,6 @@
else
command = '\\' - 56;
break;
- case CMD_DELAYCUT:
- command = param = 0;
- break;
case CMD_XPARAM: //rewbs.XMfixes - XParam is 38
if(bCompatibilityExport)
command = param = 0;
@@ -183,8 +185,14 @@
default: command = 0x0E; break;
}
break;
- default: command = param = 0;
+ default:
+ command = param = 0;
}
+
+ // don't even think about saving XM effects in MODs...
+ if(command > 0x0F && !bXM)
+ command = param = 0;
+
return (WORD)((command << 8) | (param));
}
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2010-06-19 17:12:30 UTC (rev 627)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2010-06-19 19:47:53 UTC (rev 628)
@@ -3572,13 +3572,14 @@
{
MODINSTRUMENT *pIns = pChn->pModInstrument;
if (((pIns->VolEnv.dwFlags & ENV_LOOP) || (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))) && (pIns->nFadeOut))
- {
+ {
pChn->dwFlags |= CHN_NOTEFADE;
}
if (pIns->VolEnv.nReleaseNode != ENV_RELEASE_NODE_UNSET)
{
- pChn->nVolEnvValueAtReleaseJump = getVolEnvValueFromPosition(pChn->nVolEnvPosition, pIns); pChn->nVolEnvPosition= pIns->VolEnv.Ticks[pIns->VolEnv.nReleaseNode];
+ pChn->nVolEnvValueAtReleaseJump = getVolEnvValueFromPosition(pChn->nVolEnvPosition, pIns);
+ pChn->nVolEnvPosition= pIns->VolEnv.Ticks[pIns->VolEnv.nReleaseNode];
}
}
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2010-06-19 17:12:30 UTC (rev 627)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2010-06-19 19:47:53 UTC (rev 628)
@@ -3794,10 +3794,16 @@
}
} // End if (newTypeIsS3M)
- //////////////////////////////////////////////////
- // Convert anything to XM - adjust volume column
+ ////////////////////////////////////////////////////////////////////////
+ // Convert anything to XM - adjust volume column, breaking EDx command
if (newTypeIsXM)
{
+ // remove EDx if no note is next to it, or it will retrigger the note in FT2 mode
+ if(m->command == CMD_MODCMDEX && (m->param & 0xF0) == 0xD0 && m->note == NOTE_NONE)
+ {
+ m->command = m->param = 0;
+ }
+
if(!m->command) switch(m->volcmd)
{
case VOLCMD_PORTADOWN:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rel...@us...> - 2010-06-19 17:12:36
|
Revision: 627
http://modplug.svn.sourceforge.net/modplug/?rev=627&view=rev
Author: relabsoluness
Date: 2010-06-19 17:12:30 +0000 (Sat, 19 Jun 2010)
Log Message:
-----------
Created tag for version 1.18.02.00
Added Paths:
-----------
tags/1.18.02.00/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|