DSP: fix asura header checks

This commit is contained in:
EdnessP 2024-07-06 23:05:54 +03:00
parent b0329b573e
commit 28c6dc4218
2 changed files with 8 additions and 8 deletions

View File

@ -18,8 +18,8 @@ VGMSTREAM* init_vgmstream_dsp_asura_sfx(STREAMFILE* sf) {
/* no clear header id, but this is how they all start */ /* no clear header id, but this is how they all start */
/* the 0x02s are likely channels and codec (DSPADPCM) */ /* the 0x02s are likely channels and codec (DSPADPCM) */
if (read_u32be(0x00, sf) != 0x00 && if (read_u32be(0x00, sf) != 0x00 ||
read_u32be(0x04, sf) != 0x02 && read_u32be(0x04, sf) != 0x02 ||
read_u32be(0x08, sf) != 0x02) read_u32be(0x08, sf) != 0x02)
return NULL; return NULL;
@ -44,8 +44,7 @@ VGMSTREAM* init_vgmstream_dsp_asura_sfx(STREAMFILE* sf) {
loop_flag = 0; loop_flag = 0;
/* more safety checks */ /* more safety checks */
if (interleave < 0 || if (interleave < 0 || interleave < nibble_count / 2 ||
interleave < nibble_count / 2 ||
interleave > get_streamfile_size(sf) / channels) interleave > get_streamfile_size(sf) / channels)
goto fail; goto fail;

View File

@ -1580,9 +1580,10 @@ VGMSTREAM* init_vgmstream_dsp_asura(STREAMFILE* sf) {
uint8_t flag; uint8_t flag;
/* checks */ /* checks */
if (!is_id32be(0x00, sf, "DSP\x00") && /* GC */ /* "DSP\x00" (GC), "DSP\x01" (GC/Wii/WiiU), "DSP\x02" (WiiU) */
!is_id32be(0x00, sf, "DSP\x01") && /* GC/Wii/WiiU */ if ((read_u32be(0x00, sf) & 0xFFFFFF00) != get_id32be("DSP\0"))
!is_id32be(0x00, sf, "DSP\x02")) /* WiiU */ return NULL;
if (read_u8(0x03, sf) < 0x00 || read_u8(0x03, sf) > 0x02)
return NULL; return NULL;
/* .dsp: Judge Dredd (GC) /* .dsp: Judge Dredd (GC)
@ -1590,7 +1591,7 @@ VGMSTREAM* init_vgmstream_dsp_asura(STREAMFILE* sf) {
if (!check_extensions(sf, "dsp,wav,lwav")) if (!check_extensions(sf, "dsp,wav,lwav"))
return NULL; return NULL;
/* flag set to 0x00 so far only seen in Judge Dredd, which also uses 0x01 /* flag set to 0x00 so far only seen in Judge Dredd, which also uses 0x01.
* at first assumed being 0 means it has a stream name at 0x48 (unlikely) */ * at first assumed being 0 means it has a stream name at 0x48 (unlikely) */
/* flag set to 0x02 means it's ddsp-like stereo */ /* flag set to 0x02 means it's ddsp-like stereo */
flag = read_u8(0x03, sf); flag = read_u8(0x03, sf);