From 058b0edb75cc3b05b390a8c8bef181965c5de20e Mon Sep 17 00:00:00 2001 From: manakoAT Date: Thu, 30 Oct 2008 15:43:36 +0000 Subject: [PATCH] .asd added for DC (Miss Moonlight) git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@457 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- src/Makefile | 3 +- src/libvgmstream.vcproj | 4 ++ src/meta/Makefile.unix.am | 1 + src/meta/dc_asd.c | 81 +++++++++++++++++++++++++++++++++++++++ src/meta/meta.h | 2 + src/vgmstream.c | 4 ++ src/vgmstream.h | 2 +- winamp/in_vgmstream.c | 1 + 8 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 src/meta/dc_asd.c diff --git a/src/Makefile b/src/Makefile index 17d3130a..c45d8a22 100644 --- a/src/Makefile +++ b/src/Makefile @@ -140,7 +140,8 @@ META_OBJS=meta/adx_header.o \ meta/psx_fag.o \ meta/ps2_mihb.o \ meta/ngc_pdt.o \ - meta/wii_mus.o + meta/wii_mus.o \ + meta/dc_asd.o OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS) diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index 2a0eb713..92bc1d43 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -235,6 +235,10 @@ RelativePath=".\meta\Cstr.c" > + + diff --git a/src/meta/Makefile.unix.am b/src/meta/Makefile.unix.am index 6b89b378..9c44eb93 100644 --- a/src/meta/Makefile.unix.am +++ b/src/meta/Makefile.unix.am @@ -109,4 +109,5 @@ libmeta_la_SOURCES += psx_fag.c libmeta_la_SOURCES += ps2_mihb.c libmeta_la_SOURCES += ngc_pdt.c libmeta_la_SOURCES += wii_mus.c +libmeta_la_SOURCES += dc_asd.c EXTRA_DIST = meta.h diff --git a/src/meta/dc_asd.c b/src/meta/dc_asd.c new file mode 100644 index 00000000..7a751823 --- /dev/null +++ b/src/meta/dc_asd.c @@ -0,0 +1,81 @@ +#include "meta.h" +#include "../util.h" + +/* ASD (found in Miss Moonlight) */ +VGMSTREAM * init_vgmstream_dc_asd(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("asd",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x20,streamFile) != 0x00000000) + goto fail; + if (read_32bitBE(0x24,streamFile) != 0x00000000) + goto fail; + + loop_flag = 0; /* (read_32bitLE(0x144,streamFile)!=0); */ + channel_count = read_16bitLE(0x0A,streamFile); + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + + /* fill in the vital statistics */ + start_offset = 0x800; + vgmstream->channels = channel_count; + vgmstream->sample_rate = read_32bitLE(0x0C,streamFile); + vgmstream->coding_type = coding_PCM16LE; + vgmstream->num_samples = read_32bitLE(0x0,streamFile)/2/channel_count; + if (loop_flag) { + vgmstream->loop_start_sample = 0; /* read_32bitLE(0x144,streamFile)/2/channel_count; */ + vgmstream->loop_end_sample = read_32bitLE(0x0,streamFile)/2/channel_count; + } + + + + switch (channel_count) { + case 1: + vgmstream->layout_type = layout_none; + break; + case 2: + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = 0x2; + break; + default: + goto fail; + } + + + vgmstream->meta_type = meta_DC_ASD; + + /* open the file for reading */ + { + int i; + STREAMFILE * file; + file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); + if (!file) goto fail; + for (i=0;ich[i].streamfile = file; + + vgmstream->ch[i].channel_start_offset= + vgmstream->ch[i].offset=start_offset+ + vgmstream->interleave_block_size*i; + + } + } + + 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 1eaca658..46131e0a 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -247,4 +247,6 @@ VGMSTREAM * init_vgmstream_rsd4vag(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_rsd6vag(STREAMFILE * streamFile); +VGMSTREAM * init_vgmstream_dc_asd(STREAMFILE * streamFile); + #endif diff --git a/src/vgmstream.c b/src/vgmstream.c index 61f01b36..256c862d 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -134,6 +134,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_ps2_mihb, init_vgmstream_ngc_pdt, init_vgmstream_wii_mus, + init_vgmstream_dc_asd, init_vgmstream_rsd2vag, init_vgmstream_rsd2xadp, @@ -1732,6 +1733,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { break; case meta_RSD6VAG: snprintf(temp,TEMPSIZE,"RSD6/VAG Header"); + break; + case meta_DC_ASD: + snprintf(temp,TEMPSIZE,"ASD Header"); break; default: snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET"); diff --git a/src/vgmstream.h b/src/vgmstream.h index c4779a90..89678d50 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -241,7 +241,7 @@ typedef enum { meta_PSX_FAG, /* Jackie Chan - Stuntmaster */ meta_PS2_MIHB, /* Merged MIH+MIB */ meta_NGC_PDT, /* Mario Party 6 */ - + meta_DC_ASD, /* Miss Moonligh */ meta_RSD2VAG, /* RSD2VAG */ meta_RSD2XADP, /* RSD2XADP */ meta_RSD4PCMB, /* RSD4PCMB */ diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index dd0537d8..33722b4c 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -190,6 +190,7 @@ char * extension_list[] = { "fag\0FAG Audio File (*.FAG)\0", "mihb\0MIHB Audio File (*.MIHB)\0", "pdt\0PDT Audio File (*.PDT)\0", + "asd\0ASD Audio File (*.ASD)\0", }; void about(HWND hwndParent) {