|
From: <sag...@us...> - 2010-08-31 21:44:05
|
Revision: 692
http://modplug.svn.sourceforge.net/modplug/?rev=692&view=rev
Author: saga-games
Date: 2010-08-31 21:43:58 +0000 (Tue, 31 Aug 2010)
Log Message:
-----------
[Imp] MOD Loader: Added a heuristic detection for VBlank MODs (most MODs use the CIA timer instead of VBlank timing).
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_mod.cpp
Modified: trunk/OpenMPT/soundlib/Load_mod.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mod.cpp 2010-08-31 21:42:33 UTC (rev 691)
+++ trunk/OpenMPT/soundlib/Load_mod.cpp 2010-08-31 21:43:58 UTC (rev 692)
@@ -224,7 +224,18 @@
return ((*(DWORD *)s1) == (*(DWORD *)s2)) ? true : false;
}
+// Functor for fixing VBlank MODs
+struct FixVBlankMODs
+//==================
+{
+ void operator()(MODCOMMAND& m)
+ {
+ if(m.command == CMD_TEMPO)
+ m.command = CMD_SPEED;
+ }
+};
+
bool CSoundFile::ReadMod(const BYTE *lpStream, DWORD dwMemLength)
//---------------------------------------------------------------
{
@@ -380,6 +391,7 @@
const CHANNELINDEX nMaxChn = (bFLT8) ? 4 : m_nChannels; // 4 channels per pattern in FLT8 format.
if(bFLT8) nbp++; // as one logical pattern consists of two real patterns in FLT8 format, the highest pattern number has to be increased by one.
+ bool bHasTempoCommands = false; // for detecting VBlank MODs
// Reading patterns
for (PATTERNINDEX ipat = 0; ipat < nbp; ipat++)
@@ -421,6 +433,7 @@
m->param = A3;
if ((m->command) || (m->param)) ConvertModCommand(m);
+ if (m->command == CMD_TEMPO && m->param < 100) bHasTempoCommands = true;
}
}
}
@@ -449,6 +462,21 @@
bSamplesPresent = true;
}
}
+
+ // Fix VBlank MODs. Arbitrary threshold: 10 minutes.
+ // Basically, this just converts all tempo commands into speed commands
+ // for MODs which are supposed to have VBlank timing (instead of CIA timing).
+ // There is no perfect way to do this, since both MOD types look the same,
+ // but the most reliable way is to simply check for extremely long songs
+ // (as this would indicate that f.e. a F30 command was really meant to set
+ // the ticks per row to 48, and not the tempo to 48 BPM).
+ // In the pattern loader above, a second condition is used: Only tempo commands
+ // below 100 BPM are taken into account.
+ if(bHasTempoCommands && GetSongTime() >= 10 * 60)
+ {
+ Patterns.ForEachModCommand(FixVBlankMODs());
+ }
+
#ifdef MODPLUG_TRACKER
return true;
#else
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|