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/gbs.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 apps/metadata/gbs.c (limited to 'apps/metadata/gbs.c') 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 @@ +#include +#include +#include +#include +#include + +#include "system.h" +#include "metadata.h" +#include "metadata_common.h" +#include "metadata_parsers.h" +#include "rbunicode.h" + +bool parse_gbs_header(int fd, struct mp3entry* id3) +{ + /* Use the trackname part of the id3 structure as a temporary buffer */ + unsigned char* buf = (unsigned char *)id3->path; + lseek(fd, 0, SEEK_SET); + if (read(fd, buf, 112) < 112) + return false; + + /* Calculate track length with number of subtracks */ + id3->length = buf[4] * 1000; + + /* If meta info was found in the m3u skip next step */ + if (id3->title && id3->title[0]) return true; + + char *p = id3->id3v2buf; + + /* Some metadata entries have 32 bytes length */ + /* Game */ + memcpy(p, &buf[16], 32); *(p + 33) = '\0'; + id3->title = p; + p += strlen(p)+1; + + /* Artist */ + memcpy(p, &buf[48], 32); *(p + 33) = '\0'; + id3->artist = p; + p += strlen(p)+1; + + /* Copyright */ + memcpy(p, &buf[80], 32); *(p + 33) = '\0'; + id3->album = p; + + return true; +} + +bool get_gbs_metadata(int fd, struct mp3entry* id3) +{ + char gbs_type[3]; + if ((lseek(fd, 0, SEEK_SET) < 0) || + (read(fd, gbs_type, 3) < 3)) + return false; + + id3->vbr = false; + id3->filesize = filesize(fd); + /* we only render 16 bits, 44.1KHz, Stereo */ + id3->bitrate = 706; + id3->frequency = 44100; + + /* Check for GBS magic */ + if (memcmp( gbs_type, "GBS", 3 ) != 0) + return false; + + return parse_gbs_header(fd, id3); +} -- cgit v1.2.3