From b61e94ed3cdf01fb850b07d6aa3a5780e4401463 Mon Sep 17 00:00:00 2001 From: bnnm Date: Sun, 15 May 2022 12:23:01 +0200 Subject: [PATCH] Fix some .tun [NBA Inside Drive 2000 (PC)] --- src/formats.c | 2 +- src/meta/meta.h | 2 +- src/meta/tun.c | 30 +++++++++++++++++++++--------- src/vgmstream.c | 2 +- src/vgmstream.h | 2 +- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/formats.c b/src/formats.c index d231c8ca..9cac65d9 100644 --- a/src/formats.c +++ b/src/formats.c @@ -1205,7 +1205,7 @@ static const meta_info meta_info_list[] = { {meta_MTAF, "Konami MTAF header"}, {meta_PS2_VAG1, "Konami VAG1 header"}, {meta_PS2_VAG2, "Konami VAG2 header"}, - {meta_TUN, "Lego Racers ALP header"}, + {meta_ALP, "High Voltage ALP header"}, {meta_WPD, "WPD 'DPW' header"}, {meta_MN_STR, "Mini Ninjas 'STR' header"}, {meta_MSS, "Guerilla MCSS header"}, diff --git a/src/meta/meta.h b/src/meta/meta.h index 064e8553..f423926f 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -541,7 +541,7 @@ VGMSTREAM * init_vgmstream_eb_sf0(STREAMFILE* streamFile); VGMSTREAM * init_vgmstream_mtaf(STREAMFILE* streamFile); -VGMSTREAM * init_vgmstream_tun(STREAMFILE* streamFile); +VGMSTREAM* init_vgmstream_alp(STREAMFILE* sf); VGMSTREAM * init_vgmstream_wpd(STREAMFILE* streamFile); diff --git a/src/meta/tun.c b/src/meta/tun.c index 78dfbb2a..4af0e2e6 100644 --- a/src/meta/tun.c +++ b/src/meta/tun.c @@ -1,31 +1,43 @@ #include "meta.h" #include "../coding/coding.h" -/* ALP - from LEGO Racers (PC) */ -VGMSTREAM* init_vgmstream_tun(STREAMFILE* sf) { +/* ALP - from High Voltage games [LEGO Racers (PC), NBA Inside Drive 2000 (PC)] */ +VGMSTREAM* init_vgmstream_alp(STREAMFILE* sf) { VGMSTREAM* vgmstream = NULL; off_t start_offset; - int loop_flag, channels; + int loop_flag, channels, sample_rate; /* checks */ if (!is_id32be(0x00,sf, "ALP ")) goto fail; if (!check_extensions(sf,"tun")) goto fail; - /* also "ADPCM" at 0x08 */ - channels = 2; /* probably at 0x0F */ + start_offset = read_u32le(0x04, sf) + 0x08; + if (!is_id32be(0x08,sf, "ADPC")) /* codec, probably */ + goto fail; + /* 0x0c: "M\0\0" */ + channels = read_u8(0x0f, sf); + if (channels != 2) /* not seen though mono should work (raw IMA_HV in NBA Hangtime uses it) */ + goto fail; + + /* NBA Inside Drive (PC) */ + if (start_offset >= 0x14) + sample_rate = read_s32le(0x10, sf); /* still 22050 thogh */ + else + sample_rate = 22050; + loop_flag = 0; - start_offset = 0x10; + /* build the VGMSTREAM */ vgmstream = allocate_vgmstream(channels,loop_flag); if (!vgmstream) goto fail; - vgmstream->meta_type = meta_TUN; + vgmstream->meta_type = meta_ALP; vgmstream->channels = channels; - vgmstream->sample_rate = 22050; - vgmstream->num_samples = ima_bytes_to_samples(get_streamfile_size(sf) - 0x10, channels); + vgmstream->sample_rate = sample_rate; + vgmstream->num_samples = ima_bytes_to_samples(get_streamfile_size(sf) - start_offset, channels); vgmstream->coding_type = coding_HV_IMA; vgmstream->layout_type = layout_interleave; diff --git a/src/vgmstream.c b/src/vgmstream.c index 12061537..dd87b4bd 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -257,7 +257,7 @@ VGMSTREAM* (*init_vgmstream_functions[])(STREAMFILE* sf) = { init_vgmstream_eb_sfx, init_vgmstream_eb_sf0, init_vgmstream_mtaf, - init_vgmstream_tun, + init_vgmstream_alp, init_vgmstream_wpd, init_vgmstream_mn_str, init_vgmstream_mss, diff --git a/src/vgmstream.h b/src/vgmstream.h index 4257e019..06ff5297 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -568,7 +568,7 @@ typedef enum { meta_MTAF, meta_PS2_VAG1, /* Metal Gear Solid 3 VAG1 */ meta_PS2_VAG2, /* Metal Gear Solid 3 VAG2 */ - meta_TUN, /* LEGO Racers (PC) */ + meta_ALP, meta_WPD, /* Shuffle! (PC) */ meta_MN_STR, /* Mini Ninjas (PC/PS3/WII) */ meta_MSS, /* Guerilla: ShellShock Nam '67 (PS2/Xbox), Killzone (PS2) */