From ad4276c7b7945718b1f405dfae580a842820c3f4 Mon Sep 17 00:00:00 2001 From: manakoAT Date: Mon, 10 May 2010 08:02:22 +0000 Subject: [PATCH] fixed the "XIII" dsp meta added PCM coding to NAOMI SPSD git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@794 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- src/layout/blocked.c | 3 +++ src/layout/layout.h | 2 ++ src/libvgmstream.vcproj | 10 +++++++++- src/meta/meta.h | 2 ++ src/meta/naomi_spsd.c | 34 +++++++++++++++++++++++++--------- src/meta/ngc_dsp_std.c | 15 ++++++++------- src/vgmstream.c | 5 +++++ src/vgmstream.h | 2 ++ winamp/in_vgmstream.c | 1 + 9 files changed, 57 insertions(+), 17 deletions(-) diff --git a/src/layout/blocked.c b/src/layout/blocked.c index 33fa27cb..920010db 100644 --- a/src/layout/blocked.c +++ b/src/layout/blocked.c @@ -117,6 +117,9 @@ void render_vgmstream_blocked(sample * buffer, int32_t sample_count, VGMSTREAM * break; case layout_ps2_adm_blocked: ps2_adm_block_update(vgmstream->next_block_offset,vgmstream); + break; + case layout_dsp_bdsp_blocked: + dsp_bdsp_block_update(vgmstream->next_block_offset,vgmstream); break; default: break; diff --git a/src/layout/layout.h b/src/layout/layout.h index 48a03042..feef3d96 100644 --- a/src/layout/layout.h +++ b/src/layout/layout.h @@ -62,4 +62,6 @@ void psx_mgav_block_update(off_t block_offset, VGMSTREAM * vgmstream); void ps2_adm_block_update(off_t block_offset, VGMSTREAM * vgmstream); +void dsp_bdsp_block_update(off_t block_offset, VGMSTREAM * vgmstream); + #endif diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index 7614ee2e..c8c05eec 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -1,7 +1,7 @@  + + @@ -1130,6 +1134,10 @@ RelativePath=".\layout\ast_blocked.c" > + + diff --git a/src/meta/meta.h b/src/meta/meta.h index 45505b91..3ed0ae67 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -503,4 +503,6 @@ VGMSTREAM * init_vgmstream_ps2_adm(STREAMFILE* streamFile); VGMSTREAM * init_vgmstream_ps2_lpcm(STREAMFILE* streamFile); +VGMSTREAM * init_vgmstream_dsp_bdsp(STREAMFILE* streamFile); + #endif diff --git a/src/meta/naomi_spsd.c b/src/meta/naomi_spsd.c index f38e669c..fc566918 100644 --- a/src/meta/naomi_spsd.c +++ b/src/meta/naomi_spsd.c @@ -6,8 +6,9 @@ VGMSTREAM * init_vgmstream_naomi_spsd(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; char filename[260]; off_t start_offset; + int coding; int loop_flag; - int channel_count; + int channel_count; /* check extension, case insensitive */ streamFile->get_name(streamFile,filename,sizeof(filename)); @@ -19,23 +20,38 @@ VGMSTREAM * init_vgmstream_naomi_spsd(STREAMFILE *streamFile) { loop_flag = 0; channel_count = 2; - - /* build the VGMSTREAM */ + + /* build the VGMSTREAM */ vgmstream = allocate_vgmstream(channel_count,loop_flag); if (!vgmstream) goto fail; - /* fill in the vital statistics */ - vgmstream->channels = channel_count; + /* fill in the vital statistics */ start_offset = 0x40; + vgmstream->channels = channel_count; vgmstream->sample_rate = (uint16_t)read_16bitLE(0x2A,streamFile); - vgmstream->coding_type = coding_AICA; - - vgmstream->num_samples = read_32bitLE(0x0C,streamFile); - if (loop_flag) { + switch (read_8bit(0x8,streamFile)) + { + case 0x01: + coding = coding_PCM8; + break; + case 0x03: + coding = coding_AICA; + break; + default: + goto fail; + } + + vgmstream->coding_type = coding; + vgmstream->num_samples = read_32bitLE(0x0C,streamFile); + +#if 0 + if (loop_flag) + { vgmstream->loop_start_sample = 0; vgmstream->loop_end_sample = read_32bitLE(0x0C,streamFile); } +#endif vgmstream->interleave_block_size = 0x2000; if (channel_count > 1) { diff --git a/src/meta/ngc_dsp_std.c b/src/meta/ngc_dsp_std.c index da9b86ff..81dcf6cf 100644 --- a/src/meta/ngc_dsp_std.c +++ b/src/meta/ngc_dsp_std.c @@ -1786,8 +1786,9 @@ fail: return NULL; } -/* .dsp found in Ubisoft games, like "XIII", possibly more - always 2 channels and an interleave of 8 */ +/* .dsp found in: Speed Challenge - Jacques Villeneuve's Racing Vision (NGC) + XIII (NGC) + always 2 channels, and an interleave of 0x8 */ VGMSTREAM * init_vgmstream_dsp_xiii(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; char filename[260]; @@ -1830,7 +1831,7 @@ VGMSTREAM * init_vgmstream_dsp_xiii(STREAMFILE *streamFile) { ch0_header.nibble_count != ch1_header.nibble_count || ch0_header.sample_rate != ch1_header.sample_rate || ch0_header.loop_flag != ch1_header.loop_flag || - ch0_header.loop_start_offset != ch1_header.loop_start_offset || + //ch0_header.loop_start_offset != ch1_header.loop_start_offset || ch0_header.loop_end_offset != ch1_header.loop_end_offset ) goto fail; @@ -1838,7 +1839,7 @@ VGMSTREAM * init_vgmstream_dsp_xiii(STREAMFILE *streamFile) { { off_t loop_off; /* check loop predictor/scale */ - loop_off = ch0_header.loop_start_offset/16*8; + loop_off = 0x0; //ch0_header.loop_start_offset/16*8; if (ch0_header.loop_ps != (uint8_t)read_8bit(ch1_start+loop_off,streamFile)) goto fail; @@ -1846,16 +1847,16 @@ VGMSTREAM * init_vgmstream_dsp_xiii(STREAMFILE *streamFile) { goto fail; } + /* build the VGMSTREAM */ - vgmstream = allocate_vgmstream(2,ch0_header.loop_flag); + vgmstream = allocate_vgmstream(2,ch1_header.loop_flag); if (!vgmstream) goto fail; /* fill in the vital statistics */ vgmstream->num_samples = ch0_header.sample_count; vgmstream->sample_rate = ch0_header.sample_rate; - vgmstream->loop_start_sample = dsp_nibbles_to_samples( - ch0_header.loop_start_offset); + vgmstream->loop_start_sample = 0x0; //dsp_nibbles_to_samples(ch0_header.loop_start_offset); vgmstream->loop_end_sample = dsp_nibbles_to_samples( ch0_header.loop_end_offset)+1; diff --git a/src/vgmstream.c b/src/vgmstream.c index 16ed26f8..467346fe 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -274,6 +274,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_dsp_cabelas, init_vgmstream_ps2_adm, init_vgmstream_ps2_lpcm, + init_vgmstream_dsp_bdsp, }; #define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0])) @@ -712,6 +713,7 @@ void render_vgmstream(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstre case layout_ivaud_blocked: case layout_psx_mgav_blocked: case layout_ps2_adm_blocked: + case layout_dsp_bdsp_blocked: render_vgmstream_blocked(buffer,sample_count,vgmstream); break; case layout_interleave_byte: @@ -1764,6 +1766,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { case layout_ps2_adm_blocked: snprintf(temp,TEMPSIZE,"ADM blocked"); break; + case layout_dsp_bdsp_blocked: + snprintf(temp,TEMPSIZE,"DSP blocked"); + break; #ifdef VGM_USE_MPEG case layout_fake_mpeg: snprintf(temp,TEMPSIZE,"MPEG Audio stream with incorrect frame headers"); diff --git a/src/vgmstream.h b/src/vgmstream.h index 26d44a45..c8066700 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -150,6 +150,7 @@ typedef enum { layout_mxch_blocked, layout_psx_mgav_blocked, layout_ps2_adm_blocked, + layout_dsp_bdsp_blocked, #if 0 layout_strm_blocked, /* */ #endif @@ -469,6 +470,7 @@ typedef enum { meta_DSP_CABELAS, /* Cabelas games */ meta_PS2_ADM, /* Dragon Quest 5 */ meta_PS2_LPCM, /* Ah! My Goddess */ + meta_DSP_BDSP, /* Ah! My Goddess */ } meta_t; typedef struct { diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index 0de1d85f..d6eb591d 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -104,6 +104,7 @@ char * extension_list[] = { "b1s\0B1S Audio File (*.B1S)\0", "baka\0BAKA Audio File (*.BAKA)\0", + "bdsp\0BDSP Audio File (*.BDSP)\0", "bg00\0BG00 Audio File (*.BG00)\0", "bgw\0BGW Audio File (*.BGW)\0", "bh2pcm\0BH2PCM Audio File (*.BH2PCM)\0",