diff --git a/src/coding/coding.h b/src/coding/coding.h index bd2c800e..e55c6572 100644 --- a/src/coding/coding.h +++ b/src/coding/coding.h @@ -21,7 +21,7 @@ void decode_3ds_ima(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspaci void decode_snds_ima(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel); void decode_otns_ima(VGMSTREAM* vgmstream, VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel); void decode_wv6_ima(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do); -void decode_alp_ima(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do); +void decode_hv_ima(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do); void decode_ffta2_ima(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do); void decode_blitz_ima(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do); void decode_mtf_ima(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel, int is_stereo); diff --git a/src/coding/ima_decoder.c b/src/coding/ima_decoder.c index 68e6d3f6..ae136a96 100644 --- a/src/coding/ima_decoder.c +++ b/src/coding/ima_decoder.c @@ -190,8 +190,8 @@ static void wv6_ima_expand_nibble(VGMSTREAMCHANNEL * stream, off_t byte_offset, if (*step_index > 88) *step_index=88; } -/* Lego Racers (PC) .TUN variation, reverse engineered from the .exe */ -static void alp_ima_expand_nibble(VGMSTREAMCHANNEL * stream, off_t byte_offset, int nibble_shift, int32_t * hist1, int32_t * step_index) { +/* High Voltage variation, reverse engineered from .exes [Lego Racers (PC), NBA Hangtime (PC)] */ +static void hv_ima_expand_nibble(VGMSTREAMCHANNEL * stream, off_t byte_offset, int nibble_shift, int32_t * hist1, int32_t * step_index) { int sample_nibble, sample_decoded, step, delta; sample_nibble = (read_8bit(byte_offset,stream->streamfile) >> nibble_shift)&0xf; @@ -489,8 +489,8 @@ void decode_wv6_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspa stream->adpcm_step_index = step_index; } -/* ALT IMA, DVI IMA with custom nibble expand */ -void decode_alp_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) { +/* High Voltage's DVI IMA with simplified nibble expand */ +void decode_hv_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) { int i, sample_count; int32_t hist1 = stream->adpcm_history1_32; int step_index = stream->adpcm_step_index; @@ -503,7 +503,7 @@ void decode_alp_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspa off_t byte_offset = stream->offset + i/2; int nibble_shift = (i&1?0:4); //high nibble first - alp_ima_expand_nibble(stream, byte_offset,nibble_shift, &hist1, &step_index); + hv_ima_expand_nibble(stream, byte_offset,nibble_shift, &hist1, &step_index); outbuf[sample_count] = (short)(hist1); } diff --git a/src/decode.c b/src/decode.c index 0e82f468..bdd53cef 100644 --- a/src/decode.c +++ b/src/decode.c @@ -412,7 +412,7 @@ int get_vgmstream_samples_per_frame(VGMSTREAM* vgmstream) { case coding_DVI_IMA_int: case coding_3DS_IMA: case coding_WV6_IMA: - case coding_ALP_IMA: + case coding_HV_IMA: case coding_FFTA2_IMA: case coding_BLITZ_IMA: case coding_PCFX: @@ -622,7 +622,7 @@ int get_vgmstream_frame_size(VGMSTREAM* vgmstream) { case coding_DVI_IMA_int: case coding_3DS_IMA: case coding_WV6_IMA: - case coding_ALP_IMA: + case coding_HV_IMA: case coding_FFTA2_IMA: case coding_BLITZ_IMA: case coding_PCFX: @@ -1163,9 +1163,9 @@ void decode_vgmstream(VGMSTREAM* vgmstream, int samples_written, int samples_to_ vgmstream->channels, vgmstream->samples_into_block, samples_to_do); } break; - case coding_ALP_IMA: + case coding_HV_IMA: for (ch = 0; ch < vgmstream->channels; ch++) { - decode_alp_ima(&vgmstream->ch[ch], buffer+ch, + decode_hv_ima(&vgmstream->ch[ch], buffer+ch, vgmstream->channels, vgmstream->samples_into_block, samples_to_do); } break; diff --git a/src/formats.c b/src/formats.c index 6286e8e7..d231c8ca 100644 --- a/src/formats.c +++ b/src/formats.c @@ -779,7 +779,7 @@ static const coding_info coding_info_list[] = { {coding_SNDS_IMA, "Heavy Iron .snds 4-bit IMA ADPCM"}, {coding_QD_IMA, "Quantic Dream 4-bit IMA ADPCM"}, {coding_WV6_IMA, "Gorilla Systems WV6 4-bit IMA ADPCM"}, - {coding_ALP_IMA, "High Voltage ALP 4-bit IMA ADPCM"}, + {coding_HV_IMA, "High Voltage 4-bit IMA ADPCM"}, {coding_FFTA2_IMA, "Final Fantasy Tactics A2 4-bit IMA ADPCM"}, {coding_BLITZ_IMA, "Blitz Games 4-bit IMA ADPCM"}, {coding_MTF_IMA, "MT Framework 4-bit IMA ADPCM"}, diff --git a/src/meta/tun.c b/src/meta/tun.c index b49e9ba9..78dfbb2a 100644 --- a/src/meta/tun.c +++ b/src/meta/tun.c @@ -1,41 +1,41 @@ -#include "meta.h" -#include "../coding/coding.h" - -/* ALP - from LEGO Racers (PC) */ -VGMSTREAM * init_vgmstream_tun(STREAMFILE *streamFile) { - VGMSTREAM * vgmstream = NULL; - off_t start_offset; - int loop_flag, channel_count; - - /* checks */ - if ( !check_extensions(streamFile,"tun") ) - goto fail; - if (read_32bitBE(0x00,streamFile) != 0x414C5020) /* "ALP " */ - goto fail; - - channel_count = 2; /* probably at 0x0F */ - loop_flag = 0; - start_offset = 0x10; - /* also "ADPCM" at 0x08 */ - - /* build the VGMSTREAM */ - vgmstream = allocate_vgmstream(channel_count,loop_flag); - if (!vgmstream) goto fail; - - vgmstream->channels = channel_count; - vgmstream->sample_rate = 22050; - vgmstream->num_samples = ima_bytes_to_samples(get_streamfile_size(streamFile) - 0x10, channel_count); - - vgmstream->coding_type = coding_ALP_IMA; - vgmstream->layout_type = layout_interleave; - vgmstream->interleave_block_size = 0x01; - vgmstream->meta_type = meta_TUN; - - if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) ) - goto fail; - return vgmstream; - -fail: - if (vgmstream) close_vgmstream(vgmstream); - return NULL; -} +#include "meta.h" +#include "../coding/coding.h" + +/* ALP - from LEGO Racers (PC) */ +VGMSTREAM* init_vgmstream_tun(STREAMFILE* sf) { + VGMSTREAM* vgmstream = NULL; + off_t start_offset; + int loop_flag, channels; + + /* 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 */ + 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->channels = channels; + vgmstream->sample_rate = 22050; + vgmstream->num_samples = ima_bytes_to_samples(get_streamfile_size(sf) - 0x10, channels); + + vgmstream->coding_type = coding_HV_IMA; + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = 0x01; + + if (!vgmstream_open_stream(vgmstream, sf, start_offset)) + goto fail; + return vgmstream; + +fail: + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} diff --git a/src/vgmstream.h b/src/vgmstream.h index 0c261aaf..4257e019 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -109,7 +109,7 @@ typedef enum { coding_SNDS_IMA, /* Heavy Iron Studios .snds IMA ADPCM */ coding_QD_IMA, coding_WV6_IMA, /* Gorilla Systems WV6 4-bit IMA ADPCM */ - coding_ALP_IMA, /* High Voltage ALP 4-bit IMA ADPCM */ + coding_HV_IMA, /* High Voltage 4-bit IMA ADPCM */ coding_FFTA2_IMA, /* Final Fantasy Tactics A2 4-bit IMA ADPCM */ coding_BLITZ_IMA, /* Blitz Games 4-bit IMA ADPCM */