From acb0917556fc33681c1df5a530cf754193e67705 Mon Sep 17 00:00:00 2001 From: Andree Buschmann Date: Sun, 7 Aug 2011 20:01:04 +0000 Subject: Submit initial patch from FS#12176. Adds support for several new game music formats (AY, GBS, HES, KSS, SGC, VGM and VGZ) and replaces the current NSF and NSFE with a new implementation based on a port of the Game Music Emu library 'GME'. This first submit does not cover the full functionality provided by the author's original patch: Coleco-SGV is not supported, some GME-specific m3u-support has been removed and IRAM is not used yet. Further changes are very likely to follow this submit. Thanks to Mauricio Garrido. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30264 a1c6a512-1295-4272-9138-f99709370657 --- apps/metadata/nsf.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'apps/metadata/nsf.c') diff --git a/apps/metadata/nsf.c b/apps/metadata/nsf.c index 29fd8475bb..2fa6f36b12 100644 --- a/apps/metadata/nsf.c +++ b/apps/metadata/nsf.c @@ -11,6 +11,9 @@ #include "rbunicode.h" #include "string-extra.h" +/* NOTE: This file was modified to work properly with the new nsf codec based + on Game_Music_Emu */ + struct NESM_HEADER { uint32_t nHeader; @@ -66,7 +69,7 @@ static bool parse_nsfe(int fd, struct mp3entry *id3) /* default values */ info.nTrackCount = 1; - id3->length = 2*1000*60; + id3->length = 150 * 1000; /* begin reading chunks */ while (!(chunks_found & CHUNK_NEND)) @@ -210,6 +213,10 @@ static bool parse_nsfe(int fd, struct mp3entry *id3) if (track_count | playlist_count) id3->length = MAX(track_count, playlist_count)*1000; + /* Single subtrack files will be treated differently + by gme's nsf codec */ + if (id3->length <= 1000) id3->length = 150 * 1000; + /* * if we exited the while loop without a 'return', we must have hit an NEND * chunk if this is the case, the file was layed out as it was expected. @@ -230,7 +237,7 @@ static bool parse_nesm(int fd, struct mp3entry *id3) return false; /* Length */ - id3->length = hdr.nTrackCount*1000; + id3->length = (hdr.nTrackCount > 1 ? hdr.nTrackCount : 150) * 1000; /* Title */ id3->title = p; @@ -250,7 +257,6 @@ static bool parse_nesm(int fd, struct mp3entry *id3) bool get_nsf_metadata(int fd, struct mp3entry* id3) { uint32_t nsf_type; - if (lseek(fd, 0, SEEK_SET) < 0 || read_uint32be(fd, &nsf_type) != (int)sizeof(nsf_type)) return false; -- cgit v1.2.3