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/kss.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/kss.c')
-rw-r--r-- | apps/metadata/kss.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/apps/metadata/kss.c b/apps/metadata/kss.c new file mode 100644 index 0000000000..ecb59b8353 --- /dev/null +++ b/apps/metadata/kss.c | |||
@@ -0,0 +1,53 @@ | |||
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_kss_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 | |||
18 | lseek(fd, 0, SEEK_SET); | ||
19 | if (read(fd, buf, 0x20) < 0x20) | ||
20 | return false; | ||
21 | |||
22 | /* calculate track length with number of tracks */ | ||
23 | id3->length = 0; | ||
24 | if (buf[14] == 0x10) { | ||
25 | id3->length = (get_short_le((void *)(buf + 26)) + 1) * 1000; | ||
26 | } | ||
27 | |||
28 | if (id3->length <= 0) | ||
29 | id3->length = 255 * 1000; /* 255 tracks */ | ||
30 | |||
31 | return true; | ||
32 | } | ||
33 | |||
34 | |||
35 | bool get_kss_metadata(int fd, struct mp3entry* id3) | ||
36 | { | ||
37 | uint32_t kss_type; | ||
38 | if ((lseek(fd, 0, SEEK_SET) < 0) || | ||
39 | read_uint32be(fd, &kss_type) != (int)sizeof(kss_type)) | ||
40 | return false; | ||
41 | |||
42 | id3->vbr = false; | ||
43 | id3->filesize = filesize(fd); | ||
44 | /* we only render 16 bits, 44.1KHz, Stereo */ | ||
45 | id3->bitrate = 706; | ||
46 | id3->frequency = 44100; | ||
47 | |||
48 | /* Make sure this is an SGC file */ | ||
49 | if (kss_type != FOURCC('K','S','C','C') && kss_type != FOURCC('K','S','S','X')) | ||
50 | return false; | ||
51 | |||
52 | return parse_kss_header(fd, id3); | ||
53 | } | ||