EA GIN: Added "Octn" header magic

This commit is contained in:
NicknineTheEagle 2021-07-28 16:57:09 +03:00
parent 4e2cad5625
commit 147af39293

View File

@ -2,16 +2,17 @@
#include "../coding/coding.h"
/* .gin - EA engine sounds [Need for Speed: Most Wanted (multi)] */
VGMSTREAM * init_vgmstream_gin(STREAMFILE *streamFile) {
VGMSTREAM * init_vgmstream_gin(STREAMFILE *sf) {
VGMSTREAM *vgmstream = NULL;
off_t start_offset;
int loop_flag, channel_count, sample_rate, num_samples;
if (!check_extensions(streamFile, "gin"))
if (!check_extensions(sf, "gin"))
goto fail;
/* checks */
if (read_32bitBE(0x00, streamFile) != 0x476E7375) /* "Gnsu" */
if (!is_id32be(0x00, sf, "Gnsu") && /* original */
!is_id32be(0x00, sf, "Octn")) /* later (2013+) games, looks same as "Gnsu" */
goto fail;
/* contains mapped values for engine RPM sounds but we'll just play the whole thing */
@ -21,11 +22,11 @@ VGMSTREAM * init_vgmstream_gin(STREAMFILE *streamFile) {
/* 0x14: RPM ??? table size */
/* always LE even on X360/PS3 */
num_samples = read_32bitLE(0x18, streamFile);
sample_rate = read_32bitLE(0x1c, streamFile);
num_samples = read_u32le(0x18, sf);
sample_rate = read_u32le(0x1c, sf);
start_offset = 0x20 +
(read_32bitLE(0x10, streamFile) + 1) * 0x04 +
(read_32bitLE(0x14, streamFile) + 1) * 0x04;
(read_u32le(0x10, sf) + 1) * 0x04 +
(read_u32le(0x14, sf) + 1) * 0x04;
channel_count = 1;
loop_flag = 0;
@ -44,7 +45,7 @@ VGMSTREAM * init_vgmstream_gin(STREAMFILE *streamFile) {
/* calculate size for TMX */
vgmstream->stream_size = (align_size_to_block(num_samples, 32) / 32) * 0x13;
if (!vgmstream_open_stream(vgmstream, streamFile, start_offset))
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail;
return vgmstream;