summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRobert Kukla <roolku@rockbox.org>2008-05-26 23:00:07 +0000
committerRobert Kukla <roolku@rockbox.org>2008-05-26 23:00:07 +0000
commitd23f78b1c6f293abacb171d94cd951c33b8c2c95 (patch)
treedba02f8c8e24b358d3d068688a3655f56b9b932a /apps
parent41cfc4d8386de3779a8f053b610f62600ad821e5 (diff)
downloadrockbox-d23f78b1c6f293abacb171d94cd951c33b8c2c95.tar.gz
rockbox-d23f78b1c6f293abacb171d94cd951c33b8c2c95.tar.bz2
rockbox-d23f78b1c6f293abacb171d94cd951c33b8c2c95.zip
fix FS#9042 - MOD codec: SoundTracker variant MOD files will not play
- remove dubious format check and assume no formattag -> Soundtracker - change method for remembering "periods converted" as the old one would corrupt Soundtracker files git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17635 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/codecs/mod.c42
1 files changed, 15 insertions, 27 deletions
diff --git a/apps/codecs/mod.c b/apps/codecs/mod.c
index 0d3eadf773..7bc87c8a42 100644
--- a/apps/codecs/mod.c
+++ b/apps/codecs/mod.c
@@ -374,7 +374,7 @@ STATICIRAM bool loadmod(void *modfile) ICODE_ATTR;
bool loadmod(void *modfile)
{
int i;
- bool periodsconverted = false;
+ unsigned char *periodsconverted;
/* We don't support PowerPacker 2.0 Files */
if (memcmp((char*) modfile, "PP20", 4) == 0) return false;
@@ -401,26 +401,10 @@ bool loadmod(void *modfile)
{modsong.noofchannels = 8; modsong.noofinstruments = 31;}
else if (memcmp(fileformattag, "CD81", 4) == 0)
{modsong.noofchannels = 8; modsong.noofinstruments = 31;}
- else if (memcmp(fileformattag, "RS", 2) == 0)
- {
- /* This is a special internal in-memory fileformat
- * where the periods have been already converted to offsets
- * in our periodtable.
- * It comes to use when rockbox reloads an already played
- * module (e.g. on rewinding) */
- modsong.noofchannels = fileformattag[2];
- modsong.noofinstruments = fileformattag[3];
- periodsconverted = true;
- }
else {
- /* The file has no format tag, so we take a guess */
+ /* The file has no format tag, so most likely soundtracker */
modsong.noofchannels = 4;
-
- /* For the no of instruments we check if there is a sample #16 and
- * if it has a (ascii) name */
- char *p = (char *)modfile + 470;
- if ((*p >= 32) && (*p <= 126)) modsong.noofinstruments = 31;
- else modsong.noofinstruments = 15;
+ modsong.noofinstruments = 15;
}
/* Get the Song title
@@ -458,14 +442,19 @@ bool loadmod(void *modfile)
maxpatterns = modsong.patternordertable[i];
maxpatterns++;
- /* Get the pattern data */
- modsong.patterndata = (char*)modfile + 20 +
- modsong.noofinstruments*30 + 134;
+ /* use 'restartposition' (historically set to 127) which is not used here
+ as a marker that periods have already been converted */
+
+ periodsconverted = (char*)modfile + 20 + modsong.noofinstruments*30 + 1;
+ /* Get the pattern data; ST doesn't have fileformattag, so 4 bytes less */
+ modsong.patterndata = periodsconverted +
+ (modsong.noofinstruments==15 ? 129 : 133);
+
/* Convert the period values in the mod file to offsets
* in our periodtable (but only, if we haven't done this yet) */
p = (unsigned char *) modsong.patterndata;
- if (!periodsconverted)
+ if (*periodsconverted != 0xfe)
{
int note, note2, channel;
for (note=0;note<maxpatterns*64;note++)
@@ -487,10 +476,9 @@ bool loadmod(void *modfile)
p += 4;
}
/* Remember that we already converted the periods,
- * in case the file gets reloaded by rewinding */
- fileformattag[0] = 'R'; fileformattag[1] = 'S';
- fileformattag[2] = modsong.noofchannels;
- fileformattag[3] = modsong.noofinstruments;
+ * in case the file gets reloaded by rewinding
+ * with 0xfe (arbitary magic value > 127) */
+ *periodsconverted = 0xfe;
}
/* Get the samples