Skip to content

Commit

Permalink
Merge pull request #1535 from EdnessP/master
Browse files Browse the repository at this point in the history
- Add Rebellion Developments (Asura engine) DSP variants:
  - DSPx [Judge Dredd (GC), The Simpsons Game (Wii), Sniper Elite V2 (WiiU)]
  - .DS2 [PDC World Championship Darts 2009 & Pro Tour (Wii)]
  - TTSS [Sniper Elite series (NSW)]
  - .SFX [Sniper Elite (Wii)]
- Decrease minimum allowed DSP sample rate to 5000Hz [Judge Dredd (GC)]
- Add more extensions:
  - DSP: .dat [The Sims: Bustin' Out (GC)], .wav [PDC World Championship Darts 2009 & Pro Tour (Wii)]
  - DDSP: (extensionless) [The Sims series (GC/Wii)]
  - VAG: .wav [Sniper Elite (PS2), The Simpsons Game (PS2/PSP)]
  • Loading branch information
bnnm committed May 25, 2024
2 parents 5e25e54 + 2930704 commit b2be98b
Show file tree
Hide file tree
Showing 11 changed files with 262 additions and 26 deletions.
1 change: 1 addition & 0 deletions src/formats.c
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,7 @@ static const meta_info meta_info_list[] = {
{meta_CBX, "Traveller's Tales CBX header"},
{meta_VAS_ROCKSTAR, "Rockstar .VAS header"},
{meta_EA_SBK, "Electronic Arts SBK header"},
{meta_DSP_ASURA, "Rebellion DSP header"},
};

void get_vgmstream_coding_description(VGMSTREAM* vgmstream, char* out, size_t out_size) {
Expand Down
1 change: 1 addition & 0 deletions src/libvgmstream.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@
<ClCompile Include="meta\nds_strm.c" />
<ClCompile Include="meta\nds_strm_ffta2.c" />
<ClCompile Include="meta\ngc_adpdtk.c" />
<ClCompile Include="meta\ngc_dsp_asura.c" />
<ClCompile Include="meta\ngc_dsp_konami.c" />
<ClCompile Include="meta\ngc_dsp_mpds.c" />
<ClCompile Include="meta\ngc_dsp_std.c" />
Expand Down
3 changes: 3 additions & 0 deletions src/libvgmstream.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,9 @@
<ClCompile Include="meta\ngc_adpdtk.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\ngc_dsp_asura.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\ngc_dsp_konami.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
Expand Down
19 changes: 14 additions & 5 deletions src/meta/ea_eaac_mpf_mus.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ VGMSTREAM* init_vgmstream_ea_msb_mus_eaac(STREAMFILE* sf) {
off_t info_offset, mus_name_offset;
read_u32_t read_u32;

//if (read_u64be(0x00,sf) != 0) //TODO always?
// return NULL;
if (read_u64be(0x00, sf) != 0)
return NULL;
if (!check_extensions(sf, "msb,msx"))
return NULL;

Expand All @@ -40,13 +40,22 @@ VGMSTREAM* init_vgmstream_ea_msb_mus_eaac(STREAMFILE* sf) {
read_u32 = guess_read_u32(0x08, sf);

/* extra checks to fail faster before streamfile'ing */
if (read_u32(0x08,sf) != 0x20)
if (read_u32(0x08, sf) != 0x20)
return NULL;
if (read_u32(0x20,sf) != 0x05)
if (read_u32(0x20, sf) != 0x05)
return NULL;

/* not exactly the same as mpf size since it's aligned, but doesn't matter here */
info_offset = read_u32(0x24, sf); //+ header_size;
/* TODO: it should be theoretically possible to use the numparts section
* in the plaintext chunk to get valid stream names using its entry node
* indices by checking if they're within range of the current subsong.
*
* However the main thing currently preventing that from being a thing
* is the fact that the indices deviate starting off by being off by 1,
* and can go up to being off by like 10 or in some rare extreme cases
* up to couple 100s. See if this index logic has some rhyme or reason.
*/
read_string(mus_name, sizeof(mus_name), mus_name_offset, sf);

sf_mpf = open_wrap_streamfile(sf);
Expand All @@ -55,8 +64,8 @@ VGMSTREAM* init_vgmstream_ea_msb_mus_eaac(STREAMFILE* sf) {

vgmstream = init_vgmstream_ea_mpf_mus_eaac_main(sf_mpf, mus_name);
if (!vgmstream) goto fail;
close_streamfile(sf_mpf);

close_streamfile(sf_mpf);
return vgmstream;

fail:
Expand Down
10 changes: 5 additions & 5 deletions src/meta/ea_schl.c
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,8 @@ VGMSTREAM* init_vgmstream_ea_msb_mus(STREAMFILE* sf) {
off_t info_offset, mus_name_offset;
read_u32_t read_u32;

//if (read_u64be(0x00,sf) != 0) //TODO always?
// return NULL;
if (read_u64be(0x00, sf) != 0)
return NULL;
if (!check_extensions(sf, "msb,msx"))
return NULL;

Expand All @@ -893,9 +893,9 @@ VGMSTREAM* init_vgmstream_ea_msb_mus(STREAMFILE* sf) {
read_u32 = guess_read_u32(0x08, sf);

/* extra checks to fail faster before streamfile'ing */
if (read_u32(0x08,sf) != 0x20)
if (read_u32(0x08, sf) != 0x20)
return NULL;
if (read_u32(0x20,sf) != 0x05)
if (read_u32(0x20, sf) != 0x05)
return NULL;

/* not exactly the same as mpf size since it's aligned, but correct size is only needed for v3 */
Expand All @@ -908,8 +908,8 @@ VGMSTREAM* init_vgmstream_ea_msb_mus(STREAMFILE* sf) {

vgmstream = init_vgmstream_ea_mpf_mus_main(sf_mpf, mus_name);
if (!vgmstream) goto fail;
close_streamfile(sf_mpf);

close_streamfile(sf_mpf);
return vgmstream;

fail:
Expand Down
7 changes: 6 additions & 1 deletion src/meta/meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ VGMSTREAM* init_vgmstream_dsp_sps_n1(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_dsp_itl_ch(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_dsp_adpy(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_dsp_adpx(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_dsp_ds2(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_dsp_lucasarts_ds2(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_dsp_itl(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_dsp_sqex(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_dsp_wiivoice(STREAMFILE* sf);
Expand All @@ -69,6 +69,9 @@ VGMSTREAM* init_vgmstream_dsp_cwac(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_idsp_tose(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_dsp_kwa(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_dsp_apex(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_dsp_asura(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_dsp_asura_ds2(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_dsp_asura_ttss(STREAMFILE* sf);

VGMSTREAM * init_vgmstream_csmp(STREAMFILE *streamFile);

Expand Down Expand Up @@ -1010,4 +1013,6 @@ VGMSTREAM* init_vgmstream_vas_rockstar(STREAMFILE* sf);

VGMSTREAM* init_vgmstream_ea_sbk(STREAMFILE* sf);

VGMSTREAM* init_vgmstream_dsp_asura_sfx(STREAMFILE* sf);

#endif /*_META_H*/
77 changes: 77 additions & 0 deletions src/meta/ngc_dsp_asura.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#include "meta.h"
#include "../coding/coding.h"


/* .sfx - Rebellion (Asura engine) games [Sniper Elite (Wii)] */
/* Despite what the extension implies it's used for music too */
/* Rebellion's other DSP variants can be found in ngc_dsp_std */
VGMSTREAM* init_vgmstream_dsp_asura_sfx(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
int channels, interleave, loop_flag;
uint32_t nibble_count, sample_rate;
off_t ch1_offset, ch2_offset;


/* checks */
if (!check_extensions(sf, "sfx"))
return NULL;

/* no clear header id, but this is how they all start */
/* the 0x02s are likely channels and codec (DSPADPCM) */
if (read_u32be(0x00, sf) != 0x00 &&
read_u32be(0x04, sf) != 0x02 &&
read_u32be(0x08, sf) != 0x02)
return NULL;


nibble_count = read_u32be(0x0C, sf);
sample_rate = read_u32be(0x10, sf); /* always 44100? */

/* this would likely be an array, but always 2ch so */
ch1_offset = read_u32be(0x14, sf); /* always 0x20? */
ch2_offset = read_u32be(0x18, sf); /* 0x10 aligned */

interleave = ch2_offset - ch1_offset;

/* channel header:
* 0x00: coefs
* 0x20: gain (0)
* 0x22: initial ps
* 0x30: stream start
*/

channels = 2;
loop_flag = 0;

/* more safety checks */
if (interleave < 0 ||
interleave < nibble_count / 2 ||
interleave > get_streamfile_size(sf) / channels)
goto fail;

if (read_u16be(ch1_offset + 0x22, sf) != read_u8(ch1_offset + 0x30, sf) ||
read_u16be(ch2_offset + 0x22, sf) != read_u8(ch2_offset + 0x30, sf))
goto fail;


/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail;

vgmstream->sample_rate = sample_rate;
vgmstream->meta_type = meta_DSP_ASURA;
vgmstream->coding_type = coding_NGC_DSP;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = interleave;
dsp_read_coefs_be(vgmstream, sf, ch1_offset, interleave);
vgmstream->num_samples = dsp_nibbles_to_samples(nibble_count);

if (!vgmstream_open_stream(vgmstream, sf, ch1_offset + 0x30))
goto fail;

return vgmstream;

fail:
close_vgmstream(vgmstream);
return NULL;
}
Loading

0 comments on commit b2be98b

Please sign in to comment.