summaryrefslogtreecommitdiff
path: root/apps/metadata/nsf.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/metadata/nsf.c')
-rw-r--r--apps/metadata/nsf.c12
1 files changed, 9 insertions, 3 deletions
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 @@
11#include "rbunicode.h" 11#include "rbunicode.h"
12#include "string-extra.h" 12#include "string-extra.h"
13 13
14/* NOTE: This file was modified to work properly with the new nsf codec based
15 on Game_Music_Emu */
16
14struct NESM_HEADER 17struct NESM_HEADER
15{ 18{
16 uint32_t nHeader; 19 uint32_t nHeader;
@@ -66,7 +69,7 @@ static bool parse_nsfe(int fd, struct mp3entry *id3)
66 69
67 /* default values */ 70 /* default values */
68 info.nTrackCount = 1; 71 info.nTrackCount = 1;
69 id3->length = 2*1000*60; 72 id3->length = 150 * 1000;
70 73
71 /* begin reading chunks */ 74 /* begin reading chunks */
72 while (!(chunks_found & CHUNK_NEND)) 75 while (!(chunks_found & CHUNK_NEND))
@@ -210,6 +213,10 @@ static bool parse_nsfe(int fd, struct mp3entry *id3)
210 if (track_count | playlist_count) 213 if (track_count | playlist_count)
211 id3->length = MAX(track_count, playlist_count)*1000; 214 id3->length = MAX(track_count, playlist_count)*1000;
212 215
216 /* Single subtrack files will be treated differently
217 by gme's nsf codec */
218 if (id3->length <= 1000) id3->length = 150 * 1000;
219
213 /* 220 /*
214 * if we exited the while loop without a 'return', we must have hit an NEND 221 * if we exited the while loop without a 'return', we must have hit an NEND
215 * chunk if this is the case, the file was layed out as it was expected. 222 * 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)
230 return false; 237 return false;
231 238
232 /* Length */ 239 /* Length */
233 id3->length = hdr.nTrackCount*1000; 240 id3->length = (hdr.nTrackCount > 1 ? hdr.nTrackCount : 150) * 1000;
234 241
235 /* Title */ 242 /* Title */
236 id3->title = p; 243 id3->title = p;
@@ -250,7 +257,6 @@ static bool parse_nesm(int fd, struct mp3entry *id3)
250bool get_nsf_metadata(int fd, struct mp3entry* id3) 257bool get_nsf_metadata(int fd, struct mp3entry* id3)
251{ 258{
252 uint32_t nsf_type; 259 uint32_t nsf_type;
253
254 if (lseek(fd, 0, SEEK_SET) < 0 || 260 if (lseek(fd, 0, SEEK_SET) < 0 ||
255 read_uint32be(fd, &nsf_type) != (int)sizeof(nsf_type)) 261 read_uint32be(fd, &nsf_type) != (int)sizeof(nsf_type))
256 return false; 262 return false;