diff --git a/fb2k/in_vgmstream.cpp b/fb2k/in_vgmstream.cpp index 9d60c359..9dae58a3 100644 --- a/fb2k/in_vgmstream.cpp +++ b/fb2k/in_vgmstream.cpp @@ -340,6 +340,7 @@ bool input_vgmstream::g_is_our_path(const char * p_path,const char * p_extension if(!stricmp_utf8(p_extension,"filp")) return 1; if(!stricmp_utf8(p_extension,"fsb")) return 1; + if(!stricmp_utf8(p_extension,"g1l")) return 1; if(!stricmp_utf8(p_extension,"gbts")) return 1; if(!stricmp_utf8(p_extension,"gca")) return 1; if(!stricmp_utf8(p_extension,"gcm")) return 1; @@ -667,6 +668,7 @@ DECLARE_MULTIPLE_FILE_TYPE("FAG Audio File (*.FAG)", fag); DECLARE_MULTIPLE_FILE_TYPE("FILP Audio File (*.FILP)", filp); DECLARE_MULTIPLE_FILE_TYPE("FSB Audio File (*.FSB)", fsb); +DECLARE_MULTIPLE_FILE_TYPE("G1L Audio File (*.G1L)", g1l); DECLARE_MULTIPLE_FILE_TYPE("GBTS Audio File (*.GBTS)", gbts); DECLARE_MULTIPLE_FILE_TYPE("GCA Audio File (*.GCA)", gca); DECLARE_MULTIPLE_FILE_TYPE("GCM Audio File (*.GCM)", gcm); diff --git a/src/Makefile b/src/Makefile index 98d399c3..d7a6046a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -295,7 +295,8 @@ META_OBJS=meta/adx_header.o \ meta/otm.o \ meta/bcstm.o \ meta/bfstm.o \ - meta/bfwav.o + meta/bfwav.o \ + meta/g1l.o OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS) diff --git a/src/meta/Makefile.unix.am b/src/meta/Makefile.unix.am index 928ab7fa..9cbad508 100644 --- a/src/meta/Makefile.unix.am +++ b/src/meta/Makefile.unix.am @@ -239,7 +239,8 @@ libmeta_la_SOURCES += ubi_ckd.c libmeta_la_SOURCES += otm.c libmeta_la_SOURCES += bcstm.c libmeta_la_SOURCES += bfwav.c -libmeta_la_SOURCES += bfstm.c +libmeta_la_SOURCES += bfstm.c +libmeta_la_SOURCES += g1l.c libmeta_la_SOURCES += ps2_vbk.c EXTRA_DIST = meta.h diff --git a/src/meta/g1l.c b/src/meta/g1l.c new file mode 100644 index 00000000..4220be57 --- /dev/null +++ b/src/meta/g1l.c @@ -0,0 +1,115 @@ +#include "meta.h" +#include "../util.h" + +VGMSTREAM * init_vgmstream_g1l(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + char filename[PATH_LIMIT]; + + coding_t coding_type; + + off_t head_offset; + + int channel_count; + int loop_flag; + off_t start_offset; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile, filename, sizeof(filename)); + if (strcasecmp("g1l", filename_extension(filename))) + goto fail; + + + /* check header */ + if ((uint32_t)read_32bitBE(0, streamFile) != 0x47314C5F) /* "G1L_" */ + goto fail; + if ((uint32_t)read_32bitBE(0x1c, streamFile) != 0x57696942) /* "WiiB" */ + goto fail; + + /* check type details */ +// loop_flag = read_8bit(head_offset + 0x21, streamFile); + if (read_32bitBE(0x30, streamFile) > 0) + loop_flag = 1; + else + loop_flag = 0; + channel_count = read_8bit(0x3f, streamFile); + + + coding_type = coding_NGC_DSP; + + + if (channel_count < 1) goto fail; + + /* build the VGMSTREAM */ + + vgmstream = allocate_vgmstream(channel_count, loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + vgmstream->num_samples = read_32bitBE(0x2c, streamFile); + vgmstream->sample_rate = (uint16_t)read_16bitBE(0x42, streamFile); + /* channels and loop flag are set by allocate_vgmstream */ + + vgmstream->loop_start_sample = read_32bitBE(0x30, streamFile); + vgmstream->loop_end_sample = vgmstream->num_samples; + + + vgmstream->coding_type = coding_type; + if (channel_count == 1) + vgmstream->layout_type = layout_none; + + vgmstream->layout_type = layout_interleave_byte; + + vgmstream->meta_type = meta_G1L; + + vgmstream->interleave_block_size = 0x1; + + if (vgmstream->coding_type == coding_NGC_DSP) { + off_t coef_offset = 0x78; + + int i, j; + int coef_spacing = 0x60; + + + for (j = 0; jchannels; j++) { + for (i = 0; i<16; i++) { + vgmstream->ch[j].adpcm_coef[i] = read_16bitBE(coef_offset + j*coef_spacing + i * 2, streamFile); + } + } + } + + if (vgmstream->coding_type == coding_NGC_DSP) + start_offset = 0x81c; + else // Will add AT3 G1L support later + goto fail; + + + + /* open the file for reading by each channel */ + { + int i; + for (i = 0; ilayout_type == layout_interleave_shortblock) + vgmstream->ch[i].streamfile = streamFile->open(streamFile, filename, + vgmstream->interleave_block_size); + else if (vgmstream->layout_type == layout_interleave) + vgmstream->ch[i].streamfile = streamFile->open(streamFile, filename, + STREAMFILE_DEFAULT_BUFFER_SIZE); + else + vgmstream->ch[i].streamfile = streamFile->open(streamFile, filename, + 0x1000); + + if (!vgmstream->ch[i].streamfile) goto fail; + + vgmstream->ch[i].channel_start_offset = + vgmstream->ch[i].offset = + start_offset + i*vgmstream->interleave_block_size; + } + } + + return vgmstream; + + /* clean up anything we may have opened */ +fail: + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} diff --git a/src/meta/meta.h b/src/meta/meta.h index 7ceb8e21..cb46f018 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -640,4 +640,6 @@ VGMSTREAM * init_vgmstream_bfstm(STREAMFILE* streamFile); VGMSTREAM * init_vgmstream_bfwav(STREAMFILE* streamFile); +VGMSTREAM * init_vgmstream_g1l(STREAMFILE* streamFile); + #endif diff --git a/src/vgmstream.c b/src/vgmstream.c index e046adb5..534de315 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -334,7 +334,8 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_ps2_vbk, init_vgmstream_otm, init_vgmstream_bcstm, - init_vgmstream_3ds_idsp, + init_vgmstream_3ds_idsp, + init_vgmstream_g1l, }; #define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0])) @@ -3079,6 +3080,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { case meta_FSTM: snprintf(temp,TEMPSIZE,"Nintendo Wii U FSTM Header"); break; + case meta_G1L: + snprintf(temp,TEMPSIZE,"Tecmo Koei G1L Header"); + break; case meta_3DS_IDSP: snprintf(temp,TEMPSIZE,"Nintendo 3DS IDSP Header"); break; diff --git a/src/vgmstream.h b/src/vgmstream.h index f737fb52..b6e03993 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -570,6 +570,7 @@ typedef enum { meta_CSTM, // Nintendo 3DS CSTM meta_FSTM, // Nintendo Wii U FSTM meta_3DS_IDSP, // Nintendo 3DS IDSP + meta_G1L, // Tecmo Koei G1L #ifdef VGM_USE_MP4V2 meta_MP4, #endif diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index d0fca2a6..5cb0c648 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -151,6 +151,7 @@ char * extension_list[] = { "filp\0FILP Audio File (*.FILP)\0", "fsb\0FSB Audio File (*.FSB)\0", + "g1l\0G1L Audio File (*.G1L)\0", "gbts\0GBTS Audio File (*.GBTS)\0", "gca\0GCA Audio File (*.GCA)\0", "gcm\0GCM Audio File (*.GCM)\0",