Add Hyrule Warriors G1L

This commit is contained in:
soneek 2014-10-19 17:10:31 -04:00
parent 115da3222f
commit 76062dbbdc
8 changed files with 130 additions and 3 deletions

View File

@ -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);

View File

@ -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)

View File

@ -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

115
src/meta/g1l.c Normal file
View File

@ -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; j<vgmstream->channels; 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; i<channel_count; i++) {
if (vgmstream->layout_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;
}

View File

@ -640,4 +640,6 @@ VGMSTREAM * init_vgmstream_bfstm(STREAMFILE* streamFile);
VGMSTREAM * init_vgmstream_bfwav(STREAMFILE* streamFile);
VGMSTREAM * init_vgmstream_g1l(STREAMFILE* streamFile);
#endif

View File

@ -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;

View File

@ -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

View File

@ -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",