diff options
author | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-08-07 20:01:04 +0000 |
---|---|---|
committer | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-08-07 20:01:04 +0000 |
commit | acb0917556fc33681c1df5a530cf754193e67705 (patch) | |
tree | 052a47097009a210e4aed9c207bd6aa4828cc000 /apps/metadata/gbs.c | |
parent | 93c6f1329a5691a8be158cefe15641bd1daf9ef8 (diff) | |
download | rockbox-acb0917556fc33681c1df5a530cf754193e67705.tar.gz rockbox-acb0917556fc33681c1df5a530cf754193e67705.zip |
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
Diffstat (limited to 'apps/metadata/gbs.c')
-rw-r--r-- | apps/metadata/gbs.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/apps/metadata/gbs.c b/apps/metadata/gbs.c new file mode 100644 index 0000000000..796db5932f --- /dev/null +++ b/apps/metadata/gbs.c | |||
@@ -0,0 +1,65 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <string.h> | ||
3 | #include <stdlib.h> | ||
4 | #include <ctype.h> | ||
5 | #include <inttypes.h> | ||
6 | |||
7 | #include "system.h" | ||
8 | #include "metadata.h" | ||
9 | #include "metadata_common.h" | ||
10 | #include "metadata_parsers.h" | ||
11 | #include "rbunicode.h" | ||
12 | |||
13 | bool parse_gbs_header(int fd, struct mp3entry* id3) | ||
14 | { | ||
15 | /* Use the trackname part of the id3 structure as a temporary buffer */ | ||
16 | unsigned char* buf = (unsigned char *)id3->path; | ||
17 | lseek(fd, 0, SEEK_SET); | ||
18 | if (read(fd, buf, 112) < 112) | ||
19 | return false; | ||
20 | |||
21 | /* Calculate track length with number of subtracks */ | ||
22 | id3->length = buf[4] * 1000; | ||
23 | |||
24 | /* If meta info was found in the m3u skip next step */ | ||
25 | if (id3->title && id3->title[0]) return true; | ||
26 | |||
27 | char *p = id3->id3v2buf; | ||
28 | |||
29 | /* Some metadata entries have 32 bytes length */ | ||
30 | /* Game */ | ||
31 | memcpy(p, &buf[16], 32); *(p + 33) = '\0'; | ||
32 | id3->title = p; | ||
33 | p += strlen(p)+1; | ||
34 | |||
35 | /* Artist */ | ||
36 | memcpy(p, &buf[48], 32); *(p + 33) = '\0'; | ||
37 | id3->artist = p; | ||
38 | p += strlen(p)+1; | ||
39 | |||
40 | /* Copyright */ | ||
41 | memcpy(p, &buf[80], 32); *(p + 33) = '\0'; | ||
42 | id3->album = p; | ||
43 | |||
44 | return true; | ||
45 | } | ||
46 | |||
47 | bool get_gbs_metadata(int fd, struct mp3entry* id3) | ||
48 | { | ||
49 | char gbs_type[3]; | ||
50 | if ((lseek(fd, 0, SEEK_SET) < 0) || | ||
51 | (read(fd, gbs_type, 3) < 3)) | ||
52 | return false; | ||
53 | |||
54 | id3->vbr = false; | ||
55 | id3->filesize = filesize(fd); | ||
56 | /* we only render 16 bits, 44.1KHz, Stereo */ | ||
57 | id3->bitrate = 706; | ||
58 | id3->frequency = 44100; | ||
59 | |||
60 | /* Check for GBS magic */ | ||
61 | if (memcmp( gbs_type, "GBS", 3 ) != 0) | ||
62 | return false; | ||
63 | |||
64 | return parse_gbs_header(fd, id3); | ||
65 | } | ||