diff --git a/src/formats.c b/src/formats.c index d03539d6..445b64e3 100644 --- a/src/formats.c +++ b/src/formats.c @@ -564,7 +564,7 @@ static const layout_info layout_info_list[] = { {layout_gsb_blocked, "GSB blocked"}, {layout_thp_blocked, "THP Movie Audio blocked"}, {layout_filp_blocked, "FILp blocked"}, - {layout_psx_mgav_blocked, "MGAV blocked"}, + {layout_blocked_ea_swvr, "blocked (EA SWVR)"}, {layout_ps2_adm_blocked, "ADM blocked"}, {layout_dsp_bdsp_blocked, "DSP blocked"}, {layout_blocked_ivaud, "blocked (IVAUD)"}, @@ -838,7 +838,7 @@ static const meta_info meta_info_list[] = { {meta_PS2_ADSC, "ADSC Header"}, {meta_NGC_DSP_MPDS, "MPDS DSP header"}, {meta_DSP_STR_IG, "Infogrames dual dsp header"}, - {meta_PSX_MGAV, "Electronic Arts RVWS header"}, + {meta_EA_SWVR, "Electronic Arts SWVR header"}, {meta_PS2_B1S, "B1S header"}, {meta_PS2_WAD, "WAD header"}, {meta_DSP_XIII, "XIII dsp header"}, diff --git a/src/layout/blocked.c b/src/layout/blocked.c index b8bd1c60..b6b1530f 100644 --- a/src/layout/blocked.c +++ b/src/layout/blocked.c @@ -128,8 +128,8 @@ void render_vgmstream_blocked(sample * buffer, int32_t sample_count, VGMSTREAM * case layout_blocked_ivaud: block_update_ivaud(vgmstream->next_block_offset,vgmstream); break; - case layout_psx_mgav_blocked: - psx_mgav_block_update(vgmstream->next_block_offset,vgmstream); + case layout_blocked_ea_swvr: + block_update_ea_swvr(vgmstream->next_block_offset,vgmstream); break; case layout_ps2_adm_blocked: ps2_adm_block_update(vgmstream->next_block_offset,vgmstream); diff --git a/src/layout/layout.h b/src/layout/layout.h index 41a40c4a..466281ef 100644 --- a/src/layout/layout.h +++ b/src/layout/layout.h @@ -46,7 +46,7 @@ void filp_block_update(off_t block_offset, VGMSTREAM * vgmstream); void block_update_ivaud(off_t block_offset, VGMSTREAM * vgmstream); -void psx_mgav_block_update(off_t block_offset, VGMSTREAM * vgmstream); +void block_update_ea_swvr(off_t block_offset, VGMSTREAM * vgmstream); void ps2_adm_block_update(off_t block_offset, VGMSTREAM * vgmstream); diff --git a/src/layout/psx_mgav_blocked.c b/src/layout/psx_mgav_blocked.c index e2a3d21a..d4206b5c 100644 --- a/src/layout/psx_mgav_blocked.c +++ b/src/layout/psx_mgav_blocked.c @@ -2,16 +2,17 @@ #include "../vgmstream.h" /* set up for the block at the given offset */ -void psx_mgav_block_update(off_t block_offset, VGMSTREAM * vgmstream) { +void block_update_ea_swvr(off_t block_offset, VGMSTREAM * vgmstream) { + STREAMFILE* streamFile = vgmstream->ch[0].streamfile; int i; + int32_t (*read_32bit)(off_t,STREAMFILE*) = vgmstream->codec_endian ? read_32bitBE : read_32bitLE; - vgmstream->current_block_offset = block_offset; - vgmstream->current_block_size = read_32bitLE(vgmstream->current_block_offset+0x04,vgmstream->ch[0].streamfile)-0x1C; - vgmstream->next_block_offset = vgmstream->current_block_offset+vgmstream->current_block_size+0x1C; - vgmstream->current_block_size/=vgmstream->channels; + vgmstream->current_block_offset = block_offset; + vgmstream->current_block_size = read_32bit(vgmstream->current_block_offset+0x04,streamFile)-0x1C; + vgmstream->next_block_offset = vgmstream->current_block_offset+vgmstream->current_block_size+0x1C; + vgmstream->current_block_size/=vgmstream->channels; - for (i=0;ichannels;i++) { + for (i=0;ichannels;i++) { vgmstream->ch[i].offset = vgmstream->current_block_offset+0x1C+(vgmstream->current_block_size*i); - } } diff --git a/src/meta/meta.h b/src/meta/meta.h index 8088dc7c..89e049d6 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -490,7 +490,7 @@ VGMSTREAM * init_vgmstream_ngc_dsp_mpds(STREAMFILE* streamFile); VGMSTREAM * init_vgmstream_dsp_str_ig(STREAMFILE* streamFile); -VGMSTREAM * init_vgmstream_psx_mgav(STREAMFILE* streamFile); +VGMSTREAM * init_vgmstream_ea_swvr(STREAMFILE* streamFile); VGMSTREAM * init_vgmstream_ngc_dsp_sth_str1(STREAMFILE* streamFile); VGMSTREAM * init_vgmstream_ngc_dsp_sth_str2(STREAMFILE* streamFile); diff --git a/src/meta/psx_str_mgav.c b/src/meta/psx_str_mgav.c index 0951fc10..8c996947 100644 --- a/src/meta/psx_str_mgav.c +++ b/src/meta/psx_str_mgav.c @@ -1,77 +1,80 @@ #include "meta.h" #include "../layout/layout.h" -#include "../util.h" +#include "../coding/coding.h" -/* STR (Future Cop L.A.P.D.) */ -VGMSTREAM * init_vgmstream_psx_mgav(STREAMFILE *streamFile) { + +/* SWVR - from EA games [Future Cop L.A.P.D. (PS/PC), Freekstyle (PS2/GC), EA Sports Supercross (PS)] */ +VGMSTREAM * init_vgmstream_ea_swvr(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; - off_t start_offset; - off_t current_chunk; - char filename[PATH_LIMIT]; - int loop_flag = 0; - int channel_count; - int dataBuffer = 0; - int i; + off_t start_offset; + int loop_flag = 0, channel_count; + int big_endian; + int32_t (*read_32bit)(off_t,STREAMFILE*) = NULL; - /* check extension, case insensitive */ - streamFile->get_name(streamFile,filename,sizeof(filename)); - if (strcasecmp("str",filename_extension(filename))) goto fail; - /* check header */ - if (read_32bitBE(0x00,streamFile) != 0x52565753) /* "RVWS" */ + /* check extension */ + if (!check_extensions(streamFile,"str")) goto fail; + /* check header */ + if (read_32bitBE(0x00,streamFile) == 0x53575652) { /* "SWVR" (GC) */ + big_endian = 1; + read_32bit = read_32bitBE; + } + else if (read_32bitBE(0x00,streamFile) == 0x52565753) { /* "RVWS" (PS/PS2) */ + big_endian = 0; + read_32bit = read_32bitLE; + } + else { + goto fail; + } + + + start_offset = read_32bit(0x04,streamFile); loop_flag = 1; 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 */ - start_offset = read_32bitLE(0x4,streamFile); - vgmstream->channels = channel_count; vgmstream->sample_rate = 16000; + vgmstream->codec_endian = big_endian; + + vgmstream->meta_type = meta_EA_SWVR; + vgmstream->layout_type = layout_blocked_ea_swvr; + vgmstream->coding_type = coding_PSX; - vgmstream->layout_type = layout_psx_mgav_blocked; - vgmstream->meta_type = meta_PSX_MGAV; - /* open the file for reading */ + if (!vgmstream_open_stream(vgmstream,streamFile,start_offset)) + goto fail; + + + /* calculate samples */ { - STREAMFILE * file; - file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); - if (!file) goto fail; - for (i=0;ich[i].streamfile = file; - } - } - - // calculate samples - current_chunk = start_offset; - vgmstream->num_samples = 0; - while ((current_chunk + start_offset) < (get_streamfile_size(streamFile))) - { - dataBuffer = (read_32bitBE(current_chunk,streamFile)); - if (dataBuffer == 0x4D474156) /* "MGAV" */ - { - psx_mgav_block_update(start_offset,vgmstream); - vgmstream->num_samples += vgmstream->current_block_size/16*28; - current_chunk += vgmstream->current_block_size + 0x1C; - } - current_chunk += 0x10; - } + off_t current_chunk = start_offset; + vgmstream->num_samples = 0; + while ((current_chunk + start_offset) < (get_streamfile_size(streamFile))) { + uint32_t block_id = (read_32bit(current_chunk,streamFile)); + if (block_id == 0x5641474D) { /* "VAGM" */ + block_update_ea_swvr(start_offset,vgmstream); + vgmstream->num_samples += vgmstream->current_block_size/16*28; + current_chunk += vgmstream->current_block_size + 0x1C; + } + current_chunk += 0x10; + } + } if (loop_flag) { vgmstream->loop_start_sample = 0; vgmstream->loop_end_sample = vgmstream->num_samples; } - return vgmstream; - /* clean up anything we may have opened */ fail: - if (vgmstream) close_vgmstream(vgmstream); + close_vgmstream(vgmstream); return NULL; } diff --git a/src/vgmstream.c b/src/vgmstream.c index af81004f..c9d88360 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -265,7 +265,7 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = { init_vgmstream_ps2_adsc, init_vgmstream_ngc_dsp_mpds, init_vgmstream_dsp_str_ig, - init_vgmstream_psx_mgav, + init_vgmstream_ea_swvr, init_vgmstream_ngc_dsp_sth_str1, init_vgmstream_ngc_dsp_sth_str2, init_vgmstream_ngc_dsp_sth_str3, @@ -968,7 +968,7 @@ void render_vgmstream(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstre case layout_thp_blocked: case layout_filp_blocked: case layout_blocked_ivaud: - case layout_psx_mgav_blocked: + case layout_blocked_ea_swvr: case layout_ps2_adm_blocked: case layout_dsp_bdsp_blocked: case layout_tra_blocked: diff --git a/src/vgmstream.h b/src/vgmstream.h index 18dfc9c3..7bdcda26 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -237,7 +237,7 @@ typedef enum { layout_gsb_blocked, layout_thp_blocked, layout_filp_blocked, - layout_psx_mgav_blocked, + layout_blocked_ea_swvr, layout_ps2_adm_blocked, layout_dsp_bdsp_blocked, layout_mxch_blocked, @@ -544,7 +544,7 @@ typedef enum { meta_DSP_DDSP, /* Various (2 dsp files stuck together */ meta_NGC_DSP_MPDS, /* Big Air Freestyle, Terminator 3 */ meta_DSP_STR_IG, /* Micro Machines, Superman Superman: Shadow of Apokolis */ - meta_PSX_MGAV, /* Future Cop L.A.P.D. */ + meta_EA_SWVR, /* Future Cop L.A.P.D., Freekstyle */ meta_NGC_DSP_STH_STR, /* SpongeBob Squarepants (NGC), Taz Wanted (NGC), Cubix (NGC), Tak (WII)*/ meta_PS2_B1S, /* 7 Wonders of the ancient world */ meta_PS2_WAD, /* The golden Compass */