From 9c7283eda0d3cc0f880526f7db14c237e29a5c05 Mon Sep 17 00:00:00 2001 From: bxaimc Date: Mon, 22 Nov 2010 01:45:39 +0000 Subject: [PATCH] Initial .RAS support (incomplete but working) added for Donkey Kong Country Returns (Wii). Loop and other code will need to be added once other files are found. Other incomplete/unused code that breaks vgmstream commented out for now. git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@881 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- fb2k/in_vgmstream.cpp | 2 ++ src/Makefile | 3 +- src/layout/blocked.c | 4 +-- src/libvgmstream.vcproj | 4 +++ src/meta/Makefile.unix.am | 1 + src/meta/meta.h | 8 ++--- src/meta/ps3_sgh_sgb.c | 40 ++++++++++----------- src/meta/wii_ras.c | 74 +++++++++++++++++++++++++++++++++++++++ src/meta/xbox_wavm.c | 2 ++ src/vgmstream.c | 26 ++++++++------ src/vgmstream.h | 9 ++--- unix/data.c | 1 + winamp/in_vgmstream.c | 3 +- 13 files changed, 134 insertions(+), 43 deletions(-) create mode 100644 src/meta/wii_ras.c diff --git a/fb2k/in_vgmstream.cpp b/fb2k/in_vgmstream.cpp index 2beab8d2..cdbafa72 100644 --- a/fb2k/in_vgmstream.cpp +++ b/fb2k/in_vgmstream.cpp @@ -397,6 +397,7 @@ bool input_vgmstream::g_is_our_path(const char * p_path,const char * p_extension if(!stricmp_utf8(p_extension,"psh")) return 1; if(!stricmp_utf8(p_extension,"psw")) return 1; + if(!stricmp_utf8(p_extension,"ras")) return 1; if(!stricmp_utf8(p_extension,"raw")) return 1; if(!stricmp_utf8(p_extension,"rkv")) return 1; if(!stricmp_utf8(p_extension,"rnd")) return 1; @@ -690,6 +691,7 @@ DECLARE_MULTIPLE_FILE_TYPE("PS2STM Audio File (*.PS2STM)", ps2stm); DECLARE_MULTIPLE_FILE_TYPE("PSH Audio File (*.PSH)", psh); DECLARE_MULTIPLE_FILE_TYPE("PSW Audio File (*.PSW)", psw); +DECLARE_MULTIPLE_FILE_TYPE("RAS Audio File (*.RAS)", ras); DECLARE_MULTIPLE_FILE_TYPE("RAW Audio File (*.RAW)", raw); DECLARE_MULTIPLE_FILE_TYPE("RKV Audio File (*.RKV)", rkv); DECLARE_MULTIPLE_FILE_TYPE("RND Audio File (*.RND)", rnd); diff --git a/src/Makefile b/src/Makefile index db522dad..fd622144 100644 --- a/src/Makefile +++ b/src/Makefile @@ -260,7 +260,8 @@ META_OBJS=meta/adx_header.o \ meta/nub.o \ meta/ps3_past.o \ meta/ps3_sgh_sgb.o \ - meta/ngca.o + meta/ngca.o \ + meta/wii_ras.o OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS) diff --git a/src/layout/blocked.c b/src/layout/blocked.c index 145db7c0..ec994a5a 100644 --- a/src/layout/blocked.c +++ b/src/layout/blocked.c @@ -121,10 +121,10 @@ void render_vgmstream_blocked(sample * buffer, int32_t sample_count, VGMSTREAM * case layout_dsp_bdsp_blocked: dsp_bdsp_block_update(vgmstream->next_block_offset,vgmstream); break; - case layout_mtaf_blocked: + /*case layout_mtaf_blocked: mtaf_block_update(vgmstream->next_block_offset,vgmstream); case layout_tra_blocked: - tra_block_update(vgmstream->next_block_offset,vgmstream); + tra_block_update(vgmstream->next_block_offset,vgmstream);*/ default: break; } diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index 1301f15e..60faa089 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -978,6 +978,10 @@ RelativePath=".\meta\wii_mus.c" > + + diff --git a/src/meta/Makefile.unix.am b/src/meta/Makefile.unix.am index c4d2f333..985874a5 100644 --- a/src/meta/Makefile.unix.am +++ b/src/meta/Makefile.unix.am @@ -213,5 +213,6 @@ libmeta_la_SOURCES += nub.c libmeta_la_SOURCES += ps3_past.c libmeta_la_SOURCES += ps3_sgh_sgb.c libmeta_la_SOURCES += ngca.c +libmeta_la_SOURCES += wii_ras.c EXTRA_DIST = meta.h diff --git a/src/meta/meta.h b/src/meta/meta.h index 473a27a3..97a91a71 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -543,12 +543,12 @@ VGMSTREAM * init_vgmstream_nub_vag(STREAMFILE* streamFile); VGMSTREAM * init_vgmstream_ps3_past(STREAMFILE* streamFile); -VGMSTREAM * init_vgmstream_ps3_sghb(STREAMFILE* streamFile); +VGMSTREAM * init_vgmstream_ps3_sgh_sgb(STREAMFILE* streamFile); -VGMSTREAM * init_vgmstream_xbox_tra(STREAMFILE* streamFile); +//VGMSTREAM * init_vgmstream_xbox_tra(STREAMFILE* streamFile); +VGMSTREAM * init_vgmstream_ngca(STREAMFILE* streamFile); -//VGMSTREAM * init_vgmstream_ngca(STREAMFILE* streamFile); - +VGMSTREAM * init_vgmstream_wii_ras(STREAMFILE* streamFile); #endif diff --git a/src/meta/ps3_sgh_sgb.c b/src/meta/ps3_sgh_sgb.c index 0b222ee8..6a78c7e2 100644 --- a/src/meta/ps3_sgh_sgb.c +++ b/src/meta/ps3_sgh_sgb.c @@ -4,28 +4,28 @@ /* SGH+SGB (from Folklore) */ VGMSTREAM * init_vgmstream_ps3_sgh_sgb(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; - off_t start_offset = 0; - STREAMFILE * streamFileSGH = NULL; - char filename[260]; - char filenameSGH[260]; - int channel_count; + off_t start_offset = 0; + STREAMFILE * streamFileSGH = NULL; + char filename[260]; + char filenameSGH[260]; + int channel_count; int loop_flag; /* check extension, case insensitive */ streamFile->get_name(streamFile,filename,sizeof(filename)); if (strcasecmp("sgb",filename_extension(filename))) goto fail; - strcpy(filenameSGH,filename); + strcpy(filenameSGH,filename); strcpy(filenameSGH+strlen(filenameSGH)-3,"sgh"); - streamFileSGH = streamFile->open(streamFile,filenameSGH,STREAMFILE_DEFAULT_BUFFER_SIZE); - if (!streamFileSGH) goto fail; - - /* check header */ - if (read_32bitBE(0x00,streamFileSGH) != 0x53475844) /* "SGXD" */ + streamFileSGH = streamFile->open(streamFile,filenameSGH,STREAMFILE_DEFAULT_BUFFER_SIZE); + if (!streamFileSGH) goto fail; + + /* check header */ + if (read_32bitBE(0x00,streamFileSGH) != 0x53475844) /* "SGXD" */ goto fail; - channel_count = read_32bitLE(0x6C,streamFileSGH); + channel_count = read_32bitLE(0x6C,streamFileSGH); if (read_32bitBE(0x44,streamFileSGH)==0xFFFFFFFF) loop_flag = 0; else @@ -36,14 +36,14 @@ VGMSTREAM * init_vgmstream_ps3_sgh_sgb(STREAMFILE *streamFile) { if (!vgmstream) goto fail; /* fill in the vital statistics */ - vgmstream->channels = channel_count; - vgmstream->sample_rate = read_32bitLE(0x2C,streamFileSGH); - vgmstream->num_samples = read_32bitLE(0xC,streamFileSGH)*28/32; - vgmstream->coding_type = coding_PSX; - if(loop_flag) { - vgmstream->loop_start_sample = read_32bitLE(0x44,streamFileSGH); - vgmstream->loop_end_sample = read_32bitLE(0x48,streamFileSGH); - } + vgmstream->channels = channel_count; + vgmstream->sample_rate = read_32bitLE(0x2C,streamFileSGH); + vgmstream->num_samples = read_32bitLE(0xC,streamFileSGH)*28/32; + vgmstream->coding_type = coding_PSX; + if(loop_flag) { + vgmstream->loop_start_sample = read_32bitLE(0x44,streamFileSGH); + vgmstream->loop_end_sample = read_32bitLE(0x48,streamFileSGH); + } vgmstream->layout_type = layout_interleave; diff --git a/src/meta/wii_ras.c b/src/meta/wii_ras.c new file mode 100644 index 00000000..a6dfe69d --- /dev/null +++ b/src/meta/wii_ras.c @@ -0,0 +1,74 @@ +#include "meta.h" +#include "../util.h" + +/* RAS (from Donkey Kong Country Returns) */ +VGMSTREAM * init_vgmstream_wii_ras(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + char filename[260]; + off_t start_offset; + + int loop_flag; + int channel_count; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("ras",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x00,streamFile) != 0x5241535F) /* "RAS_" */ + goto fail; + + loop_flag = 0; + channel_count = 2; + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + start_offset = read_32bitBE(0x18,streamFile); + vgmstream->channels = channel_count; + vgmstream->sample_rate = read_32bitBE(0x14,streamFile); + vgmstream->coding_type = coding_NGC_DSP; + vgmstream->num_samples = read_32bitBE(0xc,streamFile); + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = read_32bitBE(0x20,streamFile); + vgmstream->meta_type = meta_WII_RAS; + + if (vgmstream->coding_type == coding_NGC_DSP) { + int i; + for (i=0;i<16;i++) { + vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(0x40+i*2,streamFile); + } + if (channel_count == 2) { + for (i=0;i<16;i++) + vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(0x70+i*2,streamFile); + } + } + + /* open the file for reading */ + { + int i; + for (i=0;ilayout_type==layout_interleave_shortblock) + vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename, + vgmstream->interleave_block_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/xbox_wavm.c b/src/meta/xbox_wavm.c index 18953a54..81361933 100644 --- a/src/meta/xbox_wavm.c +++ b/src/meta/xbox_wavm.c @@ -60,6 +60,7 @@ fail: return NULL; } +#ifdef x360_tra VGMSTREAM * init_vgmstream_xbox_tra(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; char filename[260]; @@ -110,3 +111,4 @@ fail: if (vgmstream) close_vgmstream(vgmstream); return NULL; } +#endif \ No newline at end of file diff --git a/src/vgmstream.c b/src/vgmstream.c index f534e47c..1e99959c 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -282,7 +282,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_dsp_dspw, init_vgmstream_ps2_jstm, init_vgmstream_ps3_xvag, - init_vgmstream_ps2_mtaf, + //init_vgmstream_ps2_mtaf, init_vgmstream_ps3_cps, init_vgmstream_se_scd, init_vgmstream_ngc_nst_dsp, @@ -291,9 +291,10 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_fsb_mpeg, init_vgmstream_nub_vag, init_vgmstream_ps3_past, -// init_vgmstream_ps3_sgh_sgb, - init_vgmstream_xbox_tra, - //init_vgmstream_ngca, + init_vgmstream_ps3_sgh_sgb, + //init_vgmstream_xbox_tra, + init_vgmstream_ngca, + init_vgmstream_wii_ras, }; #define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0])) @@ -735,10 +736,10 @@ void render_vgmstream(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstre case layout_psx_mgav_blocked: case layout_ps2_adm_blocked: case layout_dsp_bdsp_blocked: - case layout_mtaf_blocked: - case layout_tra_blocked: + //case layout_mtaf_blocked: + /*case layout_tra_blocked: render_vgmstream_blocked(buffer,sample_count,vgmstream); - break; + break;*/ case layout_interleave_byte: render_vgmstream_interleave_byte(buffer,sample_count,vgmstream); break; @@ -1771,9 +1772,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { case layout_mxch_blocked: snprintf(temp,TEMPSIZE,"MxCh blocked"); break; - case layout_mtaf_blocked: + /*case layout_mtaf_blocked: snprintf(temp,TEMPSIZE,"MTAF blocked"); - break; + break; */ case layout_ast_blocked: snprintf(temp,TEMPSIZE,"AST blocked"); break; @@ -2723,8 +2724,11 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { case meta_NGCA: snprintf(temp,TEMPSIZE,"NGCA header"); break; - case meta_X360_TRA: - snprintf(temp,TEMPSIZE,"Assume Def Jam Rapstar Track by .tra extension"); + /*case meta_X360_TRA: + snprintf(temp,TEMPSIZE,"Assume Def Jam Rapstar Track by .tra extension"); */ + case meta_WII_RAS: + snprintf(temp,TEMPSIZE,"RAS header"); + break; default: snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET"); } diff --git a/src/vgmstream.h b/src/vgmstream.h index 026ddd9f..cb29bc7d 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -158,8 +158,8 @@ typedef enum { layout_ps2_adm_blocked, layout_dsp_bdsp_blocked, layout_mxch_blocked, - layout_mtaf_blocked, - layout_tra_blocked, + //layout_mtaf_blocked, + //layout_tra_blocked, #if 0 layout_strm_blocked, /* */ @@ -492,14 +492,15 @@ typedef enum { meta_NGC_NST_DSP, /* Animaniacs [NGC] */ meta_BAF, /* .baf (Blur) */ meta_PS3_XVAG, /* Ratchet & Clank Future: Quest for Booty (PS3) */ - meta_PS2_MTAF, /* Metal Gear 3 MTAF */ + //meta_PS2_MTAF, /* Metal Gear 3 MTAF */ meta_PS3_CPS, /* Eternal Sonata (PS3) */ meta_PS3_MSF, /* MSF header */ meta_NUB_VAG, /* VAG from Nub archives */ meta_PS3_PAST, /* Bakugan Battle Brawlers (PS3) */ meta_PS3_SGH_SGB, /* Folklore (PS3) */ meta_NGCA, /* GoldenEye 007 (Wii) */ - meta_X360_TRA, /* Def Jam Rapstar */ + //meta_X360_TRA, /* Def Jam Rapstar */ + meta_WII_RAS, /* Donkey Kong Country Returns (Wii) */ } meta_t; typedef struct { diff --git a/unix/data.c b/unix/data.c index 3a15ea66..37ae56c4 100644 --- a/unix/data.c +++ b/unix/data.c @@ -153,6 +153,7 @@ gchar *vgmstream_exts [] = { "psh", "psw", + "ras", "raw", "rkv", "rnd", diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index 9291cac5..446f89aa 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -220,7 +220,8 @@ char * extension_list[] = { "psh\0PSH Audio File (*.PSH)\0", "psw\0PSW Audio File (*.PSW)\0", - "raw\0RAW Audio File (*.RAW)\0", + "ras\0RAS Audio File (*.RAS)\0", + "raw\0RAW Audio File (*.RAW)\0", "rkv\0RKV Audio File (*.RKV)\0", "rnd\0RND Audio File (*.RND)\0", "rrds\0RRDS Audio File (*.RRDS)\0",