Merge pull request #750 from NicknineTheEagle/ea

Ea
This commit is contained in:
NicknineTheEagle 2020-11-07 21:53:16 +03:00 committed by GitHub
commit b5e9ce33ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 76 additions and 56 deletions

View File

@ -1,4 +1,4 @@
name: CMake Linux
name: Linux build
on: [push, pull_request]
@ -12,6 +12,7 @@ jobs:
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#configuring-a-build-matrix
name: CMake, Ubuntu
runs-on: ubuntu-latest
steps:

View File

@ -1,6 +1,6 @@
# This is a basic workflow to help you get started with Actions
name: Windows VS 2017
name: Windows build
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
@ -10,6 +10,8 @@ on: [push, pull_request]
jobs:
# This workflow contains a single job called "build"
build:
name: VS 2017
# The type of runner that the job will run on
runs-on: windows-2016
@ -26,15 +28,6 @@ jobs:
shell: cmd
run: powershell -ExecutionPolicy Bypass -NoProfile -File .\build.ps1 Init
- name: Generate Build Files for Jansson
working-directory: ${{github.workspace}}
shell: cmd
run: |
cd dependencies\jansson\
mkdir build
cd build
cmake .. -DJANSSON_BUILD_SHARED_LIBS=ON -DJANSSON_EXAMPLES=OFF -DJANSSON_BUILD_DOCS=OFF -G "Visual Studio 15 2017" -T "v141_xp"
# Runs a single command using the runners shell
- name: Build
shell: cmd

View File

@ -101,7 +101,7 @@ function Init
cd dependencies\jansson\
mkdir build
cd build
cmake .. -DJANSSON_BUILD_SHARED_LIBS=ON -DJANSSON_EXAMPLES=OFF -DJANSSON_BUILD_DOCS=OFF -G "Visual Studio 15 2017" -T "v141_xp"
cmake .. -DJANSSON_BUILD_SHARED_LIBS=ON -DJANSSON_EXAMPLES=OFF -DJANSSON_BUILD_DOCS=OFF -A "Win32" -T "v141_xp"
cd ..\..\..
}

View File

@ -126,6 +126,7 @@ static const char* extension_list[] = {
"ccc",
"cd",
"cfn", //fake extension for CAF (renamed, to be removed?)
"chk",
"ckb",
"ckd",
"cks",

View File

@ -4,7 +4,7 @@
#include "../coding/coding.h"
#include "ea_eaac_streamfile.h"
/* EAAudioCore formats, EA's current audio middleware */
/* EAAudioCore (aka SND10) formats, EA's current audio middleware */
#define EAAC_VERSION_V0 0x00 /* SNR/SNS */
#define EAAC_VERSION_V1 0x01 /* SPS */
@ -512,9 +512,9 @@ static STREAMFILE *open_mapfile_pair(STREAMFILE* sf, int track, int num_tracks)
{"world.mpf", "World_Stream.mus"},
{"FreSkate.mpf", "track.mus,ram.mus"}, /* Skate It */
{"nsf_sing.mpf", "track_main.mus"}, /* Need for Speed: Nitro */
{"nsf_wii.mpf", "Track.mus"}, /* Need for Speed: Nitro */
{"nsf_wii.mpf", "Track.mus"},
{"ssx_fe.mpf", "stream_1.mus,stream_2.mus"}, /* SSX 2012 */
{"ssxdd.mpf", "main_trk.mus," /* SSX 2012 */
{"ssxdd.mpf", "main_trk.mus,"
"trick_alaska0.mus,"
"trick_rockies0.mus,"
"trick_pata0.mus,"
@ -733,31 +733,35 @@ fail:
return NULL;
}
/* EA TMX - used for engine sounds in NFS games (2007-present) */
/* EA TMX - used for engine sounds in NFS games (2007-2011) */
VGMSTREAM * init_vgmstream_ea_tmx(STREAMFILE* sf) {
uint32_t num_sounds, sound_type;
off_t table_offset, data_offset, entry_offset, sound_offset;
uint32_t num_sounds, sound_type, table_offset, data_offset, entry_offset, sound_offset;
VGMSTREAM *vgmstream = NULL;
int target_stream = sf->stream_index;
uint32_t(*read_u32)(off_t, STREAMFILE *);
if (!check_extensions(sf, "tmx"))
goto fail;
/* always little endian */
if (read_32bitLE(0x0c, sf) != 0x30303031) /* "0001" */
if (read_u32be(0x0c, sf) == 0x30303031) { /* "0001" */
read_u32 = read_u32be;
} else if (read_u32le(0x0c, sf) == 0x30303031) { /* "1000" */
read_u32 = read_u32le;
} else {
goto fail;
}
num_sounds = read_32bitLE(0x20, sf);
table_offset = read_32bitLE(0x58, sf);
data_offset = read_32bitLE(0x5c, sf);
num_sounds = read_u32(0x20, sf);
table_offset = read_u32(0x58, sf);
data_offset = read_u32(0x5c, sf);
if (target_stream == 0) target_stream = 1;
if (target_stream < 0 || num_sounds == 0 || target_stream > num_sounds)
goto fail;
entry_offset = table_offset + (target_stream - 1) * 0x24;
sound_type = read_32bitLE(entry_offset + 0x00, sf);
sound_offset = read_32bitLE(entry_offset + 0x08, sf) + data_offset;
sound_type = read_u32(entry_offset + 0x00, sf);
sound_offset = read_u32(entry_offset + 0x08, sf) + data_offset;
switch (sound_type) {
case 0x47494E20: /* "GIN " */
@ -1022,7 +1026,7 @@ static VGMSTREAM * init_vgmstream_eaaudiocore_header(STREAMFILE* sf_head, STREAM
eaac.channel_config = (header1 >> 18) & 0x3F; /* 6 bits */
eaac.sample_rate = (header1 >> 0) & 0x03FFFF; /* 18 bits */
eaac.type = (header2 >> 30) & 0x03; /* 2 bits */
eaac.loop_flag = (header2 >> 29) & 0x01; /* 1 bits */
eaac.loop_flag = (header2 >> 29) & 0x01; /* 1 bit */
eaac.num_samples = (header2 >> 0) & 0x1FFFFFFF; /* 29 bits */
/* rest is optional, depends on used flags and codec (handled below) */
@ -1032,7 +1036,7 @@ static VGMSTREAM * init_vgmstream_eaaudiocore_header(STREAMFILE* sf_head, STREAM
/* EA 6ch channel mapping is L C R BL BR LFE, but may use stereo layers for dynamic music
* instead, so we can't re-map automatically (use TXTP) */
/* V0: SNR+SNS, V1: SPR+SPS (no apparent differences, other than block flags) */
/* V0: SNR+SNS, V1: SPH+SPS (no apparent differences, other than block flags) */
if (eaac.version != EAAC_VERSION_V0 && eaac.version != EAAC_VERSION_V1) {
VGM_LOG("EA EAAC: unknown version\n");
goto fail;
@ -1050,6 +1054,12 @@ static VGMSTREAM * init_vgmstream_eaaudiocore_header(STREAMFILE* sf_head, STREAM
goto fail;
}
if (eaac.version == EAAC_VERSION_V1 && eaac.type != EAAC_TYPE_STREAM) {
/* should never happen */
VGM_LOG("EA EAAC: bad stream type for version %x\n", eaac.version);
goto fail;
}
/* Non-streamed sounds are stored as a single block (may not set block end flags) */
eaac.streamed = (eaac.type != EAAC_TYPE_RAM);
@ -1086,12 +1096,13 @@ static VGMSTREAM * init_vgmstream_eaaudiocore_header(STREAMFILE* sf_head, STREAM
}
break;
case EAAC_TYPE_GIGASAMPLE: /* rarely seen [Def Jam Icon (X360)] */
if (eaac.loop_flag) {
VGM_LOG("EAAC: Looped gigasample found.\n");
goto fail;
}
header_size += 0x04;
eaac.prefetch_samples = read_32bitBE(header_offset + 0x08, sf_head);
eaac.prefetch_samples = read_32bitBE(header_offset + eaac.loop_flag ? 0x0c : 0x08, sf_head);
if (eaac.loop_flag && eaac.loop_start >= eaac.prefetch_samples) {
header_size += 0x04;
eaac.loop_offset = read_32bitBE(header_offset + 0x10, sf_head);
}
break;
}
@ -1119,7 +1130,20 @@ static VGMSTREAM * init_vgmstream_eaaudiocore_header(STREAMFILE* sf_head, STREAM
/* SNR+SNS are separate so offsets are relative to the data start
* (first .SNS block, or extra data before the .SNS block in case of .SNU)
* SPS have headers+data together so offsets are relative to the file start [ex. FIFA 18 (PC)] */
if (eaac.version == EAAC_VERSION_V1) {
if (eaac.version == EAAC_VERSION_V0) {
if (eaac.prefetch_samples != 0) {
if (eaac.loop_start == 0) {
/* loop from the beginning */
eaac.loop_offset = 0x00;
} else if (eaac.loop_start < eaac.prefetch_samples) {
/* loop from the second RAM block */
eaac.loop_offset = read_32bitBE(eaac.prefetch_offset, sf_head) & 0x00FFFFFF;
} else {
/* loop from offset within SNS */
eaac.loop_offset += read_32bitBE(eaac.prefetch_offset, sf_head) & 0x00FFFFFF;
}
}
} else {
eaac.loop_offset -= header_block_size;
}
} else if (eaac.loop_start > 0) {
@ -1345,13 +1369,15 @@ static size_t calculate_eaac_size(STREAMFILE *sf, eaac_header *ea, uint32_t num_
stream_size += block_size;
block_offset += block_size;
if (is_ram) {
/* RAM data only consists of one block (two for looped sounds) */
if (ea->loop_start > 0 && !looped) looped = 1;
else break;
} else if (ea->version == EAAC_VERSION_V0 && block_id == EAAC_BLOCKID0_END) {
if (ea->loop_offset > 0 && !looped) looped = 1;
else break;
if (ea->version == EAAC_VERSION_V0) {
if (is_ram) {
/* RAM data only consists of one block (two for looped sounds) */
if (ea->loop_start > 0 && ea->loop_start < num_samples && !looped) looped = 1;
else break;
} else if (block_id == EAAC_BLOCKID0_END) {
if (ea->loop_offset > 0 && ea->loop_start >= ea->prefetch_samples && !looped) looped = 1;
else break;
}
}
}
@ -1430,13 +1456,7 @@ static STREAMFILE *setup_eaac_streamfile(eaac_header *ea, STREAMFILE* sf_head, S
break;
}
} else {
if (ea->type == EAAC_TYPE_GIGASAMPLE) {
/* not seen so far, need samples */
VGM_LOG("EAAC: Found SPS gigasample\n");
goto fail;
}
data_size = calculate_eaac_size(sf_head, ea, ea->num_samples, ea->stream_offset, ea->type == EAAC_TYPE_RAM);
data_size = calculate_eaac_size(sf_head, ea, ea->num_samples, ea->stream_offset, 0);
if (data_size == 0) goto fail;
new_sf = open_wrap_streamfile(sf_head);

View File

@ -17,12 +17,13 @@
#define EA_PLATFORM_MAC 0x03
#define EA_PLATFORM_SAT 0x04
#define EA_PLATFORM_PS2 0x05
#define EA_PLATFORM_GC_WII 0x06
#define EA_PLATFORM_GC 0x06 /* also used on Wii */
#define EA_PLATFORM_XBOX 0x07
#define EA_PLATFORM_GENERIC 0x08 /* typically Wii/X360/PS3/videos */
#define EA_PLATFORM_X360 0x09
#define EA_PLATFORM_PSP 0x0A
#define EA_PLATFORM_PS3 0x0E /* very rare [Need for Speed: Carbon (PS3)] */
#define EA_PLATFORM_WII 0x10
#define EA_PLATFORM_3DS 0x14
/* codec constants (undefined are probably reserved, ie.- sx.exe encodes PCM24/DVI but no platform decodes them) */
@ -59,6 +60,7 @@
//#define EA_CODEC2_S24BE_INT 0x15 /* not used */
#define EA_CODEC2_MT5 0x16
#define EA_CODEC2_EALAYER3 0x17
//#define EA_CODEC2_ATRAC3 0x1A /* not seen so far */
#define EA_CODEC2_ATRAC3PLUS 0x1B
/* Block headers, SCxy - where x is block ID and y is endianness flag (always 'l'?) */
@ -136,6 +138,7 @@ VGMSTREAM* init_vgmstream_ea_schl(STREAMFILE* sf) {
* .asf: ~early (audio stream file?) [ex. Need for Speed II (PC)]
* .lasf: fake for plugins
* .str: ~early [ex. FIFA 98 (PS1), FIFA 2002 (PS1)]
* .chk: ~early [ex. NBA Live 98 (PS1)]
* .eam: ~mid?
* .exa: ~mid [ex. 007 - From Russia with Love]
* .sng: ~late (FIFA games)
@ -149,7 +152,7 @@ VGMSTREAM* init_vgmstream_ea_schl(STREAMFILE* sf) {
* .gsf: 007 - Everything or Nothing (GC)
* .mus: map/mpf+mus only?
* (extensionless): SSX (PS2) (inside .big) */
if (!check_extensions(sf,"asf,lasf,str,eam,exa,sng,aud,sx,xa,strm,stm,hab,xsf,gsf,mus,"))
if (!check_extensions(sf,"asf,lasf,str,chk,eam,exa,sng,aud,sx,xa,strm,stm,hab,xsf,gsf,mus,"))
goto fail;
/* check header */
@ -1377,9 +1380,7 @@ static VGMSTREAM * init_vgmstream_ea_variable_header(STREAMFILE* sf, ea_header*
for (i = 0; i < ea->channels; i++) {
vgmstream->ch[i].offset = ea->offsets[0] + interleave*i;
}
} else if ((vgmstream->coding_type == coding_PCM8 || vgmstream->coding_type == coding_PCM16LE) &&
ea->platform == EA_PLATFORM_PS2 &&
(ea->flag_value & 0x100)) {
} else if (ea->platform == EA_PLATFORM_PS2 && (ea->flag_value & 0x100)) {
/* weird 0x10 mini header when played on IOP (codec/loop start/loop end/samples) [SSX 3 (PS2)] */
for (i = 0; i < vgmstream->channels; i++) {
vgmstream->ch[i].offset = ea->offsets[i] + 0x10;
@ -1654,9 +1655,10 @@ static int parse_variable_header(STREAMFILE* sf, ea_header* ea, off_t begin_offs
if (ea->platform == EA_PLATFORM_N64
|| ea->platform == EA_PLATFORM_MAC
|| ea->platform == EA_PLATFORM_SAT
|| ea->platform == EA_PLATFORM_GC_WII
|| ea->platform == EA_PLATFORM_GC
|| ea->platform == EA_PLATFORM_X360
|| ea->platform == EA_PLATFORM_PS3
|| ea->platform == EA_PLATFORM_WII
|| ea->platform == EA_PLATFORM_GENERIC) {
ea->big_endian = 1;
}
@ -1675,11 +1677,12 @@ static int parse_variable_header(STREAMFILE* sf, ea_header* ea, off_t begin_offs
case EA_PLATFORM_MAC: ea->version = EA_VERSION_V0; break;
case EA_PLATFORM_SAT: ea->version = EA_VERSION_V0; break;
case EA_PLATFORM_PS2: ea->version = EA_VERSION_V1; break;
case EA_PLATFORM_GC_WII: ea->version = EA_VERSION_V2; break;
case EA_PLATFORM_GC: ea->version = EA_VERSION_V2; break;
case EA_PLATFORM_XBOX: ea->version = EA_VERSION_V2; break;
case EA_PLATFORM_X360: ea->version = EA_VERSION_V3; break;
case EA_PLATFORM_PSP: ea->version = EA_VERSION_V3; break;
case EA_PLATFORM_PS3: ea->version = EA_VERSION_V3; break;
case EA_PLATFORM_WII: ea->version = EA_VERSION_V3; break;
case EA_PLATFORM_3DS: ea->version = EA_VERSION_V3; break;
case EA_PLATFORM_GENERIC: ea->version = EA_VERSION_V2; break;
default:
@ -1734,11 +1737,12 @@ static int parse_variable_header(STREAMFILE* sf, ea_header* ea, off_t begin_offs
case EA_PLATFORM_PSX: ea->codec2 = EA_CODEC2_VAG; break;
case EA_PLATFORM_MAC: ea->codec2 = EA_CODEC2_EAXA; break;
case EA_PLATFORM_PS2: ea->codec2 = EA_CODEC2_VAG; break;
case EA_PLATFORM_GC_WII: ea->codec2 = EA_CODEC2_S16BE; break;
case EA_PLATFORM_GC: ea->codec2 = EA_CODEC2_S16BE; break;
case EA_PLATFORM_XBOX: ea->codec2 = EA_CODEC2_S16LE; break;
case EA_PLATFORM_X360: ea->codec2 = EA_CODEC2_EAXA; break;
case EA_PLATFORM_PSP: ea->codec2 = EA_CODEC2_EAXA; break;
case EA_PLATFORM_PS3: ea->codec2 = EA_CODEC2_EAXA; break;
//case EA_PLATFORM_WII: ea->codec2 = EA_CODEC2_EAXA; break; /* not set? */
case EA_PLATFORM_3DS: ea->codec2 = EA_CODEC2_GCADPCM; break;
default:
VGM_LOG("EA SCHl: unknown default codec2 for platform 0x%02x\n", ea->platform);
@ -1756,11 +1760,12 @@ static int parse_variable_header(STREAMFILE* sf, ea_header* ea, off_t begin_offs
case EA_PLATFORM_MAC: ea->sample_rate = 22050; break;
case EA_PLATFORM_SAT: ea->sample_rate = 22050; break;
case EA_PLATFORM_PS2: ea->sample_rate = 22050; break;
case EA_PLATFORM_GC_WII: ea->sample_rate = 24000; break;
case EA_PLATFORM_GC: ea->sample_rate = 24000; break;
case EA_PLATFORM_XBOX: ea->sample_rate = 24000; break;
case EA_PLATFORM_X360: ea->sample_rate = 44100; break;
case EA_PLATFORM_PSP: ea->sample_rate = 22050; break;
case EA_PLATFORM_PS3: ea->sample_rate = 44100; break;
case EA_PLATFORM_WII: ea->sample_rate = 32000; break;
case EA_PLATFORM_3DS: ea->sample_rate = 32000; break;
default:
VGM_LOG("EA SCHl: unknown default sample rate for platform 0x%02x\n", ea->platform);