2017-11-05 17:06:40 +01:00
|
|
|
#include "meta.h"
|
2019-01-19 20:03:48 +01:00
|
|
|
#include "../layout/layout.h"
|
2017-11-05 17:06:40 +01:00
|
|
|
#include "../coding/coding.h"
|
2019-01-19 20:03:48 +01:00
|
|
|
#include "ubi_sb_streamfile.h"
|
2017-11-05 17:06:40 +01:00
|
|
|
|
|
|
|
|
2019-02-10 19:02:28 +01:00
|
|
|
#define SB_MAX_LAYER_COUNT 16 /* arbitrary max */
|
|
|
|
#define SB_MAX_CHAIN_COUNT 64 /* arbitrary max */
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
typedef enum { UBI_IMA, UBI_ADPCM, RAW_PCM, RAW_PSX, RAW_DSP, RAW_XBOX, FMT_VAG, FMT_AT3, RAW_AT3, FMT_XMA1, RAW_XMA1, FMT_OGG, FMT_CWAV } ubi_sb_codec;
|
2019-01-05 04:32:07 +01:00
|
|
|
typedef enum { UBI_PC, UBI_PS2, UBI_XBOX, UBI_GC, UBI_X360, UBI_PSP, UBI_PS3, UBI_WII, UBI_3DS } ubi_sb_platform;
|
2019-01-26 16:30:36 +01:00
|
|
|
typedef enum { UBI_NONE = 0, UBI_AUDIO, UBI_LAYER, UBI_SEQUENCE, UBI_SILENCE } ubi_sb_type;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int map_version;
|
|
|
|
size_t map_entry_size;
|
|
|
|
size_t section1_entry_size;
|
|
|
|
size_t section2_entry_size;
|
|
|
|
size_t section3_entry_size;
|
|
|
|
size_t resource_name_size;
|
|
|
|
|
|
|
|
off_t audio_extra_offset;
|
|
|
|
off_t audio_stream_size;
|
|
|
|
off_t audio_stream_offset;
|
|
|
|
off_t audio_stream_type;
|
|
|
|
off_t audio_group_id;
|
|
|
|
off_t audio_external_flag;
|
|
|
|
off_t audio_loop_flag;
|
|
|
|
off_t audio_num_samples;
|
|
|
|
off_t audio_num_samples2;
|
|
|
|
off_t audio_sample_rate;
|
|
|
|
off_t audio_channels;
|
|
|
|
off_t audio_stream_name;
|
|
|
|
off_t audio_extra_name;
|
|
|
|
off_t audio_xma_offset;
|
|
|
|
int audio_external_and;
|
|
|
|
int audio_loop_and;
|
|
|
|
int audio_group_and;
|
|
|
|
int audio_has_internal_names;
|
2019-02-03 01:47:44 +01:00
|
|
|
size_t audio_interleave;
|
2019-01-26 16:30:36 +01:00
|
|
|
|
|
|
|
off_t sequence_extra_offset;
|
|
|
|
off_t sequence_sequence_loop;
|
|
|
|
off_t sequence_sequence_single;
|
|
|
|
off_t sequence_sequence_count;
|
|
|
|
off_t sequence_entry_number;
|
|
|
|
size_t sequence_entry_size;
|
|
|
|
|
|
|
|
off_t layer_extra_offset;
|
|
|
|
off_t layer_layer_count;
|
|
|
|
off_t layer_stream_size;
|
|
|
|
off_t layer_stream_offset;
|
|
|
|
off_t layer_stream_name;
|
|
|
|
off_t layer_extra_name;
|
|
|
|
off_t layer_sample_rate;
|
|
|
|
off_t layer_channels;
|
|
|
|
off_t layer_stream_type;
|
|
|
|
off_t layer_num_samples;
|
|
|
|
size_t layer_entry_size;
|
2019-03-16 13:58:28 +01:00
|
|
|
size_t layer_hijack;
|
2019-01-26 16:30:36 +01:00
|
|
|
|
|
|
|
off_t silence_duration_int;
|
|
|
|
off_t silence_duration_float;
|
|
|
|
|
|
|
|
int is_padded_section1_offset;
|
|
|
|
int is_padded_section2_offset;
|
|
|
|
int is_padded_section3_offset;
|
|
|
|
int is_padded_sectionX_offset;
|
|
|
|
int is_padded_sounds_offset;
|
|
|
|
int ignore_layer_error;
|
|
|
|
} ubi_sb_config;
|
2019-01-19 20:03:48 +01:00
|
|
|
|
2017-11-05 17:06:40 +01:00
|
|
|
typedef struct {
|
2018-12-17 08:05:45 +01:00
|
|
|
ubi_sb_platform platform;
|
2019-01-19 20:03:48 +01:00
|
|
|
int is_psp_old;
|
2017-11-05 17:06:40 +01:00
|
|
|
int big_endian;
|
2019-01-13 23:27:29 +01:00
|
|
|
int total_subsongs;
|
2019-01-19 20:03:48 +01:00
|
|
|
int bank_subsongs;
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
/* SB config */
|
|
|
|
/* header varies slightly per game/version but not enough parse case by case,
|
|
|
|
* instead we configure sizes and offsets to where each variable is */
|
|
|
|
ubi_sb_config cfg;
|
|
|
|
|
2019-01-05 04:02:14 +01:00
|
|
|
/* map base header info */
|
|
|
|
off_t map_start;
|
|
|
|
off_t map_num;
|
|
|
|
|
|
|
|
uint32_t map_type;
|
|
|
|
uint32_t map_zero;
|
|
|
|
off_t map_offset;
|
|
|
|
off_t map_size;
|
2019-02-17 20:53:30 +01:00
|
|
|
char map_name[0x28];
|
2019-01-05 04:02:14 +01:00
|
|
|
uint32_t map_unknown;
|
|
|
|
|
2019-01-07 18:03:47 +01:00
|
|
|
/* SB info (some values are derived depending if it's standard sbX or map sbX) */
|
|
|
|
int is_map;
|
|
|
|
uint32_t version; /* 16b+16b major+minor version */
|
|
|
|
uint32_t version_empty; /* map sbX versions are empty */
|
2019-01-19 20:03:48 +01:00
|
|
|
/* events (often share header_id/type with some descriptors,
|
|
|
|
* but may exist without headers or header exist without them) */
|
2017-11-05 17:06:40 +01:00
|
|
|
size_t section1_num;
|
2019-01-07 18:03:47 +01:00
|
|
|
size_t section1_offset;
|
|
|
|
/* descriptors, audio header or other config types */
|
2017-11-05 17:06:40 +01:00
|
|
|
size_t section2_num;
|
2019-01-07 18:03:47 +01:00
|
|
|
size_t section2_offset;
|
2019-01-19 20:03:48 +01:00
|
|
|
/* internal streams table, referenced by each header */
|
2017-11-05 17:06:40 +01:00
|
|
|
size_t section3_num;
|
2019-01-07 18:03:47 +01:00
|
|
|
size_t section3_offset;
|
|
|
|
/* section with sounds in some map versions */
|
2018-12-24 12:29:55 +01:00
|
|
|
size_t section4_num;
|
2019-01-07 18:03:47 +01:00
|
|
|
size_t section4_offset;
|
|
|
|
/* extra table, config for certain types (DSP coefs, external resources, layer headers, etc) */
|
2019-01-05 04:02:14 +01:00
|
|
|
size_t sectionX_size;
|
2019-01-07 18:03:47 +01:00
|
|
|
size_t sectionX_offset;
|
|
|
|
/* unknown, usually -1 but can be others (0/1/2/etc) */
|
2017-11-05 17:06:40 +01:00
|
|
|
int flag1;
|
|
|
|
int flag2;
|
2018-12-22 22:47:24 +01:00
|
|
|
|
2019-01-05 04:02:14 +01:00
|
|
|
/* header/stream info */
|
2019-01-19 20:03:48 +01:00
|
|
|
ubi_sb_type type; /* unified type */
|
|
|
|
ubi_sb_codec codec; /* unified codec */
|
|
|
|
int header_index; /* entry number within section2 */
|
|
|
|
off_t header_offset; /* entry offset within section2 */
|
|
|
|
uint32_t header_id; /* 16b+16b group+sound identifier (unique within a sbX, but not smX), may start from 0 */
|
|
|
|
uint32_t header_type; /* parsed type (we only need audio types) */
|
2019-01-05 04:02:14 +01:00
|
|
|
off_t extra_offset; /* offset within sectionX to extra data */
|
2019-01-19 20:03:48 +01:00
|
|
|
off_t stream_offset; /* offset within the data section (internal) or absolute (external) to the audio */
|
|
|
|
size_t stream_size; /* size of the audio data */
|
2019-01-13 23:27:29 +01:00
|
|
|
uint32_t stream_type; /* rough codec value */
|
2019-01-07 22:10:48 +01:00
|
|
|
uint32_t group_id; /* internal id to reference in section3 */
|
2019-01-13 23:27:29 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
int loop_flag; /* stream loops (normally internal sfx, but also external music) */
|
|
|
|
int loop_start; /* usually 0 */
|
2019-01-07 22:10:48 +01:00
|
|
|
int num_samples; /* should match manually calculated samples */
|
2017-11-05 17:06:40 +01:00
|
|
|
int sample_rate;
|
|
|
|
int channels;
|
2019-01-19 20:03:48 +01:00
|
|
|
off_t xma_header_offset; /* some XMA have extra header stuff */
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
int layer_count; /* number of layers in a layer type */
|
2019-02-22 23:52:09 +01:00
|
|
|
int layer_channels[SB_MAX_LAYER_COUNT];
|
2019-01-19 20:03:48 +01:00
|
|
|
int sequence_count; /* number of segments in a sequence type */
|
2019-02-10 19:02:28 +01:00
|
|
|
int sequence_chain[SB_MAX_CHAIN_COUNT]; /* sequence of entry numbers */
|
2019-01-20 17:16:44 +01:00
|
|
|
int sequence_loop; /* chain index to loop */
|
|
|
|
int sequence_single; /* if que sequence plays once (loops by default) */
|
2019-01-05 04:02:14 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
float duration; /* silence duration */
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
int is_external; /* stream is in a external file */
|
2019-02-17 20:53:30 +01:00
|
|
|
char resource_name[0x28]; /* filename to the external stream, or internal stream info for some games */
|
2019-01-19 20:03:48 +01:00
|
|
|
|
|
|
|
char readable_name[255]; /* final subsong name */
|
|
|
|
int types[16]; /* counts each header types, for debugging */
|
|
|
|
int allowed_types[16];
|
2017-11-05 17:06:40 +01:00
|
|
|
} ubi_sb_header;
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
static int parse_header(ubi_sb_header * sb, STREAMFILE *streamFile, off_t offset, int index);
|
2019-02-10 19:02:28 +01:00
|
|
|
static int parse_sb(ubi_sb_header * sb, STREAMFILE *streamFile, int target_subsong);
|
|
|
|
static VGMSTREAM * init_vgmstream_ubi_sb_header(ubi_sb_header *sb, STREAMFILE* streamTest, STREAMFILE *streamFile);
|
2019-01-05 04:32:07 +01:00
|
|
|
static int config_sb_platform(ubi_sb_header * sb, STREAMFILE *streamFile);
|
2019-01-05 04:02:14 +01:00
|
|
|
static int config_sb_version(ubi_sb_header * sb, STREAMFILE *streamFile);
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-07 18:03:47 +01:00
|
|
|
|
|
|
|
/* .SBx - banks from Ubisoft's DARE (Digital Audio Rendering Engine) engine games in ~2000-2008+ */
|
2017-11-05 17:06:40 +01:00
|
|
|
VGMSTREAM * init_vgmstream_ubi_sb(STREAMFILE *streamFile) {
|
2019-01-19 20:03:48 +01:00
|
|
|
VGMSTREAM* vgmstream = NULL;
|
2019-01-02 23:46:39 +01:00
|
|
|
STREAMFILE *streamTest = NULL;
|
2018-12-22 22:47:24 +01:00
|
|
|
int32_t(*read_32bit)(off_t, STREAMFILE*) = NULL;
|
2019-01-19 20:03:48 +01:00
|
|
|
ubi_sb_header sb = {0};
|
2019-01-13 23:27:29 +01:00
|
|
|
int target_subsong = streamFile->stream_index;
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
|
|
|
|
/* checks (number represents the platform, see later) */
|
2018-12-22 22:47:24 +01:00
|
|
|
if (!check_extensions(streamFile, "sb0,sb1,sb2,sb3,sb4,sb5,sb6,sb7"))
|
2017-11-05 17:06:40 +01:00
|
|
|
goto fail;
|
|
|
|
|
2019-01-05 04:02:14 +01:00
|
|
|
/* .sbX (sound bank) is a small multisong format (loaded in memory?) that contains SFX data
|
2017-11-05 17:06:40 +01:00
|
|
|
* but can also reference .ss0/ls0 (sound stream) external files for longer streams.
|
2019-01-19 20:03:48 +01:00
|
|
|
* A companion .sp0 (sound project) describes files and if it uses BANKs (.sbX) or MAPs (.smX). */
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-05 04:02:14 +01:00
|
|
|
|
|
|
|
/* PLATFORM DETECTION */
|
2019-01-05 04:32:07 +01:00
|
|
|
if (!config_sb_platform(&sb, streamFile))
|
2018-12-22 22:47:24 +01:00
|
|
|
goto fail;
|
2019-01-26 16:30:36 +01:00
|
|
|
read_32bit = sb.big_endian ? read_32bitBE : read_32bitLE;
|
2018-12-22 22:47:24 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
if (target_subsong <= 0) target_subsong = 1;
|
2018-12-22 22:47:24 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* use smaller header buffer for performance */
|
2019-01-05 04:02:14 +01:00
|
|
|
streamTest = reopen_streamfile(streamFile, 0x100);
|
|
|
|
if (!streamTest) goto fail;
|
2018-12-22 22:47:24 +01:00
|
|
|
|
|
|
|
|
2019-01-05 04:02:14 +01:00
|
|
|
/* SB HEADER */
|
2019-01-19 20:03:48 +01:00
|
|
|
/* SBx layout: header, section1, section2, extra section, section3, data (all except header can be null) */
|
2018-12-22 22:47:24 +01:00
|
|
|
sb.is_map = 0;
|
2019-01-07 18:03:47 +01:00
|
|
|
sb.version = read_32bit(0x00, streamFile);
|
|
|
|
sb.section1_num = read_32bit(0x04, streamFile);
|
|
|
|
sb.section2_num = read_32bit(0x08, streamFile);
|
|
|
|
sb.section3_num = read_32bit(0x0c, streamFile);
|
|
|
|
sb.sectionX_size = read_32bit(0x10, streamFile);
|
|
|
|
sb.flag1 = read_32bit(0x14, streamFile);
|
|
|
|
sb.flag2 = read_32bit(0x18, streamFile);
|
2018-12-22 22:47:24 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
if (!config_sb_version(&sb, streamFile))
|
|
|
|
goto fail;
|
2019-01-05 04:02:14 +01:00
|
|
|
|
|
|
|
sb.section1_offset = 0x1c;
|
2019-01-26 16:30:36 +01:00
|
|
|
if (sb.cfg.is_padded_section1_offset)
|
|
|
|
sb.section1_offset = align_size_to_block(sb.section1_offset, 0x10);
|
|
|
|
|
|
|
|
sb.section2_offset = sb.section1_offset + sb.cfg.section1_entry_size * sb.section1_num;
|
|
|
|
if (sb.cfg.is_padded_section2_offset)
|
|
|
|
sb.section2_offset = align_size_to_block(sb.section2_offset, 0x10);
|
|
|
|
|
|
|
|
sb.sectionX_offset = sb.section2_offset + sb.cfg.section2_entry_size * sb.section2_num;
|
|
|
|
if (sb.cfg.is_padded_sectionX_offset)
|
|
|
|
sb.sectionX_offset = align_size_to_block(sb.sectionX_offset, 0x10);
|
|
|
|
|
2019-01-05 04:02:14 +01:00
|
|
|
sb.section3_offset = sb.sectionX_offset + sb.sectionX_size;
|
2019-01-26 16:30:36 +01:00
|
|
|
if (sb.cfg.is_padded_section3_offset)
|
|
|
|
sb.section3_offset = align_size_to_block(sb.section3_offset, 0x10);
|
2019-01-02 23:46:39 +01:00
|
|
|
|
2019-02-10 19:02:28 +01:00
|
|
|
if (!parse_sb(&sb, streamTest, target_subsong))
|
2017-11-05 17:06:40 +01:00
|
|
|
goto fail;
|
|
|
|
|
2019-01-05 04:02:14 +01:00
|
|
|
/* CREATE VGMSTREAM */
|
2019-01-19 20:03:48 +01:00
|
|
|
vgmstream = init_vgmstream_ubi_sb_header(&sb, streamTest, streamFile);
|
|
|
|
close_streamfile(streamTest);
|
|
|
|
return vgmstream;
|
2018-12-22 22:47:24 +01:00
|
|
|
|
|
|
|
fail:
|
2019-01-02 23:46:39 +01:00
|
|
|
close_streamfile(streamTest);
|
2018-12-22 22:47:24 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-01-05 04:02:14 +01:00
|
|
|
/* .SMx - maps (sets of custom SBx files) also from Ubisoft's sound engine games in ~2000-2008+ */
|
2018-12-22 22:47:24 +01:00
|
|
|
VGMSTREAM * init_vgmstream_ubi_sm(STREAMFILE *streamFile) {
|
2019-01-19 20:03:48 +01:00
|
|
|
VGMSTREAM* vgmstream = NULL;
|
2019-01-02 23:46:39 +01:00
|
|
|
STREAMFILE *streamTest = NULL;
|
2018-12-22 22:47:24 +01:00
|
|
|
int32_t(*read_32bit)(off_t, STREAMFILE*) = NULL;
|
2019-01-19 20:03:48 +01:00
|
|
|
ubi_sb_header sb = {0}, target_sb = {0};
|
2019-01-13 23:27:29 +01:00
|
|
|
int target_subsong = streamFile->stream_index;
|
2019-01-19 20:03:48 +01:00
|
|
|
int i;
|
2018-12-22 22:47:24 +01:00
|
|
|
|
2019-01-05 04:02:14 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* checks (number represents platform, lmX are localized variations) */
|
2018-12-30 17:32:13 +01:00
|
|
|
if (!check_extensions(streamFile, "sm0,sm1,sm2,sm3,sm4,sm5,sm6,sm7,lm0,lm1,lm2,lm3,lm4,lm5,lm6,lm7"))
|
2018-12-22 22:47:24 +01:00
|
|
|
goto fail;
|
|
|
|
|
2019-01-05 04:02:14 +01:00
|
|
|
/* .smX (sound map) is a set of slightly different sbX files, compiled into one "map" file.
|
2019-01-19 20:03:48 +01:00
|
|
|
* Map has a sbX (called "submap") per named area (example: menu, level1, boss1, level2...).
|
2019-01-05 04:02:14 +01:00
|
|
|
* This counts subsongs from all sbX, so totals can be massive, but there are splitters into mini-smX. */
|
|
|
|
|
2018-12-23 05:20:36 +01:00
|
|
|
|
2019-01-05 04:02:14 +01:00
|
|
|
/* PLATFORM DETECTION */
|
2019-01-05 04:32:07 +01:00
|
|
|
if (!config_sb_platform(&sb, streamFile))
|
2018-12-22 22:47:24 +01:00
|
|
|
goto fail;
|
2019-01-26 16:30:36 +01:00
|
|
|
read_32bit = sb.big_endian ? read_32bitBE : read_32bitLE;
|
2018-12-22 22:47:24 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
if (target_subsong <= 0) target_subsong = 1;
|
2018-12-22 22:47:24 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* use smaller header buffer for performance */
|
2019-01-02 23:46:39 +01:00
|
|
|
streamTest = reopen_streamfile(streamFile, 0x100);
|
|
|
|
if (!streamTest) goto fail;
|
|
|
|
|
2019-01-05 04:02:14 +01:00
|
|
|
|
|
|
|
/* SM BASE HEADER */
|
2019-01-19 20:03:48 +01:00
|
|
|
/* SMx layout: header with N map area offset/sizes + custom SBx with relative offsets */
|
2019-01-05 04:02:14 +01:00
|
|
|
sb.is_map = 1;
|
|
|
|
sb.version = read_32bit(0x00, streamFile);
|
|
|
|
sb.map_start = read_32bit(0x04, streamFile);
|
|
|
|
sb.map_num = read_32bit(0x08, streamFile);
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
if (!config_sb_version(&sb, streamFile))
|
|
|
|
goto fail;
|
2019-01-05 04:02:14 +01:00
|
|
|
|
2018-12-24 12:29:55 +01:00
|
|
|
|
2018-12-22 22:47:24 +01:00
|
|
|
for (i = 0; i < sb.map_num; i++) {
|
2019-01-26 16:30:36 +01:00
|
|
|
off_t offset = sb.map_start + i * sb.cfg.map_entry_size;
|
2019-01-05 04:02:14 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* SUBMAP HEADER */
|
2019-01-05 04:02:14 +01:00
|
|
|
sb.map_type = read_32bit(offset + 0x00, streamFile); /* usually 0/1=first, 0=rest */
|
|
|
|
sb.map_zero = read_32bit(offset + 0x04, streamFile);
|
|
|
|
sb.map_offset = read_32bit(offset + 0x08, streamFile);
|
|
|
|
sb.map_size = read_32bit(offset + 0x0c, streamFile); /* includes sbX header, but not internal streams */
|
2019-01-19 20:03:48 +01:00
|
|
|
read_string(sb.map_name, sizeof(sb.map_name), offset + 0x10, streamFile); /* null-terminated and may contain garbage after null */
|
2019-01-26 16:30:36 +01:00
|
|
|
if (sb.cfg.map_version >= 3)
|
2019-01-05 04:02:14 +01:00
|
|
|
sb.map_unknown = read_32bit(offset + 0x30, streamFile); /* uncommon, id/config? longer name? mem garbage? */
|
|
|
|
|
|
|
|
/* SB HEADER */
|
2019-01-19 20:03:48 +01:00
|
|
|
/* SBx layout: base header, section1, section2, section4, extra section, section3, data (all except header can be null?) */
|
2019-01-05 04:02:14 +01:00
|
|
|
sb.version_empty = read_32bit(sb.map_offset + 0x00, streamFile); /* sbX in maps don't set version */
|
|
|
|
sb.section1_offset = read_32bit(sb.map_offset + 0x04, streamFile) + sb.map_offset;
|
|
|
|
sb.section1_num = read_32bit(sb.map_offset + 0x08, streamFile);
|
|
|
|
sb.section2_offset = read_32bit(sb.map_offset + 0x0c, streamFile) + sb.map_offset;
|
|
|
|
sb.section2_num = read_32bit(sb.map_offset + 0x10, streamFile);
|
2018-12-24 12:29:55 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
if (sb.cfg.map_version < 3) {
|
2019-01-05 04:02:14 +01:00
|
|
|
sb.section3_offset = read_32bit(sb.map_offset + 0x14, streamFile) + sb.map_offset;
|
|
|
|
sb.section3_num = read_32bit(sb.map_offset + 0x18, streamFile);
|
|
|
|
sb.sectionX_offset = read_32bit(sb.map_offset + 0x1c, streamFile) + sb.map_offset;
|
|
|
|
sb.sectionX_size = read_32bit(sb.map_offset + 0x20, streamFile);
|
2018-12-24 12:29:55 +01:00
|
|
|
} else {
|
2019-01-05 04:02:14 +01:00
|
|
|
sb.section4_offset = read_32bit(sb.map_offset + 0x14, streamFile);
|
|
|
|
sb.section4_num = read_32bit(sb.map_offset + 0x18, streamFile);
|
|
|
|
sb.section3_offset = read_32bit(sb.map_offset + 0x1c, streamFile) + sb.map_offset;
|
|
|
|
sb.section3_num = read_32bit(sb.map_offset + 0x20, streamFile);
|
|
|
|
sb.sectionX_offset = read_32bit(sb.map_offset + 0x24, streamFile) + sb.map_offset;
|
|
|
|
sb.sectionX_size = read_32bit(sb.map_offset + 0x28, streamFile);
|
|
|
|
|
2018-12-24 12:29:55 +01:00
|
|
|
/* latest map format has another section with sounds after section 2 */
|
2019-01-26 16:30:36 +01:00
|
|
|
sb.section2_num += sb.section4_num; /* let's just merge it with section 2 */
|
2019-01-05 04:02:14 +01:00
|
|
|
sb.sectionX_offset += sb.section4_offset; /* for some reason, this is relative to section 4 here */
|
2018-12-24 12:29:55 +01:00
|
|
|
}
|
2018-12-22 22:47:24 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
VGM_ASSERT(sb.map_type != 0 && sb.map_type != 1, "UBI SM: unknown map_type at %x\n", (uint32_t)offset);
|
|
|
|
VGM_ASSERT(sb.map_zero != 0, "UBI SM: unknown map_zero at %x\n", (uint32_t)offset);
|
2019-01-05 04:02:14 +01:00
|
|
|
//;VGM_ASSERT(sb.map_unknown != 0, "UBI SM: unknown map_unknown at %x\n", (uint32_t)offset);
|
2019-01-19 20:03:48 +01:00
|
|
|
VGM_ASSERT(sb.version_empty != 0, "UBI SM: unknown version_empty at %x\n", (uint32_t)offset);
|
2019-01-05 04:02:14 +01:00
|
|
|
|
2019-02-10 19:02:28 +01:00
|
|
|
if (!parse_sb(&sb, streamTest, target_subsong))
|
2018-12-22 22:47:24 +01:00
|
|
|
goto fail;
|
2018-12-23 05:20:36 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* snapshot of current sb if subsong was found
|
|
|
|
* (it gets rewritten and we need exact values for sequences and stuff) */
|
|
|
|
if (sb.type != UBI_NONE) {
|
|
|
|
target_sb = sb; /* memcpy */
|
2019-01-20 17:16:44 +01:00
|
|
|
sb.type = UBI_NONE; /* reset parsed flag */
|
2019-01-19 20:03:48 +01:00
|
|
|
}
|
2018-12-23 05:20:36 +01:00
|
|
|
}
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
target_sb.total_subsongs = sb.total_subsongs;
|
2019-01-05 04:02:14 +01:00
|
|
|
|
|
|
|
/* CREATE VGMSTREAM */
|
2019-01-19 20:03:48 +01:00
|
|
|
vgmstream = init_vgmstream_ubi_sb_header(&target_sb, streamTest, streamFile);
|
|
|
|
close_streamfile(streamTest);
|
|
|
|
return vgmstream;
|
2018-12-22 22:47:24 +01:00
|
|
|
|
|
|
|
fail:
|
2019-01-02 23:46:39 +01:00
|
|
|
close_streamfile(streamTest);
|
2018-12-22 22:47:24 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
#if 0
|
|
|
|
/* .BNM - proto-sbX with map style format [Donald Duck: Goin' Quackers (PC), Tonic Trouble (PC)] */
|
|
|
|
VGMSTREAM * init_vgmstream_ubi_bnm(STREAMFILE *streamFile) {
|
|
|
|
|
|
|
|
/* v0x00000000, header is somewhat like a map-style bank (offsets + sizes) but sectionX/3 fields
|
|
|
|
* are fixed/reserved (unused?). Header entry sizes and config looks the same as early games.
|
|
|
|
* Main codecs are 01=RAW_PCM and 04=FMT_APM (.apm if external, possibly Ubi IMA v0 but has a full header).
|
|
|
|
* The sound engine doesn't seem to be named DARE yet.
|
|
|
|
*/
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
/* .BLK - maps in separate .blk chunks [Donald Duck: Goin' Quackers (PS2), The Jungle Book Rhythm N'Groove (PS2)] */
|
|
|
|
VGMSTREAM * init_vgmstream_ubi_blk(STREAMFILE *streamFile) {
|
|
|
|
|
|
|
|
/* Somewhat equivalent to a v0x00000003 map:
|
|
|
|
* - HEADER.BLK: base map header (slightly different?) + submaps headers
|
|
|
|
* - EVT.BLK: section1 from all submaps
|
|
|
|
* - RES.BLK: section2 + sectionX from all submaps
|
|
|
|
* - MAPS.BLK, MAPLANG.BLK: section3 variation?
|
|
|
|
* - STREAMED.BLK, STRLANG.BLK: audio data
|
|
|
|
*
|
|
|
|
* Parsing may be be simplified with multifile_streamfiles?
|
|
|
|
*/
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* ************************************************************************* */
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
static VGMSTREAM * init_vgmstream_ubi_sb_base(ubi_sb_header *sb, STREAMFILE *streamHead, STREAMFILE *streamData, off_t start_offset) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
2019-01-05 04:02:14 +01:00
|
|
|
|
2017-11-11 15:56:29 +01:00
|
|
|
|
2017-11-05 17:06:40 +01:00
|
|
|
/* build the VGMSTREAM */
|
2019-01-19 20:03:48 +01:00
|
|
|
vgmstream = allocate_vgmstream(sb->channels, sb->loop_flag);
|
2017-11-05 17:06:40 +01:00
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
2019-01-07 18:03:47 +01:00
|
|
|
vgmstream->meta_type = meta_UBI_SB;
|
2018-12-22 22:47:24 +01:00
|
|
|
vgmstream->sample_rate = sb->sample_rate;
|
2019-01-13 23:27:29 +01:00
|
|
|
vgmstream->num_streams = sb->total_subsongs;
|
2018-12-22 22:47:24 +01:00
|
|
|
vgmstream->stream_size = sb->stream_size;
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-07 22:10:48 +01:00
|
|
|
vgmstream->num_samples = sb->num_samples;
|
|
|
|
vgmstream->loop_start_sample = sb->loop_start;
|
|
|
|
vgmstream->loop_end_sample = sb->num_samples;
|
|
|
|
|
2018-12-22 22:47:24 +01:00
|
|
|
switch(sb->codec) {
|
2019-01-19 20:03:48 +01:00
|
|
|
case UBI_IMA:
|
2017-11-05 17:06:40 +01:00
|
|
|
vgmstream->coding_type = coding_UBI_IMA;
|
|
|
|
vgmstream->layout_type = layout_none;
|
|
|
|
break;
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
case UBI_ADPCM:
|
2019-02-03 01:47:44 +01:00
|
|
|
/* todo custom Ubi 4/6-bit ADPCM (4b for music/stereo and 6b for voices?)
|
|
|
|
* - ~0x30: block-like header (some versions may not have it).
|
|
|
|
* Seems to contain frame size, channels, sometimes sample rate/samples/etc.
|
|
|
|
* - 0x34 per channel: channel header, starts with 0x02
|
|
|
|
* - 0x600: frame data (unknown interleave)
|
|
|
|
* - 0x02: ADPCM hist?
|
|
|
|
*
|
|
|
|
* frame data looks decoded in two passes (first may expand nibble somehow, other
|
|
|
|
* seems to calculate diffs)
|
|
|
|
*
|
|
|
|
* used in:
|
|
|
|
* - Batman: Vengeance (PC)
|
|
|
|
* - Splinter Cell (PC)
|
|
|
|
* - some Myst IV (PC/Xbox) banks (ex. puzzle_si_splintercell.sb2)
|
|
|
|
* - Splinter Cell Essentials (PSP) voices (header has extra 0x08 with fixed value)
|
|
|
|
*/
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
VGM_LOG("UBI SB: unsupported Ubi ADPCM found\n");
|
|
|
|
goto fail;
|
|
|
|
|
2017-11-05 17:06:40 +01:00
|
|
|
case RAW_PCM:
|
2019-01-26 16:30:36 +01:00
|
|
|
vgmstream->coding_type = coding_PCM16LE; /* always LE */
|
2017-11-05 17:06:40 +01:00
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = 0x02;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RAW_PSX:
|
|
|
|
vgmstream->coding_type = coding_PSX;
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
2019-02-03 01:47:44 +01:00
|
|
|
vgmstream->interleave_block_size = (sb->cfg.audio_interleave) ?
|
|
|
|
sb->cfg.audio_interleave :
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->stream_size / sb->channels;
|
|
|
|
if (vgmstream->num_samples == 0) { /* early PS2 games may not set it for internal streams */
|
|
|
|
vgmstream->num_samples = ps_bytes_to_samples(sb->stream_size, sb->channels);
|
2019-01-07 22:10:48 +01:00
|
|
|
vgmstream->loop_end_sample = vgmstream->num_samples;
|
|
|
|
}
|
2017-11-05 17:06:40 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RAW_XBOX:
|
2018-02-17 12:30:14 +01:00
|
|
|
vgmstream->coding_type = coding_XBOX_IMA;
|
2017-11-05 17:06:40 +01:00
|
|
|
vgmstream->layout_type = layout_none;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RAW_DSP:
|
|
|
|
vgmstream->coding_type = coding_NGC_DSP;
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
2019-01-19 20:03:48 +01:00
|
|
|
vgmstream->interleave_block_size = align_size_to_block(sb->stream_size / sb->channels, 0x08); /* frame-aligned */
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-02-10 19:02:28 +01:00
|
|
|
/* mini DSP header (first 0x10 seem to contain DSP header fields like nibbles and format) */
|
|
|
|
dsp_read_coefs_be(vgmstream, streamHead, sb->extra_offset + 0x10, 0x40);
|
|
|
|
dsp_read_hist_be (vgmstream, streamHead, sb->extra_offset + 0x34, 0x40); /* after gain/initial ps */
|
2017-11-05 17:06:40 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FMT_VAG:
|
2019-01-26 16:30:36 +01:00
|
|
|
/* skip VAG header (some sb4 use VAG and others raw PSX) */
|
2017-11-05 17:06:40 +01:00
|
|
|
if (read_32bitBE(start_offset, streamData) == 0x56414770) { /* "VAGp" */
|
|
|
|
start_offset += 0x30;
|
2018-12-22 22:47:24 +01:00
|
|
|
sb->stream_size -= 0x30;
|
2017-11-05 17:06:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
vgmstream->coding_type = coding_PSX;
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
2018-12-22 22:47:24 +01:00
|
|
|
vgmstream->interleave_block_size = sb->stream_size / sb->channels;
|
2017-11-05 17:06:40 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
#ifdef VGM_USE_FFMPEG
|
|
|
|
case FMT_AT3: {
|
|
|
|
ffmpeg_codec_data *ffmpeg_data;
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
/* skip weird value (3, 4) in Brothers in Arms: D-Day (PSP) */
|
2017-12-07 23:54:05 +01:00
|
|
|
if (read_32bitBE(start_offset+0x04,streamData) == 0x52494646) {
|
2019-01-05 04:02:14 +01:00
|
|
|
VGM_LOG("UBI SB: skipping unknown value 0x%x before RIFF\n", read_32bitBE(start_offset+0x00,streamData));
|
2017-12-07 23:54:05 +01:00
|
|
|
start_offset += 0x04;
|
2018-12-22 22:47:24 +01:00
|
|
|
sb->stream_size -= 0x04;
|
2017-12-07 23:54:05 +01:00
|
|
|
}
|
|
|
|
|
2018-12-22 22:47:24 +01:00
|
|
|
ffmpeg_data = init_ffmpeg_offset(streamData, start_offset, sb->stream_size);
|
2017-11-05 17:06:40 +01:00
|
|
|
if ( !ffmpeg_data ) goto fail;
|
|
|
|
vgmstream->codec_data = ffmpeg_data;
|
|
|
|
vgmstream->coding_type = coding_FFmpeg;
|
|
|
|
vgmstream->layout_type = layout_none;
|
2018-08-14 16:35:17 +02:00
|
|
|
if (ffmpeg_data->skipSamples <= 0) /* in case FFmpeg didn't get them */
|
|
|
|
ffmpeg_set_skip_samples(ffmpeg_data, riff_get_fact_skip_samples(streamData, start_offset));
|
2017-11-05 17:06:40 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-12-21 15:17:10 +01:00
|
|
|
case RAW_AT3: {
|
2018-12-24 12:29:55 +01:00
|
|
|
ffmpeg_codec_data *ffmpeg_data;
|
2018-12-21 15:17:10 +01:00
|
|
|
uint8_t buf[0x100];
|
|
|
|
int32_t bytes, block_size, encoder_delay, joint_stereo;
|
|
|
|
|
2018-12-22 22:47:24 +01:00
|
|
|
block_size = 0x98 * sb->channels;
|
2018-12-21 15:17:10 +01:00
|
|
|
joint_stereo = 0;
|
|
|
|
encoder_delay = 0x00; /* TODO: this is incorrect */
|
|
|
|
|
2019-01-05 04:02:14 +01:00
|
|
|
bytes = ffmpeg_make_riff_atrac3(buf, 0x100, sb->num_samples, sb->stream_size, sb->channels, sb->sample_rate, block_size, joint_stereo, encoder_delay);
|
2018-12-24 12:29:55 +01:00
|
|
|
ffmpeg_data = init_ffmpeg_header_offset(streamData, buf, bytes, start_offset, sb->stream_size);
|
|
|
|
if (!ffmpeg_data) goto fail;
|
|
|
|
vgmstream->codec_data = ffmpeg_data;
|
2018-12-21 15:17:10 +01:00
|
|
|
vgmstream->coding_type = coding_FFmpeg;
|
|
|
|
vgmstream->layout_type = layout_none;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
//todo: some XMA1 decode a bit strangely at certain positions (FFmpeg bug?)
|
2018-12-21 15:17:10 +01:00
|
|
|
case FMT_XMA1: {
|
|
|
|
ffmpeg_codec_data *ffmpeg_data;
|
|
|
|
uint8_t buf[0x100];
|
2019-01-26 16:30:36 +01:00
|
|
|
uint32_t sec1_num, sec2_num, sec3_num, bits_per_frame;
|
2018-12-30 20:25:14 +01:00
|
|
|
uint8_t flag;
|
2019-01-02 23:31:14 +01:00
|
|
|
size_t bytes, chunk_size, header_size, data_size;
|
2018-12-21 15:17:10 +01:00
|
|
|
off_t header_offset;
|
|
|
|
|
|
|
|
chunk_size = 0x20;
|
|
|
|
|
|
|
|
/* formatted XMA sounds have a strange custom header */
|
2018-12-30 20:25:14 +01:00
|
|
|
header_offset = start_offset; /* XMA fmt chunk at the start */
|
|
|
|
flag = read_8bit(header_offset + 0x20, streamData);
|
|
|
|
sec2_num = read_32bitBE(header_offset + 0x24, streamData); /* number of XMA frames */
|
|
|
|
sec1_num = read_32bitBE(header_offset + 0x28, streamData);
|
|
|
|
sec3_num = read_32bitBE(header_offset + 0x2c, streamData);
|
2018-12-31 21:05:58 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
bits_per_frame = 4;
|
|
|
|
if (flag == 0x02 || flag == 0x04)
|
2018-12-31 21:05:58 +01:00
|
|
|
bits_per_frame = 2;
|
2019-01-19 20:03:48 +01:00
|
|
|
else if (flag == 0x08)
|
|
|
|
bits_per_frame = 1;
|
2018-12-30 20:25:14 +01:00
|
|
|
|
2018-12-31 21:05:58 +01:00
|
|
|
header_size = 0x30;
|
|
|
|
header_size += sec1_num * 0x04;
|
2019-01-19 20:03:48 +01:00
|
|
|
header_size += align_size_to_block(sec2_num * bits_per_frame, 32) / 8; /* bitstream seek table? */
|
2018-12-31 21:05:58 +01:00
|
|
|
header_size += sec3_num * 0x08;
|
2018-12-30 20:25:14 +01:00
|
|
|
start_offset += header_size;
|
2019-01-26 16:30:36 +01:00
|
|
|
data_size = sec2_num * 0x800;
|
2018-12-21 15:17:10 +01:00
|
|
|
|
|
|
|
bytes = ffmpeg_make_riff_xma_from_fmt_chunk(buf, 0x100, header_offset, chunk_size, data_size, streamData, 1);
|
|
|
|
|
|
|
|
ffmpeg_data = init_ffmpeg_header_offset(streamData, buf, bytes, start_offset, data_size);
|
|
|
|
if (!ffmpeg_data) goto fail;
|
|
|
|
vgmstream->codec_data = ffmpeg_data;
|
|
|
|
vgmstream->coding_type = coding_FFmpeg;
|
|
|
|
vgmstream->layout_type = layout_none;
|
2019-01-19 20:03:48 +01:00
|
|
|
|
|
|
|
xma_fix_raw_samples_ch(vgmstream, streamData, start_offset, data_size, sb->channels, 0, 0);
|
2018-12-21 15:17:10 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-12-17 08:05:45 +01:00
|
|
|
case RAW_XMA1: {
|
|
|
|
ffmpeg_codec_data *ffmpeg_data;
|
|
|
|
uint8_t buf[0x100];
|
2018-12-21 15:17:10 +01:00
|
|
|
size_t bytes, chunk_size;
|
2018-12-17 08:05:45 +01:00
|
|
|
off_t header_offset;
|
2019-01-07 18:03:47 +01:00
|
|
|
|
2018-12-22 22:47:24 +01:00
|
|
|
VGM_ASSERT(sb->is_external, "Ubi SB: Raw XMA used for external sound\n");
|
2018-12-17 08:05:45 +01:00
|
|
|
|
2018-12-23 02:15:50 +01:00
|
|
|
/* get XMA header from extra section */
|
2018-12-21 15:17:10 +01:00
|
|
|
chunk_size = 0x20;
|
2018-12-23 16:55:20 +01:00
|
|
|
header_offset = sb->xma_header_offset;
|
2019-03-16 13:58:28 +01:00
|
|
|
if (header_offset == 0)
|
|
|
|
header_offset = sb->extra_offset;
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
bytes = ffmpeg_make_riff_xma_from_fmt_chunk(buf, 0x100, header_offset, chunk_size, sb->stream_size, streamHead, 1);
|
2018-12-17 08:05:45 +01:00
|
|
|
|
2018-12-22 22:47:24 +01:00
|
|
|
ffmpeg_data = init_ffmpeg_header_offset(streamData, buf, bytes, start_offset, sb->stream_size);
|
2018-12-17 08:05:45 +01:00
|
|
|
if (!ffmpeg_data) goto fail;
|
|
|
|
vgmstream->codec_data = ffmpeg_data;
|
|
|
|
vgmstream->coding_type = coding_FFmpeg;
|
|
|
|
vgmstream->layout_type = layout_none;
|
2019-01-19 20:03:48 +01:00
|
|
|
|
|
|
|
xma_fix_raw_samples_ch(vgmstream, streamData, start_offset, sb->stream_size, sb->channels, 0, 0);
|
2018-12-17 08:05:45 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-11-05 17:06:40 +01:00
|
|
|
case FMT_OGG: {
|
|
|
|
ffmpeg_codec_data *ffmpeg_data;
|
|
|
|
|
2018-12-22 22:47:24 +01:00
|
|
|
ffmpeg_data = init_ffmpeg_offset(streamData, start_offset, sb->stream_size);
|
2017-11-05 17:06:40 +01:00
|
|
|
if ( !ffmpeg_data ) goto fail;
|
|
|
|
vgmstream->codec_data = ffmpeg_data;
|
|
|
|
vgmstream->coding_type = coding_FFmpeg;
|
|
|
|
vgmstream->layout_type = layout_none;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
2019-01-07 18:03:47 +01:00
|
|
|
case FMT_CWAV:
|
2019-01-19 20:03:48 +01:00
|
|
|
if (sb->channels > 1) goto fail; /* unknown layout */
|
2019-01-07 18:03:47 +01:00
|
|
|
vgmstream->coding_type = coding_NGC_DSP;
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = 0x08;
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
dsp_read_coefs_le(vgmstream,streamData,start_offset + 0x7c, 0x40);
|
2019-01-07 22:10:48 +01:00
|
|
|
start_offset += 0xe0; /* skip CWAV header */
|
2019-01-07 18:03:47 +01:00
|
|
|
break;
|
|
|
|
|
2017-11-05 17:06:40 +01:00
|
|
|
default:
|
|
|
|
VGM_LOG("UBI SB: unknown codec\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2019-01-05 04:02:14 +01:00
|
|
|
/* open the actual for decoding (streamData can be an internal or external stream) */
|
2017-11-05 17:06:40 +01:00
|
|
|
if ( !vgmstream_open_stream(vgmstream, streamData, start_offset) )
|
|
|
|
goto fail;
|
2019-01-19 20:03:48 +01:00
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
close_vgmstream(vgmstream);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VGMSTREAM * init_vgmstream_ubi_sb_audio(ubi_sb_header *sb, STREAMFILE *streamTest, STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
|
|
|
STREAMFILE *streamData = NULL;
|
|
|
|
|
|
|
|
/* open external stream if needed */
|
|
|
|
if (sb->is_external) {
|
|
|
|
streamData = open_streamfile_by_filename(streamFile,sb->resource_name);
|
|
|
|
if (streamData == NULL) {
|
|
|
|
VGM_LOG("UBI SB: external stream '%s' not found\n", sb->resource_name);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
streamData = streamFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* init actual VGMSTREAM */
|
|
|
|
vgmstream = init_vgmstream_ubi_sb_base(sb, streamTest, streamData, sb->stream_offset);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2018-12-22 22:47:24 +01:00
|
|
|
if (sb->is_external && streamData) close_streamfile(streamData);
|
2017-11-05 17:06:40 +01:00
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
2018-12-22 22:47:24 +01:00
|
|
|
if (sb->is_external && streamData) close_streamfile(streamData);
|
2017-11-05 17:06:40 +01:00
|
|
|
close_vgmstream(vgmstream);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
static VGMSTREAM * init_vgmstream_ubi_sb_layer(ubi_sb_header *sb, STREAMFILE *streamTest, STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
|
|
|
layered_layout_data* data = NULL;
|
|
|
|
STREAMFILE* temp_streamFile = NULL;
|
|
|
|
STREAMFILE *streamData = NULL;
|
2019-02-10 19:02:28 +01:00
|
|
|
size_t full_stream_size = sb->stream_size;
|
2019-02-22 23:52:09 +01:00
|
|
|
int i, total_channels = 0;
|
2019-01-19 20:03:48 +01:00
|
|
|
|
|
|
|
/* open external stream if needed */
|
|
|
|
if (sb->is_external) {
|
|
|
|
streamData = open_streamfile_by_filename(streamFile,sb->resource_name);
|
|
|
|
if (streamData == NULL) {
|
|
|
|
VGM_LOG("UBI SB: external stream '%s' not found\n", sb->resource_name);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
streamData = streamFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* init layout */
|
|
|
|
data = init_layout_layered(sb->layer_count);
|
|
|
|
if (!data) goto fail;
|
|
|
|
|
|
|
|
/* open all layers and mix */
|
|
|
|
for (i = 0; i < sb->layer_count; i++) {
|
|
|
|
/* prepare streamfile from a single layer section */
|
2019-03-16 13:58:28 +01:00
|
|
|
temp_streamFile = setup_ubi_sb_streamfile(streamData, sb->stream_offset, full_stream_size, i, sb->layer_count, sb->big_endian, sb->cfg.layer_hijack);
|
2019-01-19 20:03:48 +01:00
|
|
|
if (!temp_streamFile) goto fail;
|
|
|
|
|
2019-02-10 19:02:28 +01:00
|
|
|
sb->stream_size = get_streamfile_size(temp_streamFile);
|
2019-02-22 23:52:09 +01:00
|
|
|
sb->channels = sb->layer_channels[i];
|
|
|
|
total_channels += sb->layer_channels[i];
|
2019-02-10 19:02:28 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* build the layer VGMSTREAM (standard sb with custom streamfile) */
|
|
|
|
data->layers[i] = init_vgmstream_ubi_sb_base(sb, streamTest, temp_streamFile, 0x00);
|
|
|
|
if (!data->layers[i]) goto fail;
|
|
|
|
|
|
|
|
close_streamfile(temp_streamFile);
|
2019-01-26 16:30:36 +01:00
|
|
|
temp_streamFile = NULL;
|
2019-01-19 20:03:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!setup_layout_layered(data))
|
|
|
|
goto fail;
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* build the base VGMSTREAM */
|
2019-02-22 23:52:09 +01:00
|
|
|
vgmstream = allocate_vgmstream(total_channels, sb->loop_flag);
|
2019-01-19 20:03:48 +01:00
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
|
|
|
vgmstream->meta_type = meta_UBI_SB;
|
|
|
|
vgmstream->sample_rate = sb->sample_rate;
|
|
|
|
vgmstream->num_streams = sb->total_subsongs;
|
2019-02-10 19:02:28 +01:00
|
|
|
vgmstream->stream_size = full_stream_size;
|
2019-01-19 20:03:48 +01:00
|
|
|
|
|
|
|
vgmstream->num_samples = sb->num_samples;
|
|
|
|
vgmstream->loop_start_sample = sb->loop_start;
|
|
|
|
vgmstream->loop_end_sample = sb->num_samples;
|
|
|
|
|
|
|
|
vgmstream->coding_type = data->layers[0]->coding_type;
|
|
|
|
vgmstream->layout_type = layout_layered;
|
|
|
|
vgmstream->layout_data = data;
|
|
|
|
|
|
|
|
if (sb->is_external && streamData) close_streamfile(streamData);
|
|
|
|
|
|
|
|
return vgmstream;
|
|
|
|
fail:
|
|
|
|
close_streamfile(temp_streamFile);
|
|
|
|
if (sb->is_external && streamData) close_streamfile(streamData);
|
|
|
|
if (vgmstream)
|
|
|
|
close_vgmstream(vgmstream);
|
|
|
|
else
|
|
|
|
free_layout_layered(data);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VGMSTREAM * init_vgmstream_ubi_sb_sequence(ubi_sb_header *sb, STREAMFILE *streamTest, STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
|
|
|
segmented_layout_data* data = NULL;
|
|
|
|
int i;
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
//todo optimization: open streamData once / only if new name (doesn't change 99% of the time)
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* init layout */
|
|
|
|
data = init_layout_segmented(sb->sequence_count);
|
|
|
|
if (!data) goto fail;
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->channels = 0;
|
2019-01-19 20:03:48 +01:00
|
|
|
sb->num_samples = 0;
|
|
|
|
|
|
|
|
/* open all segments and mix */
|
|
|
|
for (i = 0; i < sb->sequence_count; i++) {
|
|
|
|
ubi_sb_header temp_sb = *sb; /* memcpy'ed */
|
|
|
|
int entry_index = sb->sequence_chain[i];
|
2019-01-26 16:30:36 +01:00
|
|
|
off_t entry_offset = sb->section2_offset + sb->cfg.section2_entry_size * entry_index;
|
2019-01-19 20:03:48 +01:00
|
|
|
|
|
|
|
/* parse expected entry */
|
|
|
|
if (!parse_header(&temp_sb, streamTest, entry_offset, entry_index))
|
|
|
|
goto fail;
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
if (temp_sb.type == UBI_NONE || temp_sb.type == UBI_SEQUENCE) {
|
2019-01-19 20:03:48 +01:00
|
|
|
VGM_LOG("UBI SB: unexpected sequence entry type at %x\n", (uint32_t)entry_offset);
|
|
|
|
goto fail; /* technically ok but too much recursiveness? */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* build the layer VGMSTREAM (current sb entry config) */
|
|
|
|
data->segments[i] = init_vgmstream_ubi_sb_header(&temp_sb, streamTest, streamFile);
|
|
|
|
if (!data->segments[i]) goto fail;
|
|
|
|
|
2019-01-20 17:16:44 +01:00
|
|
|
if (i == sb->sequence_loop)
|
|
|
|
sb->loop_start = sb->num_samples;
|
2019-01-19 20:03:48 +01:00
|
|
|
sb->num_samples += data->segments[i]->num_samples;
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
/* save current (silences don't have values, so this unsures they know when memcpy'ed) */
|
|
|
|
sb->channels = temp_sb.channels;
|
|
|
|
sb->sample_rate = temp_sb.sample_rate;
|
|
|
|
}
|
2019-01-20 17:16:44 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
if (!setup_layout_segmented(data))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
/* build the base VGMSTREAM */
|
2019-01-20 17:16:44 +01:00
|
|
|
vgmstream = allocate_vgmstream(data->segments[0]->channels, !sb->sequence_single);
|
2019-01-19 20:03:48 +01:00
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
|
|
|
vgmstream->meta_type = meta_UBI_SB;
|
|
|
|
vgmstream->sample_rate = data->segments[0]->sample_rate;
|
|
|
|
vgmstream->num_streams = sb->total_subsongs;
|
|
|
|
//vgmstream->stream_size = sb->stream_size; /* auto when getting avg br */
|
|
|
|
|
|
|
|
vgmstream->num_samples = sb->num_samples;
|
|
|
|
vgmstream->loop_start_sample = sb->loop_start;
|
|
|
|
vgmstream->loop_end_sample = sb->num_samples;
|
|
|
|
|
|
|
|
vgmstream->coding_type = data->segments[0]->coding_type;
|
|
|
|
vgmstream->layout_type = layout_segmented;
|
|
|
|
vgmstream->layout_data = data;
|
|
|
|
|
|
|
|
return vgmstream;
|
|
|
|
fail:
|
|
|
|
if (vgmstream)
|
|
|
|
close_vgmstream(vgmstream);
|
|
|
|
else
|
|
|
|
free_layout_segmented(data);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
static size_t silence_io_read(STREAMFILE *streamfile, uint8_t *dest, off_t offset, size_t length, void* data) {
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < length; i++) {
|
|
|
|
dest[i] = 0;
|
|
|
|
}
|
|
|
|
return length; /* pretend we read zeroes */
|
|
|
|
}
|
|
|
|
static size_t silence_io_size(STREAMFILE *streamfile, void* data) {
|
|
|
|
return 0x7FFFFFF; /* whatevs */
|
|
|
|
}
|
|
|
|
static STREAMFILE* setup_silence_streamfile(STREAMFILE *streamFile) {
|
|
|
|
STREAMFILE *temp_streamFile = NULL, *new_streamFile = NULL;
|
|
|
|
|
|
|
|
/* setup custom streamfile */
|
|
|
|
new_streamFile = open_wrap_streamfile(streamFile);
|
|
|
|
if (!new_streamFile) goto fail;
|
|
|
|
temp_streamFile = new_streamFile;
|
|
|
|
|
|
|
|
new_streamFile = open_io_streamfile(temp_streamFile, NULL,0, silence_io_read,silence_io_size);
|
|
|
|
if (!new_streamFile) goto fail;
|
|
|
|
temp_streamFile = new_streamFile;
|
|
|
|
|
|
|
|
return temp_streamFile;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
close_streamfile(temp_streamFile);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VGMSTREAM * init_vgmstream_ubi_sb_silence(ubi_sb_header *sb, STREAMFILE *streamTest, STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
|
|
|
STREAMFILE *temp_streamFile = NULL;
|
|
|
|
int channel_count, sample_rate;
|
|
|
|
|
|
|
|
channel_count = sb->channels;
|
|
|
|
sample_rate = sb->sample_rate;
|
|
|
|
|
|
|
|
/* by default silences don't have settings so let's pretend */
|
|
|
|
if (channel_count == 0)
|
|
|
|
channel_count = 2;
|
|
|
|
if (sample_rate == 0)
|
|
|
|
sample_rate = 48000;
|
|
|
|
|
|
|
|
|
|
|
|
/* build the VGMSTREAM */
|
|
|
|
vgmstream = allocate_vgmstream(channel_count, 0);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
|
|
|
vgmstream->meta_type = meta_UBI_SB;
|
|
|
|
vgmstream->sample_rate = sample_rate;
|
|
|
|
|
2019-02-11 10:37:54 +01:00
|
|
|
vgmstream->num_samples = (int32_t)(sb->duration * (float)sample_rate);
|
2019-01-26 16:30:36 +01:00
|
|
|
vgmstream->num_streams = sb->total_subsongs;
|
|
|
|
vgmstream->stream_size = vgmstream->num_samples * channel_count * 0x02; /* PCM size */
|
|
|
|
|
|
|
|
vgmstream->coding_type = coding_PCM16LE;
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = 0x02;
|
|
|
|
|
|
|
|
temp_streamFile = setup_silence_streamfile(streamFile);
|
|
|
|
if ( !vgmstream_open_stream(vgmstream, temp_streamFile, 0x00) )
|
|
|
|
goto fail;
|
|
|
|
close_streamfile(temp_streamFile);
|
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
close_vgmstream(vgmstream);
|
|
|
|
close_streamfile(temp_streamFile);
|
|
|
|
return vgmstream;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
static VGMSTREAM * init_vgmstream_ubi_sb_header(ubi_sb_header *sb, STREAMFILE* streamTest, STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
|
|
|
|
|
|
|
if (sb->total_subsongs == 0) {
|
|
|
|
VGM_LOG("UBI SB: no subsongs\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2019-02-03 01:47:44 +01:00
|
|
|
//;VGM_LOG("UBI SB: target at %x + %x, extra=%x, name=%s, g=%i, t=%i\n",
|
2019-01-26 16:30:36 +01:00
|
|
|
// (uint32_t)sb->header_offset, sb->cfg.section2_entry_size, (uint32_t)sb->extra_offset, sb->resource_name, sb->group_id, sb->stream_type);
|
2019-01-19 20:03:48 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
//;VGM_LOG("UBI SB: stream offset=%x, size=%x, name=%s\n", (uint32_t)sb->stream_offset, sb->stream_size, sb->is_external ? sb->resource_name : "internal" );
|
2019-01-19 20:03:48 +01:00
|
|
|
|
|
|
|
switch(sb->type) {
|
|
|
|
case UBI_AUDIO:
|
|
|
|
vgmstream = init_vgmstream_ubi_sb_audio(sb, streamTest, streamFile);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UBI_LAYER:
|
|
|
|
vgmstream = init_vgmstream_ubi_sb_layer(sb, streamTest, streamFile);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UBI_SEQUENCE:
|
|
|
|
vgmstream = init_vgmstream_ubi_sb_sequence(sb, streamTest, streamFile);
|
|
|
|
break;
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
case UBI_SILENCE:
|
|
|
|
vgmstream = init_vgmstream_ubi_sb_silence(sb, streamTest, streamFile);
|
|
|
|
break;
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
case UBI_NONE:
|
|
|
|
default:
|
|
|
|
VGM_LOG("UBI SB: subsong not found/parsed\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
|
|
|
strcpy(vgmstream->stream_name, sb->readable_name);
|
|
|
|
return vgmstream;
|
|
|
|
fail:
|
|
|
|
close_vgmstream(vgmstream);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ************************************************************************* */
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
static void build_readable_name(char * buf, size_t buf_size, ubi_sb_header * sb) {
|
2019-01-13 23:27:29 +01:00
|
|
|
const char *grp_name;
|
|
|
|
const char *res_name;
|
|
|
|
uint32_t id;
|
|
|
|
uint32_t type;
|
|
|
|
int index;
|
|
|
|
|
|
|
|
/* config */
|
|
|
|
if (sb->is_map)
|
|
|
|
grp_name = sb->map_name;
|
|
|
|
else
|
2019-02-03 01:47:44 +01:00
|
|
|
grp_name = "bank";
|
2019-01-13 23:27:29 +01:00
|
|
|
id = sb->header_id;
|
|
|
|
type = sb->header_type;
|
|
|
|
if (sb->is_map)
|
2019-01-19 20:03:48 +01:00
|
|
|
index = sb->header_index; //sb->bank_subsongs;
|
2019-01-13 23:27:29 +01:00
|
|
|
else
|
|
|
|
index = sb->header_index; //-1
|
2019-01-19 20:03:48 +01:00
|
|
|
|
|
|
|
if (sb->type == UBI_SEQUENCE) {
|
2019-01-20 17:16:44 +01:00
|
|
|
if (sb->sequence_single) {
|
|
|
|
if (sb->sequence_count == 1)
|
|
|
|
res_name = "single";
|
|
|
|
else
|
|
|
|
res_name = "multi";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (sb->sequence_count == 1)
|
|
|
|
res_name = "single-loop";
|
|
|
|
else
|
|
|
|
res_name = (sb->sequence_loop == 0) ? "multi-loop" : "intro-loop";
|
|
|
|
}
|
2019-01-19 20:03:48 +01:00
|
|
|
}
|
|
|
|
else {
|
2019-01-26 16:30:36 +01:00
|
|
|
if (sb->is_external || sb->cfg.audio_has_internal_names)
|
2019-01-19 20:03:48 +01:00
|
|
|
res_name = sb->resource_name;
|
|
|
|
else
|
|
|
|
res_name = NULL;
|
|
|
|
}
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
/* maps can contain +10000 subsongs, we need something helpful
|
|
|
|
* (best done right after subsong detection, since some sequence re-parse types) */
|
2019-02-03 01:47:44 +01:00
|
|
|
if (res_name && res_name[0]) {
|
|
|
|
if (index >= 0)
|
|
|
|
snprintf(buf,buf_size, "%s/%04d/%02x-%08x/%s", grp_name, index, type, id, res_name);
|
|
|
|
else
|
|
|
|
snprintf(buf,buf_size, "%s/%02x-%08x/%s", grp_name, type, id, res_name);
|
2019-01-13 23:27:29 +01:00
|
|
|
}
|
|
|
|
else {
|
2019-02-03 01:47:44 +01:00
|
|
|
if (index >= 0)
|
|
|
|
snprintf(buf,buf_size, "%s/%04d/%02x-%08x", grp_name, index, type, id);
|
|
|
|
else
|
|
|
|
snprintf(buf,buf_size, "%s/%02x-%08x", grp_name, type, id);
|
2019-01-02 23:31:14 +01:00
|
|
|
}
|
2019-01-13 23:27:29 +01:00
|
|
|
}
|
2019-01-02 23:31:14 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
static int parse_type_audio(ubi_sb_header * sb, off_t offset, STREAMFILE* streamFile) {
|
2019-01-13 23:27:29 +01:00
|
|
|
int32_t (*read_32bit)(off_t,STREAMFILE*) = sb->big_endian ? read_32bitBE : read_32bitLE;
|
|
|
|
int16_t (*read_16bit)(off_t,STREAMFILE*) = sb->big_endian ? read_16bitBE : read_16bitLE;
|
2019-01-02 23:31:14 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* audio header */
|
|
|
|
sb->type = UBI_AUDIO;
|
2019-01-02 23:31:14 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->extra_offset = read_32bit(offset + sb->cfg.audio_extra_offset, streamFile) + sb->sectionX_offset;
|
|
|
|
sb->stream_size = read_32bit(offset + sb->cfg.audio_stream_size, streamFile);
|
|
|
|
sb->stream_offset = read_32bit(offset + sb->cfg.audio_stream_offset, streamFile);
|
|
|
|
sb->channels = (sb->cfg.audio_channels % 4) ? /* non-aligned offset is always 16b */
|
|
|
|
(uint16_t)read_16bit(offset + sb->cfg.audio_channels, streamFile) :
|
|
|
|
(uint32_t)read_32bit(offset + sb->cfg.audio_channels, streamFile);
|
|
|
|
sb->sample_rate = read_32bit(offset + sb->cfg.audio_sample_rate, streamFile);
|
|
|
|
sb->stream_type = read_32bit(offset + sb->cfg.audio_stream_type, streamFile);
|
2019-01-07 18:03:47 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
if (sb->stream_size == 0) {
|
|
|
|
VGM_LOG("UBI SB: bad stream size\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
if (sb->cfg.audio_external_flag) {
|
|
|
|
sb->is_external = (read_32bit(offset + sb->cfg.audio_external_flag, streamFile) & sb->cfg.audio_external_and);
|
2019-01-13 23:27:29 +01:00
|
|
|
}
|
2019-01-05 04:02:14 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
if (sb->cfg.audio_group_id) {
|
|
|
|
sb->group_id = read_32bit(offset + sb->cfg.audio_group_id, streamFile);
|
|
|
|
if (sb->cfg.audio_group_and) sb->group_id &= sb->cfg.audio_group_and;
|
2019-01-19 20:03:48 +01:00
|
|
|
|
|
|
|
/* normalize bitflag, known groups are only id 0/1 (if needed could calculate
|
2019-01-26 16:30:36 +01:00
|
|
|
* shift-right value here, based on cfg.audio_group_and first 1-bit) */
|
2019-01-19 20:03:48 +01:00
|
|
|
if (sb->group_id > 1)
|
|
|
|
sb->group_id = 1;
|
2019-01-13 23:27:29 +01:00
|
|
|
}
|
2019-01-05 04:02:14 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
if (sb->cfg.audio_loop_flag) {
|
|
|
|
sb->loop_flag = (read_32bit(offset + sb->cfg.audio_loop_flag, streamFile) & sb->cfg.audio_loop_and);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sb->loop_flag) {
|
|
|
|
sb->loop_start = read_32bit(offset + sb->cfg.audio_num_samples, streamFile);
|
|
|
|
sb->num_samples = read_32bit(offset + sb->cfg.audio_num_samples2, streamFile) + sb->loop_start;
|
|
|
|
|
|
|
|
if (sb->cfg.audio_num_samples == sb->cfg.audio_num_samples2) { /* early games just repeat and don't set loop start */
|
|
|
|
sb->num_samples = sb->loop_start;
|
|
|
|
sb->loop_start = 0;
|
|
|
|
}
|
|
|
|
/* Loop starts that aren't 0 do exist but are very rare (ex. Splinter Cell PC, Beowulf PSP sb 82, index 575).
|
|
|
|
* Also rare are looping external streams, since it's normally done through sequences (ex. Surf's Up).
|
|
|
|
* Loop end may be +1? (ex. Splinter Cell: Double Agent PS3 #14331). */
|
|
|
|
} else {
|
|
|
|
sb->num_samples = read_32bit(offset + sb->cfg.audio_num_samples, streamFile);
|
2019-01-19 20:03:48 +01:00
|
|
|
}
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
if (sb->cfg.resource_name_size > sizeof(sb->resource_name)) {
|
2019-01-19 20:03:48 +01:00
|
|
|
goto fail;
|
2019-01-13 23:27:29 +01:00
|
|
|
}
|
2019-01-07 18:03:47 +01:00
|
|
|
|
2019-01-13 23:27:29 +01:00
|
|
|
/* external stream name can be found in the header (first versions) or the sectionX table (later versions) */
|
2019-01-26 16:30:36 +01:00
|
|
|
if (sb->cfg.audio_stream_name) {
|
|
|
|
read_string(sb->resource_name, sb->cfg.resource_name_size, offset + sb->cfg.audio_stream_name, streamFile);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sb->cfg.audio_stream_name = read_32bit(offset + sb->cfg.audio_extra_name, streamFile);
|
|
|
|
if (sb->cfg.layer_stream_name != 0xFFFFFFFF)
|
|
|
|
read_string(sb->resource_name, sb->cfg.resource_name_size, sb->sectionX_offset + sb->cfg.audio_stream_name, streamFile);
|
2019-01-13 23:27:29 +01:00
|
|
|
}
|
2019-01-05 04:02:14 +01:00
|
|
|
|
2019-02-03 01:47:44 +01:00
|
|
|
/* points at XMA1 header in the extra section (only for RAW_XMA1, ignored garbage otherwise) */
|
2019-01-26 16:30:36 +01:00
|
|
|
if (sb->cfg.audio_xma_offset) {
|
|
|
|
sb->xma_header_offset = read_32bit(offset + sb->cfg.audio_xma_offset, streamFile) + sb->sectionX_offset;
|
2019-01-13 23:27:29 +01:00
|
|
|
}
|
2019-01-02 23:31:14 +01:00
|
|
|
|
2019-01-13 23:27:29 +01:00
|
|
|
return 1;
|
|
|
|
fail:
|
|
|
|
return 0;
|
|
|
|
}
|
2019-01-05 04:02:14 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
static int parse_type_sequence(ubi_sb_header * sb, off_t offset, STREAMFILE* streamFile) {
|
2019-01-13 23:27:29 +01:00
|
|
|
int32_t (*read_32bit)(off_t,STREAMFILE*) = sb->big_endian ? read_32bitBE : read_32bitLE;
|
2019-01-19 20:03:48 +01:00
|
|
|
off_t table_offset;
|
|
|
|
int i;
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* sequence chain */
|
|
|
|
sb->type = UBI_SEQUENCE;
|
2019-01-26 16:30:36 +01:00
|
|
|
if (sb->cfg.sequence_entry_size == 0) {
|
2019-01-19 20:03:48 +01:00
|
|
|
VGM_LOG("Ubi SB: sequence entry size not configured at %x\n", (uint32_t)offset);
|
|
|
|
goto fail;
|
|
|
|
}
|
2019-01-26 16:30:36 +01:00
|
|
|
|
|
|
|
sb->extra_offset = read_32bit(offset + sb->cfg.sequence_extra_offset, streamFile) + sb->sectionX_offset;
|
|
|
|
sb->sequence_loop = read_32bit(offset + sb->cfg.sequence_sequence_loop, streamFile);
|
|
|
|
sb->sequence_single = read_32bit(offset + sb->cfg.sequence_sequence_single, streamFile);
|
|
|
|
sb->sequence_count = read_32bit(offset + sb->cfg.sequence_sequence_count, streamFile);
|
|
|
|
|
2019-02-10 19:02:28 +01:00
|
|
|
if (sb->sequence_count > SB_MAX_CHAIN_COUNT) {
|
2019-01-19 20:03:48 +01:00
|
|
|
VGM_LOG("Ubi SB: incorrect layer count\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* get chain in extra table */
|
|
|
|
table_offset = sb->extra_offset;
|
|
|
|
for (i = 0; i < sb->sequence_count; i++) {
|
2019-01-26 16:30:36 +01:00
|
|
|
uint32_t entry_number = (uint32_t)read_32bit(table_offset+sb->cfg.sequence_entry_number, streamFile);
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
/* some sequences have an upper bit (2 bits in Donald Duck voices) for some reason */
|
|
|
|
//;VGM_ASSERT_ONCE(entry_number & 0xC0000000, "UBI SB: sequence bit entry found at %x\n", (uint32_t)sb->extra_offset);
|
2019-01-13 23:27:29 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
entry_number = entry_number & 0x3FFFFFFF;
|
2019-01-19 20:03:48 +01:00
|
|
|
if (entry_number > sb->section2_num) {
|
|
|
|
VGM_LOG("UBI SB: chain with wrong entry %i vs %i at %x\n", entry_number, sb->section2_num, (uint32_t)sb->extra_offset);
|
2019-01-13 23:27:29 +01:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
sb->sequence_chain[i] = entry_number;
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
table_offset += sb->cfg.sequence_entry_size;
|
2019-01-19 20:03:48 +01:00
|
|
|
}
|
2019-01-05 04:02:14 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
return 1;
|
|
|
|
fail:
|
|
|
|
return 0;
|
|
|
|
}
|
2019-01-07 18:03:47 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
static int parse_type_layer(ubi_sb_header * sb, off_t offset, STREAMFILE* streamFile) {
|
|
|
|
int32_t (*read_32bit)(off_t,STREAMFILE*) = sb->big_endian ? read_32bitBE : read_32bitLE;
|
|
|
|
int16_t (*read_16bit)(off_t,STREAMFILE*) = sb->big_endian ? read_16bitBE : read_16bitLE;
|
|
|
|
off_t table_offset;
|
|
|
|
int i;
|
2019-01-13 23:27:29 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* layer header */
|
|
|
|
sb->type = UBI_LAYER;
|
2019-01-26 16:30:36 +01:00
|
|
|
if (sb->cfg.layer_entry_size == 0) {
|
|
|
|
VGM_LOG("Ubi SB: layer entry size not configured at %x\n", (uint32_t)offset);
|
|
|
|
goto fail;
|
|
|
|
}
|
2019-01-07 22:10:48 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->extra_offset = read_32bit(offset + sb->cfg.layer_extra_offset, streamFile) + sb->sectionX_offset;
|
|
|
|
sb->layer_count = read_32bit(offset + sb->cfg.layer_layer_count, streamFile);
|
|
|
|
sb->stream_size = read_32bit(offset + sb->cfg.layer_stream_size, streamFile);
|
|
|
|
sb->stream_offset = read_32bit(offset + sb->cfg.layer_stream_offset, streamFile);
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
if (sb->stream_size == 0) {
|
|
|
|
VGM_LOG("UBI SB: bad stream size\n");
|
|
|
|
goto fail;
|
2019-01-02 23:31:14 +01:00
|
|
|
}
|
2019-01-05 04:02:14 +01:00
|
|
|
|
2019-02-10 19:02:28 +01:00
|
|
|
if (sb->layer_count > SB_MAX_LAYER_COUNT) {
|
2019-01-19 20:03:48 +01:00
|
|
|
VGM_LOG("Ubi SB: incorrect layer count\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
2019-01-02 23:31:14 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* get 1st layer header in extra table and validate all headers match */
|
|
|
|
table_offset = sb->extra_offset;
|
2019-02-22 23:52:09 +01:00
|
|
|
//sb->channels = (sb->cfg.layer_channels % 4) ? /* non-aligned offset is always 16b */
|
|
|
|
// (uint16_t)read_16bit(table_offset + sb->cfg.layer_channels, streamFile) :
|
|
|
|
// (uint32_t)read_32bit(table_offset + sb->cfg.layer_channels, streamFile);
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->sample_rate = read_32bit(table_offset + sb->cfg.layer_sample_rate, streamFile);
|
|
|
|
sb->stream_type = read_32bit(table_offset + sb->cfg.layer_stream_type, streamFile);
|
|
|
|
sb->num_samples = read_32bit(table_offset + sb->cfg.layer_num_samples, streamFile);
|
2019-01-19 20:03:48 +01:00
|
|
|
|
|
|
|
for (i = 0; i < sb->layer_count; i++) {
|
2019-02-22 23:52:09 +01:00
|
|
|
int channels = (sb->cfg.layer_channels % 4) ? /* non-aligned offset is always 16b */
|
|
|
|
(uint16_t)read_16bit(table_offset + sb->cfg.layer_channels, streamFile) :
|
|
|
|
(uint32_t)read_32bit(table_offset + sb->cfg.layer_channels, streamFile);
|
2019-01-26 16:30:36 +01:00
|
|
|
int sample_rate = read_32bit(table_offset + sb->cfg.layer_sample_rate, streamFile);
|
|
|
|
int stream_type = read_32bit(table_offset + sb->cfg.layer_stream_type, streamFile);
|
|
|
|
int num_samples = read_32bit(table_offset + sb->cfg.layer_num_samples, streamFile);
|
2019-02-17 20:53:30 +01:00
|
|
|
if (sb->sample_rate != sample_rate || sb->stream_type != stream_type) {
|
2019-01-26 16:30:36 +01:00
|
|
|
VGM_LOG("Ubi SB: %i layer headers don't match at %x\n", sb->layer_count, (uint32_t)table_offset);
|
|
|
|
|
|
|
|
if (sb->cfg.ignore_layer_error) {
|
2019-02-22 23:52:09 +01:00
|
|
|
continue;
|
2019-01-26 16:30:36 +01:00
|
|
|
}
|
|
|
|
|
2018-12-23 05:20:36 +01:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2019-02-22 23:52:09 +01:00
|
|
|
/* uncommonly channels may vary per layer [Brothers in Arms 2 (PS2) ex. MP_B01_NL.SB1] */
|
|
|
|
sb->layer_channels[i] = channels;
|
2019-02-17 20:53:30 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* can be +-1 */
|
|
|
|
if (sb->num_samples != num_samples && sb->num_samples + 1 == num_samples) {
|
|
|
|
sb->num_samples -= 1;
|
2018-12-23 05:20:36 +01:00
|
|
|
}
|
2019-01-07 18:03:47 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
table_offset += sb->cfg.layer_entry_size;
|
2017-11-05 17:06:40 +01:00
|
|
|
}
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* all layers seem external */
|
|
|
|
sb->is_external = 1;
|
|
|
|
|
|
|
|
/* external stream name can be found in the header (first versions) or the sectionX table (later versions) */
|
2019-01-26 16:30:36 +01:00
|
|
|
if (sb->cfg.layer_stream_name) {
|
|
|
|
read_string(sb->resource_name, sb->cfg.resource_name_size, offset + sb->cfg.layer_stream_name, streamFile);
|
2019-01-19 20:03:48 +01:00
|
|
|
} else {
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.layer_stream_name = read_32bit(offset + sb->cfg.layer_extra_name, streamFile);
|
|
|
|
if (sb->cfg.layer_stream_name != 0xFFFFFFFF)
|
|
|
|
read_string(sb->resource_name, sb->cfg.resource_name_size, sb->sectionX_offset + sb->cfg.layer_stream_name, streamFile);
|
2017-11-05 17:06:40 +01:00
|
|
|
}
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* layers seem to include XMA header */
|
2019-01-05 04:02:14 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
return 1;
|
|
|
|
fail:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
static int parse_type_silence(ubi_sb_header * sb, off_t offset, STREAMFILE* streamFile) {
|
|
|
|
int32_t (*read_32bit)(off_t,STREAMFILE*) = sb->big_endian ? read_32bitBE : read_32bitLE;
|
|
|
|
uint32_t duration_int;
|
|
|
|
float* duration_float;
|
|
|
|
|
|
|
|
/* silence header */
|
|
|
|
sb->type = UBI_SILENCE;
|
|
|
|
if (sb->cfg.silence_duration_int == 0 && sb->cfg.silence_duration_float == 0) {
|
|
|
|
VGM_LOG("Ubi SB: silence duration not configured at %x\n", (uint32_t)offset);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sb->cfg.silence_duration_int) {
|
|
|
|
duration_int = (uint32_t)read_32bit(offset + sb->cfg.silence_duration_int, streamFile);
|
|
|
|
sb->duration = (float)duration_int / 65536.0f; /* 65536.0 is common so probably means 1.0 */
|
|
|
|
}
|
|
|
|
else if (sb->cfg.silence_duration_float) {
|
|
|
|
duration_int = (uint32_t)read_32bit(offset + sb->cfg.silence_duration_float, streamFile);
|
|
|
|
duration_float = (float*)&duration_int;
|
|
|
|
sb->duration = *duration_float;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
fail:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* find actual codec from type (as different games' stream_type can overlap) */
|
|
|
|
static int parse_stream_codec(ubi_sb_header * sb) {
|
2019-01-19 20:03:48 +01:00
|
|
|
|
|
|
|
if (sb->type == UBI_SEQUENCE)
|
|
|
|
return 1;
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
/* happens randomly in internal sounds in early Xbox games */
|
2017-11-05 17:06:40 +01:00
|
|
|
if (sb->stream_type > 0xFF) {
|
2019-01-26 16:30:36 +01:00
|
|
|
//;VGM_LOG("UBI SB: garbage in stream_type\n");
|
|
|
|
sb->stream_type = 0; /* probably ignored for non-stream types */
|
2017-11-05 17:06:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* guess codec */
|
2018-12-17 12:01:00 +01:00
|
|
|
switch (sb->stream_type) {
|
2017-11-05 17:06:40 +01:00
|
|
|
case 0x00: /* platform default (rarely external) */
|
2018-12-17 08:05:45 +01:00
|
|
|
switch (sb->platform) {
|
|
|
|
case UBI_PC:
|
|
|
|
sb->codec = RAW_PCM;
|
|
|
|
break;
|
|
|
|
case UBI_PS2:
|
|
|
|
sb->codec = RAW_PSX;
|
|
|
|
break;
|
|
|
|
case UBI_PSP:
|
2019-01-19 20:03:48 +01:00
|
|
|
if (sb->is_psp_old)
|
2018-12-17 08:05:45 +01:00
|
|
|
sb->codec = FMT_VAG;
|
2019-01-19 20:03:48 +01:00
|
|
|
else
|
2018-12-17 08:05:45 +01:00
|
|
|
sb->codec = RAW_PSX;
|
|
|
|
break;
|
|
|
|
case UBI_XBOX:
|
|
|
|
sb->codec = RAW_XBOX;
|
|
|
|
break;
|
|
|
|
case UBI_GC:
|
|
|
|
case UBI_WII:
|
|
|
|
sb->codec = RAW_DSP;
|
|
|
|
break;
|
|
|
|
case UBI_X360:
|
|
|
|
sb->codec = RAW_XMA1;
|
|
|
|
break;
|
|
|
|
#if 0
|
2019-01-26 16:30:36 +01:00
|
|
|
case UBI_PS3: /* assumed, but no games seem to use it */
|
2018-12-21 15:17:10 +01:00
|
|
|
sb->codec = RAW_AT3;
|
2018-12-17 08:05:45 +01:00
|
|
|
break;
|
|
|
|
#endif
|
2019-01-07 18:03:47 +01:00
|
|
|
case UBI_3DS:
|
|
|
|
sb->codec = FMT_CWAV;
|
|
|
|
break;
|
2018-12-17 08:05:45 +01:00
|
|
|
default:
|
|
|
|
VGM_LOG("UBI SB: unknown internal format\n");
|
|
|
|
goto fail;
|
2017-11-05 17:06:40 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
case 0x01:
|
2019-01-07 22:10:48 +01:00
|
|
|
switch (sb->version) {
|
|
|
|
case 0x00000003: /* Donald Duck: Goin' Quackers */
|
2019-01-26 16:30:36 +01:00
|
|
|
case 0x00000004: /* Myst III: Exile */
|
|
|
|
case 0x00000007: /* Splinter Cell */
|
|
|
|
switch (sb->platform) {
|
|
|
|
case UBI_PS2: sb->codec = RAW_PSX; break;
|
|
|
|
case UBI_GC: sb->codec = RAW_DSP; break;
|
|
|
|
case UBI_PC: sb->codec = RAW_PCM; break;
|
|
|
|
case UBI_XBOX: sb->codec = RAW_XBOX; break;
|
|
|
|
default: VGM_LOG("UBI SB: unknown old internal format\n"); goto fail;
|
|
|
|
}
|
2019-01-07 22:10:48 +01:00
|
|
|
break;
|
|
|
|
default:
|
2019-01-19 20:03:48 +01:00
|
|
|
sb->codec = RAW_PCM; /* uncommon, ex. Wii/PSP/3DS */
|
2019-01-07 22:10:48 +01:00
|
|
|
break;
|
|
|
|
}
|
2017-11-11 17:46:18 +01:00
|
|
|
break;
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
case 0x02:
|
|
|
|
switch (sb->version) {
|
|
|
|
case 0x00000007: /* Splinter Cell, Splinter Cell: Pandora Tomorrow */
|
2019-02-03 01:47:44 +01:00
|
|
|
case 0x00120012: /* Myst IV: Exile */
|
|
|
|
//todo splinter Cell Essentials
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->codec = UBI_ADPCM;
|
2019-01-19 20:03:48 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sb->codec = RAW_PSX; /* PS3 */
|
|
|
|
break;
|
|
|
|
}
|
2018-12-17 08:05:45 +01:00
|
|
|
break;
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
case 0x03:
|
|
|
|
sb->codec = UBI_IMA; /* Ubi IMA v3+ (versions handled in decoder) */
|
2017-11-05 17:06:40 +01:00
|
|
|
break;
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
case 0x04:
|
2019-01-07 22:10:48 +01:00
|
|
|
switch (sb->version) {
|
2019-01-19 20:03:48 +01:00
|
|
|
case 0x00000007: /* Splinter Cell, Splinter Cell: Pandora Tomorrow */
|
|
|
|
sb->codec = UBI_IMA;
|
2019-01-07 22:10:48 +01:00
|
|
|
break;
|
|
|
|
default:
|
2019-01-19 20:03:48 +01:00
|
|
|
sb->codec = FMT_OGG; /* later PC games */
|
2019-01-07 22:10:48 +01:00
|
|
|
break;
|
|
|
|
}
|
2017-11-05 17:06:40 +01:00
|
|
|
break;
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
case 0x05:
|
2018-12-21 15:17:10 +01:00
|
|
|
switch (sb->platform) {
|
|
|
|
case UBI_X360:
|
|
|
|
sb->codec = FMT_XMA1;
|
|
|
|
break;
|
|
|
|
case UBI_PS3:
|
|
|
|
case UBI_PSP:
|
|
|
|
sb->codec = FMT_AT3;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
VGM_LOG("UBI SB: unknown codec for stream_type %x\n", sb->stream_type);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
case 0x06:
|
2019-01-26 16:30:36 +01:00
|
|
|
switch (sb->version) {
|
|
|
|
case 0x00000003: /* Batman: Vengeance (PC) */
|
|
|
|
sb->codec = UBI_ADPCM;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sb->codec = RAW_PSX; /* later PSP and PS3(?) games */
|
|
|
|
break;
|
|
|
|
}
|
2018-12-24 12:29:55 +01:00
|
|
|
break;
|
|
|
|
|
2018-12-21 15:17:10 +01:00
|
|
|
case 0x07:
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->codec = RAW_AT3; /* PS3 games */
|
2017-11-05 17:06:40 +01:00
|
|
|
break;
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
case 0x08:
|
2019-01-07 22:10:48 +01:00
|
|
|
switch (sb->version) {
|
|
|
|
case 0x00000003: /* Donald Duck: Goin' Quackers */
|
2019-01-13 23:27:29 +01:00
|
|
|
case 0x00000004: /* Myst III: Exile */
|
2019-01-19 20:03:48 +01:00
|
|
|
sb->codec = UBI_IMA; /* Ubi IMA v2/v3 */
|
2019-01-07 22:10:48 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sb->codec = FMT_AT3;
|
|
|
|
break;
|
|
|
|
}
|
2018-12-30 15:38:03 +01:00
|
|
|
break;
|
|
|
|
|
2017-11-05 17:06:40 +01:00
|
|
|
default:
|
|
|
|
VGM_LOG("UBI SB: unknown stream_type %x\n", sb->stream_type);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
return 1;
|
|
|
|
fail:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
/* find actual stream offset in section3 */
|
2019-02-10 19:02:28 +01:00
|
|
|
static int parse_offsets(ubi_sb_header * sb, STREAMFILE *streamFile) {
|
2019-01-19 20:03:48 +01:00
|
|
|
int32_t (*read_32bit)(off_t,STREAMFILE*) = sb->big_endian ? read_32bitBE : read_32bitLE;
|
|
|
|
int i, j, k;
|
|
|
|
|
|
|
|
if (sb->type == UBI_SEQUENCE)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
VGM_ASSERT(!sb->is_map && sb->section3_num > 2, "UBI SB: section3 > 2 found\n");
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
if (!(sb->cfg.audio_group_id || sb->is_map) && sb->section3_num > 1) {
|
2019-01-19 20:03:48 +01:00
|
|
|
VGM_LOG("UBI SB: unexpected number of internal stream groups %i\n", sb->section3_num);
|
|
|
|
goto fail;
|
2018-12-23 09:03:50 +01:00
|
|
|
}
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
if (sb->is_external)
|
|
|
|
return 1;
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* Internal sounds are split into codec groups, with their offsets being relative to group start.
|
|
|
|
* A table contains sizes of each group, so we adjust offsets based on the group ID of our sound.
|
|
|
|
* Headers normally only use 0 or 1, and section3 may only define id1 (which the internal sound would use).
|
|
|
|
* May exist even for external streams only, and they often use id 1 too. */
|
2019-01-07 22:10:48 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
if (sb->is_map) {
|
2019-01-26 11:31:50 +01:00
|
|
|
/* maps store internal sounds offsets in a separate subtable, find the matching entry
|
|
|
|
* each sec3 entry consists of the header and two tables
|
|
|
|
* 0x00: some ID? (always -1 for the first entry)
|
|
|
|
* 0x04: table 1 offset
|
|
|
|
* 0x08: table 1 entries
|
|
|
|
* 0x0c: table 2 offset
|
|
|
|
* 0x10: table 2 entries
|
|
|
|
* table 1 - for each entry:
|
|
|
|
* 0x00: sec2 entry index
|
|
|
|
* 0x04: sound offset
|
|
|
|
* table 2 - for each entry:
|
|
|
|
* 0x00 - group ID
|
|
|
|
* 0x04 - size with padding included
|
|
|
|
* 0x08 - size without padding
|
|
|
|
* 0x0c - absolute group offset */
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
for (i = 0; i < sb->section3_num; i++) {
|
|
|
|
off_t offset = sb->section3_offset + 0x14 * i;
|
|
|
|
off_t table_offset = read_32bit(offset + 0x04, streamFile) + sb->section3_offset;
|
|
|
|
uint32_t table_num = read_32bit(offset + 0x08, streamFile);
|
|
|
|
off_t table2_offset = read_32bit(offset + 0x0c, streamFile) + sb->section3_offset;
|
|
|
|
uint32_t table2_num = read_32bit(offset + 0x10, streamFile);
|
|
|
|
|
|
|
|
for (j = 0; j < table_num; j++) {
|
|
|
|
int index = read_32bit(table_offset + 0x08 * j + 0x00, streamFile) & 0x0000FFFF;
|
|
|
|
|
|
|
|
if (index == sb->header_index) {
|
2019-01-26 16:30:36 +01:00
|
|
|
if (!sb->cfg.audio_group_id && table2_num > 1) {
|
2019-01-19 20:03:48 +01:00
|
|
|
VGM_LOG("UBI SB: unexpected number of internal stream map groups %i at %x\n", table2_num, (uint32_t)table2_offset);
|
|
|
|
goto fail;
|
|
|
|
}
|
2018-12-21 15:17:10 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
sb->stream_offset = read_32bit(table_offset + 0x08 * j + 0x04, streamFile);
|
|
|
|
for (k = 0; k < table2_num; k++) {
|
|
|
|
uint32_t id = read_32bit(table2_offset + 0x10 * k + 0x00, streamFile);
|
2019-01-28 07:27:45 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
if (id == sb->group_id) {
|
|
|
|
sb->stream_offset += read_32bit(table2_offset + 0x10 * k + 0x0c, streamFile);
|
|
|
|
break;
|
2018-12-21 15:17:10 +01:00
|
|
|
}
|
|
|
|
}
|
2019-01-19 20:03:48 +01:00
|
|
|
break;
|
2018-12-21 15:17:10 +01:00
|
|
|
}
|
2019-01-19 20:03:48 +01:00
|
|
|
}
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
if (sb->stream_offset)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* banks store internal sounds after all headers and adjusted by the group table, find the matching entry */
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
off_t sounds_offset = sb->section3_offset + sb->cfg.section3_entry_size*sb->section3_num;
|
|
|
|
if (sb->cfg.is_padded_sounds_offset)
|
|
|
|
sounds_offset = align_size_to_block(sounds_offset, 0x10);
|
2019-01-19 20:03:48 +01:00
|
|
|
sb->stream_offset = sounds_offset + sb->stream_offset;
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
if (sb->cfg.audio_group_id && sb->section3_num > 1) { /* maybe should always test this? */
|
2019-01-19 20:03:48 +01:00
|
|
|
for (i = 0; i < sb->section3_num; i++) {
|
2019-01-26 16:30:36 +01:00
|
|
|
off_t offset = sb->section3_offset + sb->cfg.section3_entry_size * i;
|
2019-01-19 20:03:48 +01:00
|
|
|
|
|
|
|
/* table has unordered ids+size, so if our id doesn't match current data offset must be beyond */
|
|
|
|
if (read_32bit(offset + 0x00, streamFile) == sb->group_id)
|
2018-12-21 15:17:10 +01:00
|
|
|
break;
|
2019-01-19 20:03:48 +01:00
|
|
|
sb->stream_offset += read_32bit(offset + 0x04, streamFile);
|
2018-12-21 15:17:10 +01:00
|
|
|
}
|
2019-01-19 20:03:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
fail:
|
|
|
|
return 0;
|
|
|
|
}
|
2018-12-21 15:17:10 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
/* parse a single known header resource at offset (see config_sb for info) */
|
2019-01-19 20:03:48 +01:00
|
|
|
static int parse_header(ubi_sb_header * sb, STREAMFILE *streamFile, off_t offset, int index) {
|
|
|
|
int32_t (*read_32bit)(off_t,STREAMFILE*) = sb->big_endian ? read_32bitBE : read_32bitLE;
|
2019-01-07 22:10:48 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
sb->header_index = index;
|
|
|
|
sb->header_offset = offset;
|
2018-12-23 16:55:20 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
sb->header_id = read_32bit(offset + 0x00, streamFile);
|
|
|
|
sb->header_type = read_32bit(offset + 0x04, streamFile);
|
|
|
|
|
|
|
|
switch(sb->header_type) {
|
|
|
|
case 0x01:
|
|
|
|
if (!parse_type_audio(sb, offset, streamFile))
|
|
|
|
goto fail;
|
|
|
|
break;
|
|
|
|
case 0x05:
|
|
|
|
case 0x0c:
|
|
|
|
if (!parse_type_sequence(sb, offset, streamFile))
|
|
|
|
goto fail;
|
|
|
|
break;
|
|
|
|
case 0x06:
|
|
|
|
case 0x0d:
|
|
|
|
if (!parse_type_layer(sb, offset, streamFile))
|
|
|
|
goto fail;
|
|
|
|
break;
|
2019-01-26 16:30:36 +01:00
|
|
|
case 0x08:
|
|
|
|
case 0x0f:
|
|
|
|
if (!parse_type_silence(sb, offset, streamFile))
|
|
|
|
goto fail;
|
|
|
|
break;
|
2019-01-19 20:03:48 +01:00
|
|
|
default:
|
|
|
|
VGM_LOG("UBI SB: unknown header type at %x\n", (uint32_t)offset);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
if (!parse_stream_codec(sb))
|
2019-01-19 20:03:48 +01:00
|
|
|
goto fail;
|
|
|
|
|
2019-02-10 19:02:28 +01:00
|
|
|
if (!parse_offsets(sb, streamFile))
|
2019-01-19 20:03:48 +01:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
fail:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
/* parse a bank and its possible audio headers */
|
2019-02-10 19:02:28 +01:00
|
|
|
static int parse_sb(ubi_sb_header * sb, STREAMFILE *streamFile, int target_subsong) {
|
2019-01-19 20:03:48 +01:00
|
|
|
int32_t (*read_32bit)(off_t,STREAMFILE*) = sb->big_endian ? read_32bitBE : read_32bitLE;
|
|
|
|
int i;
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
//;VGM_LOG("UBI SB: s1=%x (%x*%x), s2=%x (%x*%x), sX=%x (%x), s3=%x (%x*%x)\n",
|
|
|
|
// sb->section1_offset,sb->cfg.section1_entry_size,sb->section1_num,sb->section2_offset,sb->cfg.section2_entry_size,sb->section2_num,
|
|
|
|
// sb->sectionX_offset,sb->sectionX_size,sb->section3_offset,sb->cfg.section3_entry_size,sb->section3_num);
|
2019-01-19 20:03:48 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
/* find target subsong info in section2 and keeps counting */
|
2019-01-19 20:03:48 +01:00
|
|
|
sb->bank_subsongs = 0;
|
|
|
|
for (i = 0; i < sb->section2_num; i++) {
|
2019-01-26 16:30:36 +01:00
|
|
|
off_t offset = sb->section2_offset + sb->cfg.section2_entry_size*i;
|
2019-01-19 20:03:48 +01:00
|
|
|
uint32_t header_type;
|
|
|
|
|
|
|
|
/*header_id =*/ read_32bit(offset + 0x00, streamFile); /* forces buffer read */
|
|
|
|
header_type = read_32bit(offset + 0x04, streamFile);
|
|
|
|
|
|
|
|
if (header_type <= 0x00 || header_type >= 0x10 || header_type == 0x09 || header_type == 0x0b) {
|
|
|
|
VGM_LOG("UBI SB: unknown type %x at %x\n", header_type, (uint32_t)offset);
|
|
|
|
goto fail;
|
2017-11-05 17:06:40 +01:00
|
|
|
}
|
2019-01-19 20:03:48 +01:00
|
|
|
|
|
|
|
sb->types[header_type]++;
|
|
|
|
if (!sb->allowed_types[header_type])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
sb->bank_subsongs++;
|
|
|
|
sb->total_subsongs++;
|
|
|
|
if (sb->total_subsongs != target_subsong)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!parse_header(sb, streamFile, offset, i))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
build_readable_name(sb->readable_name, sizeof(sb->readable_name), sb);
|
2017-11-05 17:06:40 +01:00
|
|
|
}
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
/* either found target subsong or it's in another bank (in case of maps), both handled externally */
|
2019-01-19 20:03:48 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
//;VGM_LOG("UBI SB: types "); {int i; for (i=0;i<16;i++){ VGM_ASSERT(sb->types[i],"%02x=%i ",i,sb->types[i]); }} VGM_LOG("\n");
|
2019-01-19 20:03:48 +01:00
|
|
|
|
2017-11-05 17:06:40 +01:00
|
|
|
return 1;
|
|
|
|
fail:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* ************************************************************************* */
|
|
|
|
|
2019-01-05 04:32:07 +01:00
|
|
|
static int config_sb_platform(ubi_sb_header * sb, STREAMFILE *streamFile) {
|
|
|
|
char filename[PATH_LIMIT];
|
|
|
|
int filename_len;
|
|
|
|
char platform_char;
|
|
|
|
uint32_t version;
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* to find out hijacking (LE) platforms */
|
2019-01-05 04:32:07 +01:00
|
|
|
version = read_32bitLE(0x00, streamFile);
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* get X from .sbX/smX/lmX */
|
2019-01-05 04:32:07 +01:00
|
|
|
get_streamfile_name(streamFile,filename,sizeof(filename));
|
|
|
|
filename_len = strlen(filename);
|
|
|
|
platform_char = filename[filename_len - 1];
|
|
|
|
|
|
|
|
switch(platform_char) {
|
|
|
|
case '0':
|
|
|
|
sb->platform = UBI_PC;
|
|
|
|
break;
|
|
|
|
case '1':
|
|
|
|
sb->platform = UBI_PS2;
|
|
|
|
break;
|
|
|
|
case '2':
|
|
|
|
sb->platform = UBI_XBOX;
|
|
|
|
break;
|
|
|
|
case '3':
|
|
|
|
sb->platform = UBI_GC;
|
|
|
|
break;
|
|
|
|
case '4':
|
|
|
|
switch(version) { /* early PSP clashes with X360 */
|
|
|
|
case 0x0012000C: /* multiple games use this ID and all are sb4/sm4 */
|
|
|
|
sb->platform = UBI_PSP;
|
2019-01-19 20:03:48 +01:00
|
|
|
sb->is_psp_old = 1;
|
2019-01-05 04:32:07 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sb->platform = UBI_X360;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '5':
|
|
|
|
switch(version) { /* 3DS could be sb8/sm8 but somehow hijacks extension */
|
|
|
|
case 0x00130001: /* Splinter Cell 3DS (2011) */
|
|
|
|
sb->platform = UBI_3DS;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sb->platform = UBI_PSP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '6':
|
|
|
|
sb->platform = UBI_PS3;
|
|
|
|
break;
|
|
|
|
case '7':
|
|
|
|
sb->platform = UBI_WII;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
sb->big_endian =
|
|
|
|
sb->platform == UBI_GC ||
|
|
|
|
sb->platform == UBI_PS3 ||
|
|
|
|
sb->platform == UBI_X360 ||
|
|
|
|
sb->platform == UBI_WII;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
fail:
|
|
|
|
return 0;
|
|
|
|
}
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
|
|
|
|
static void config_sb_entry(ubi_sb_header * sb, size_t section1_size_entry, size_t section2_size_entry) {
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.section1_entry_size = section1_size_entry;
|
|
|
|
sb->cfg.section2_entry_size = section2_size_entry;
|
|
|
|
sb->cfg.section3_entry_size = 0x08;
|
2019-01-13 23:27:29 +01:00
|
|
|
}
|
2019-01-19 20:03:48 +01:00
|
|
|
static void config_sb_audio_fs(ubi_sb_header * sb, off_t external_flag, off_t group_id, off_t loop_flag) {
|
|
|
|
/* audio header with standard flags */
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.audio_external_flag = external_flag;
|
|
|
|
sb->cfg.audio_group_id = group_id;
|
|
|
|
sb->cfg.audio_loop_flag = loop_flag;
|
|
|
|
sb->cfg.audio_external_and = 1;
|
|
|
|
sb->cfg.audio_group_and = 1;
|
|
|
|
sb->cfg.audio_loop_and = 1;
|
2019-01-19 20:03:48 +01:00
|
|
|
}
|
|
|
|
static void config_sb_audio_fb(ubi_sb_header * sb, off_t flag_bits, int external_and, int group_and, int loop_and) {
|
|
|
|
/* audio header with bit flags */
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.audio_external_flag = flag_bits;
|
|
|
|
sb->cfg.audio_group_id = flag_bits;
|
|
|
|
sb->cfg.audio_loop_flag = flag_bits;
|
|
|
|
sb->cfg.audio_external_and = external_and;
|
|
|
|
sb->cfg.audio_group_and = group_and;
|
|
|
|
sb->cfg.audio_loop_and = loop_and;
|
2019-01-19 20:03:48 +01:00
|
|
|
}
|
|
|
|
static void config_sb_audio_hs(ubi_sb_header * sb, off_t channels, off_t sample_rate, off_t num_samples, off_t num_samples2, off_t stream_name, off_t stream_type) {
|
|
|
|
/* audio header with stream name */
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.audio_channels = channels;
|
|
|
|
sb->cfg.audio_sample_rate = sample_rate;
|
|
|
|
sb->cfg.audio_num_samples = num_samples;
|
|
|
|
sb->cfg.audio_num_samples2 = num_samples2;
|
|
|
|
sb->cfg.audio_stream_name = stream_name;
|
|
|
|
sb->cfg.audio_stream_type = stream_type;
|
2019-01-19 20:03:48 +01:00
|
|
|
}
|
|
|
|
static void config_sb_audio_he(ubi_sb_header * sb, off_t channels, off_t sample_rate, off_t num_samples, off_t num_samples2, off_t extra_name, off_t stream_type) {
|
|
|
|
/* audio header with extra name */
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.audio_channels = channels;
|
|
|
|
sb->cfg.audio_sample_rate = sample_rate;
|
|
|
|
sb->cfg.audio_num_samples = num_samples;
|
|
|
|
sb->cfg.audio_num_samples2 = num_samples2;
|
|
|
|
sb->cfg.audio_extra_name = extra_name;
|
|
|
|
sb->cfg.audio_stream_type = stream_type;
|
2019-01-19 20:03:48 +01:00
|
|
|
}
|
|
|
|
static void config_sb_sequence(ubi_sb_header * sb, off_t sequence_count, off_t entry_size) {
|
|
|
|
/* sequence header and chain table */
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.sequence_sequence_loop = sequence_count - 0x10;
|
|
|
|
sb->cfg.sequence_sequence_single= sequence_count - 0x0c;
|
|
|
|
sb->cfg.sequence_sequence_count = sequence_count;
|
|
|
|
sb->cfg.sequence_entry_size = entry_size;
|
|
|
|
sb->cfg.sequence_entry_number = 0x00;
|
2019-01-19 20:03:48 +01:00
|
|
|
}
|
|
|
|
static void config_sb_layer_hs(ubi_sb_header * sb, off_t layer_count, off_t stream_size, off_t stream_offset, off_t stream_name) {
|
|
|
|
/* layer headers with stream name */
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.layer_layer_count = layer_count;
|
|
|
|
sb->cfg.layer_stream_size = stream_size;
|
|
|
|
sb->cfg.layer_stream_offset = stream_offset;
|
|
|
|
sb->cfg.layer_stream_name = stream_name;
|
2019-01-19 20:03:48 +01:00
|
|
|
}
|
|
|
|
static void config_sb_layer_he(ubi_sb_header * sb, off_t layer_count, off_t stream_size, off_t stream_offset, off_t extra_name) {
|
|
|
|
/* layer headers with extra name */
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.layer_layer_count = layer_count;
|
|
|
|
sb->cfg.layer_stream_size = stream_size;
|
|
|
|
sb->cfg.layer_stream_offset = stream_offset;
|
|
|
|
sb->cfg.layer_extra_name = extra_name;
|
2019-01-19 20:03:48 +01:00
|
|
|
}
|
|
|
|
static void config_sb_layer_sh(ubi_sb_header * sb, off_t entry_size, off_t sample_rate, off_t channels, off_t stream_type, off_t num_samples) {
|
|
|
|
/* layer sub-headers in extra table */
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.layer_entry_size = entry_size;
|
|
|
|
sb->cfg.layer_sample_rate = sample_rate;
|
|
|
|
sb->cfg.layer_channels = channels;
|
|
|
|
sb->cfg.layer_stream_type = stream_type;
|
|
|
|
sb->cfg.layer_num_samples = num_samples;
|
|
|
|
}
|
|
|
|
static void config_sb_silence_i(ubi_sb_header * sb, off_t duration) {
|
|
|
|
/* silence headers in int value */
|
|
|
|
sb->cfg.silence_duration_int = duration;
|
|
|
|
}
|
|
|
|
static void config_sb_silence_f(ubi_sb_header * sb, off_t duration) {
|
|
|
|
/* silence headers in float value */
|
|
|
|
sb->cfg.silence_duration_float = duration;
|
2019-01-19 20:03:48 +01:00
|
|
|
}
|
|
|
|
|
2019-01-05 04:02:14 +01:00
|
|
|
static int config_sb_version(ubi_sb_header * sb, STREAMFILE *streamFile) {
|
2019-01-26 16:30:36 +01:00
|
|
|
int is_bia_ps2 = 0, is_biadd_psp = 0;
|
|
|
|
int is_sc2_ps2_gc = 0;
|
2019-03-16 13:58:28 +01:00
|
|
|
int is_sc4_pc_online = 0;
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* Most of the format varies with almost every game + platform (struct serialization?).
|
|
|
|
* Support is configured case-by-case as offsets/order/fields only change slightly,
|
|
|
|
* and later games may remove fields. We only configure those actually needed.
|
|
|
|
*
|
|
|
|
* Various type use "chains" of entry numbers (defined in the extra table).
|
|
|
|
* Its format also depends on type.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Header types found in section2 (possibly called "resource headers"):
|
|
|
|
*
|
|
|
|
* Type 01 (old/new):
|
|
|
|
* Single audio header, external or internal, part of a chain or single. Format:
|
2019-01-07 18:03:47 +01:00
|
|
|
* - fixed part (id, type, stream size, extra offset, stream offset)
|
2019-01-19 20:03:48 +01:00
|
|
|
* - flags (as bitflags or in separate fields, around ~6 observed flags)
|
|
|
|
* - samples+samples (loop+total) + size+size (roughly equal to stream size)
|
|
|
|
* - bitrate (total sample rate)
|
|
|
|
* - base info (sample rate, pcm bits?, channels, codec)
|
2019-01-07 18:03:47 +01:00
|
|
|
* - external filename or internal filename on some platforms (earlier versions)
|
|
|
|
* - external filename offset in the extra table (later versions)
|
2019-01-19 20:03:48 +01:00
|
|
|
* - end flags?
|
2019-01-26 16:30:36 +01:00
|
|
|
* A few games (Splinter Cell, Rainbow Six) have wrong voice sample rates,
|
|
|
|
* maybe there is some pitch value too.
|
2019-01-19 20:03:48 +01:00
|
|
|
*
|
|
|
|
* Type 02 (old?/new):
|
|
|
|
* Chain, possibly to play with config (ex: type 08 (float 0.3) + 01)
|
|
|
|
*
|
|
|
|
* Type 03 (new), 09? (old):
|
|
|
|
* Chain, other way to play things? (ex: type 03 + 04)
|
|
|
|
*
|
2019-01-26 16:30:36 +01:00
|
|
|
* Type 04 (old?/new), 0a (old):
|
|
|
|
* Table of N types + chance % (sums to 65536), to play one as random. Usually N
|
|
|
|
* voice/sfx variations like death screams, or sequence alts.
|
2019-01-19 20:03:48 +01:00
|
|
|
*
|
|
|
|
* Type 05 (new), 0c (old): sequences
|
|
|
|
* N audio segment, normally with lead-in but not lead-outs. Sequences can reuse
|
|
|
|
* segments (internal loops), or can be single entries (full song or leads).
|
|
|
|
* Sequences seem to include only music or cutscenes, so even single entries can be
|
|
|
|
* useful to parse, since the readable name would make them stand out. Format:
|
|
|
|
* - extra offset to chain
|
2019-01-26 16:30:36 +01:00
|
|
|
* - loop segment
|
|
|
|
* - non-looping flag
|
2019-01-19 20:03:48 +01:00
|
|
|
* - sequence count
|
|
|
|
* - ID-like fields in the header and sequence table may point to other chains?
|
|
|
|
*
|
|
|
|
* Type 06 (new), 0d (old):
|
|
|
|
* Layer header, stream divided into N equal parts in a blocked format. Format:
|
|
|
|
* - fixed part (id, type)
|
|
|
|
* - extra offset to layer info (sample rate, pcm bits?, channels, codec, samples)
|
|
|
|
* - layer count
|
|
|
|
* - sometimes total channels, bitrate, etc
|
|
|
|
* - flags?
|
|
|
|
* - stream size + stream offset
|
|
|
|
* - external filename, or filename offset in the extra table
|
|
|
|
* Layer blocks are handled separatedly as the format doesn't depend on sb's version/platform.
|
|
|
|
* Some values may be flags/config as multiple 0x06 can point to the same layer, with different 'flags'?
|
2019-01-07 18:03:47 +01:00
|
|
|
*
|
2019-01-19 20:03:48 +01:00
|
|
|
* Type 07 (new), 0e (old):
|
2019-01-26 16:30:36 +01:00
|
|
|
* Another chain of something (single entry?), rare.
|
2019-01-07 18:03:47 +01:00
|
|
|
*
|
2019-01-19 20:03:48 +01:00
|
|
|
* Type 08 (new), 0f (old):
|
2019-01-26 16:30:36 +01:00
|
|
|
* Silence, with a value representing duration (no sample rate/channels/extra table/etc given).
|
|
|
|
* Typically used in chains to extend play time of another audio.
|
|
|
|
* For older games 08 is used for something else (maybe equivalent to 02?)
|
2017-11-05 17:06:40 +01:00
|
|
|
*/
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* debug strings reference:
|
|
|
|
* - TYPE_SAMPLE: should be 0x01 (also "sound resource")
|
|
|
|
* - TYPE_MULTITRACK: should be 0x06/0x0d (also "multilayer resource")
|
2019-01-26 16:30:36 +01:00
|
|
|
* - TYPE_SILENCE: should be 0x08
|
2019-01-19 20:03:48 +01:00
|
|
|
* sequences may be "theme resource"
|
2019-01-26 16:30:36 +01:00
|
|
|
* "class descryptor" is referenced too.
|
2019-01-19 20:03:48 +01:00
|
|
|
*
|
|
|
|
* Possible type names from .bnm (.sb's predecessor):
|
|
|
|
* 0: TYPE_INVALID
|
|
|
|
* 1: TYPE_SAMPLE
|
|
|
|
* 2: TYPE_MIDI
|
|
|
|
* 3: TYPE_CDAUDIO
|
|
|
|
* 4: TYPE_SEQUENCE
|
|
|
|
* 5: TYPE_SWITCH_OLD
|
|
|
|
* 6: TYPE_SPLIT
|
|
|
|
* 7: TYPE_THEME_OLD
|
|
|
|
* 8: TYPE_SWITCH
|
|
|
|
* 9: TYPE_THEME_OLD2
|
|
|
|
* A: TYPE_RANDOM
|
|
|
|
* B: TYPE_THEME0
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* All types may contain memory garbage, making it harder to identify fields (platforms
|
|
|
|
* and games are affected differently by this). Often types contain memory from the previous
|
|
|
|
* type header unless overwritten, random memory, or default initialization garbage.
|
|
|
|
* So if some non-audio type looks like audio it's probably repeating old data.
|
|
|
|
* This even happens for common fields (ex. type 6 at 0x08 has prev garbage, not stream size). */
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
/* games <= 0x00100000 seem to use old types, rest new types */
|
|
|
|
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-02-17 20:53:30 +01:00
|
|
|
/* maybe 0x20/0x24 for some but ok enough (null terminated) */
|
|
|
|
sb->cfg.resource_name_size = 0x28; /* min for Brother in Arms 2 (PS2) */
|
2019-01-05 04:02:14 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* represents map style (1=first, 2=mid, 3=latest) */
|
|
|
|
if (sb->version <= 0x00000007)
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.map_version = 1;
|
2019-01-19 20:03:48 +01:00
|
|
|
else if (sb->version < 0x00150000)
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.map_version = 2;
|
2019-01-19 20:03:48 +01:00
|
|
|
else
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.map_version = 3;
|
2019-01-07 18:03:47 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.map_entry_size = (sb->cfg.map_version < 2) ? 0x30 : 0x34;
|
2019-01-05 04:02:14 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
if (sb->version <= 0x00000007) {
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.audio_stream_size = 0x0c;
|
|
|
|
sb->cfg.audio_extra_offset = 0x10;
|
|
|
|
sb->cfg.audio_stream_offset = 0x14;
|
2018-12-26 15:09:35 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.sequence_extra_offset = 0x10;
|
2019-01-19 20:03:48 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.layer_extra_offset = 0x10;
|
2019-01-19 20:03:48 +01:00
|
|
|
}
|
|
|
|
else {
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.audio_stream_size = 0x08;
|
|
|
|
sb->cfg.audio_extra_offset = 0x0c;
|
|
|
|
sb->cfg.audio_stream_offset = 0x10;
|
2019-01-19 20:03:48 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.sequence_extra_offset = 0x0c;
|
2019-01-19 20:03:48 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.layer_extra_offset = 0x0c;
|
2019-01-19 20:03:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sb->allowed_types[0x01] = 1;
|
|
|
|
sb->allowed_types[0x05] = 1;
|
|
|
|
sb->allowed_types[0x0c] = 1;
|
|
|
|
sb->allowed_types[0x06] = 1;
|
|
|
|
sb->allowed_types[0x0d] = 1;
|
2019-01-26 16:30:36 +01:00
|
|
|
//sb->allowed_types[0x08] = 1; /* only needed inside sequences */
|
|
|
|
//sb->allowed_types[0x0f] = 1;
|
2019-01-19 20:03:48 +01:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
{
|
|
|
|
STREAMFILE * streamTest;
|
|
|
|
streamTest= open_streamfile_by_filename(streamFile, ".no_audio.sbx");
|
|
|
|
if (streamTest) { sb->allowed_types[0x01] = 0; close_streamfile(streamTest); }
|
|
|
|
|
|
|
|
streamTest= open_streamfile_by_filename(streamFile, ".no_sequence.sbx");
|
|
|
|
if (streamTest) { sb->allowed_types[0x05] = sb->allowed_types[0x0c] = 0; close_streamfile(streamTest); }
|
|
|
|
|
|
|
|
streamTest= open_streamfile_by_filename(streamFile, ".no_layer.sbx");
|
|
|
|
if (streamTest) { sb->allowed_types[0x06] = sb->allowed_types[0x0d] = 0; close_streamfile(streamTest); }
|
|
|
|
}
|
|
|
|
#endif
|
2019-01-07 22:10:48 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
/* Batman: Vengeance (2001)(PC)-map */
|
|
|
|
if (sb->version == 0x00000003 && sb->platform == UBI_PC) {
|
|
|
|
config_sb_entry(sb, 0x40, 0x68);
|
|
|
|
|
|
|
|
config_sb_audio_fs(sb, 0x30, 0x30, 0x34); /* no group id? use external flag */
|
|
|
|
config_sb_audio_hs(sb, 0x52, 0x4c, 0x38, 0x40, 0x58, 0x54);
|
|
|
|
sb->cfg.audio_has_internal_names = 1;
|
|
|
|
|
|
|
|
config_sb_sequence(sb, 0x2c, 0x1c);
|
|
|
|
|
|
|
|
config_sb_layer_hs(sb, 0x20, 0x4c, 0x44, 0x34);
|
|
|
|
config_sb_layer_sh(sb, 0x1c, 0x04, 0x0a, 0x0c, 0x18);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-07 22:10:48 +01:00
|
|
|
/* Disney's Tarzan: Untamed (2001)(GC)-map */
|
|
|
|
/* Batman: Vengeance (2001)(GC)-map */
|
2018-12-26 15:09:35 +01:00
|
|
|
/* Donald Duck: Goin' Quackers (2002)(GC)-map */
|
|
|
|
if (sb->version == 0x00000003 && sb->platform == UBI_GC) {
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_entry(sb, 0x40, 0x6c);
|
2018-12-26 15:09:35 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
config_sb_audio_fs(sb, 0x30, 0x30, 0x34); /* no group id? use external flag */
|
|
|
|
config_sb_audio_hs(sb, 0x56, 0x50, 0x48, 0x48, 0x5c, 0x58); /* 0x38 may be num samples too? */
|
2018-12-26 15:09:35 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_sequence(sb, 0x2c, 0x1c);
|
2019-01-13 23:27:29 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_layer_hs(sb, 0x20, 0x4c, 0x44, 0x34);
|
|
|
|
config_sb_layer_sh(sb, 0x1c, 0x04, 0x0a, 0x0c, 0x18);
|
2018-12-26 15:09:35 +01:00
|
|
|
return 1;
|
|
|
|
}
|
2019-01-19 20:03:48 +01:00
|
|
|
|
2019-01-13 23:27:29 +01:00
|
|
|
#if 0
|
2019-01-26 16:30:36 +01:00
|
|
|
//todo too weird
|
2019-01-13 23:27:29 +01:00
|
|
|
/* Batman: Vengeance (2001)(PS2)-map */
|
2019-01-19 20:03:48 +01:00
|
|
|
/* Disney's Tarzan: Untamed (2001)(PS2)-map */
|
2019-01-13 23:27:29 +01:00
|
|
|
if (sb->version == 0x00000003 && sb->platform == UBI_PS2) {
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_entry(sb, 0x30, 0x3c);
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
config_sb_audio_fb(sb, 0x1c, (1 << 2), (1 << 3), (1 << 4)); /* not ok */
|
|
|
|
config_sb_audio_hs(sb, 0x00, 0x24, 0x28, 0x28, 0x00, 0x00);
|
|
|
|
/* channels: 0? maybe 2=external, 1=internal? */
|
|
|
|
/* stream type: always PS-ADPCM (interleave unknown) */
|
|
|
|
/* sb->cfg.audio_stream_string = "STRM.SM1"; */ /* fixed */
|
2019-01-19 20:03:48 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
config_sb_sequence(sb, 0x2c, 0x10); /* this is normal enough */
|
2019-01-19 20:03:48 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
/* layers have a weird format too */
|
2019-01-13 23:27:29 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
//todo group flags and maybe num_samples for sfx are off
|
2019-01-13 23:27:29 +01:00
|
|
|
/* Myst III: Exile (2001)(PS2)-map */
|
|
|
|
if (sb->version == 0x00000004 && sb->platform == UBI_PS2) {
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_entry(sb, 0x34, 0x70);
|
2019-01-13 23:27:29 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
config_sb_audio_fb(sb, 0x1c, (1 << 3), (1 << 6), (1 << 4)); //???
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_audio_hs(sb, 0x24, 0x28, 0x2c, 0x34, 0x44, 0x6c);
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.audio_external_flag = 0x6c; /* no external flag? use codec as flag */
|
2019-01-13 23:27:29 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
config_sb_sequence(sb, 0x2c, 0x24);
|
2019-01-13 23:27:29 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-12-22 22:47:24 +01:00
|
|
|
/* Splinter Cell (2002)(PC)-map */
|
2018-12-24 13:48:15 +01:00
|
|
|
/* Splinter Cell: Pandora Tomorrow (2004)(PC)-map */
|
2018-12-21 15:17:10 +01:00
|
|
|
if (sb->version == 0x00000007 && sb->platform == UBI_PC) {
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_entry(sb, 0x58, 0x80);
|
2018-12-21 15:17:10 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
config_sb_audio_fs(sb, 0x28, 0x28, 0x2c); /* no group id? use external flag */
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_audio_hs(sb, 0x4a, 0x44, 0x30, 0x38, 0x50, 0x4c);
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.audio_has_internal_names = 1;
|
2018-12-26 15:09:35 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
config_sb_sequence(sb, 0x2c, 0x34);
|
2018-12-26 15:09:35 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
config_sb_layer_hs(sb, 0x24, 0x64, 0x5c, 0x34);
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_layer_sh(sb, 0x18, 0x00, 0x06, 0x08, 0x14);
|
2018-12-21 15:17:10 +01:00
|
|
|
return 1;
|
|
|
|
}
|
2019-01-19 20:03:48 +01:00
|
|
|
|
2019-01-07 22:10:48 +01:00
|
|
|
/* Splinter Cell (2002)(Xbox)-map */
|
2019-01-13 23:27:29 +01:00
|
|
|
/* Splinter Cell: Pandora Tomorrow (2004)(Xbox)-map */
|
2019-01-07 22:10:48 +01:00
|
|
|
if (sb->version == 0x00000007 && sb->platform == UBI_XBOX) {
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_entry(sb, 0x58, 0x78);
|
2018-12-21 15:17:10 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
config_sb_audio_fs(sb, 0x28, 0x28, 0x2c); /* no group id? use external flag */
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_audio_hs(sb, 0x4a, 0x44, 0x30, 0x38, 0x50, 0x4c);
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.audio_has_internal_names = 1;
|
2019-01-07 22:10:48 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
config_sb_sequence(sb, 0x2c, 0x34);
|
2019-01-07 22:10:48 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
config_sb_layer_hs(sb, 0x24, 0x64, 0x5c, 0x34);
|
|
|
|
config_sb_layer_sh(sb, 0x18, 0x00, 0x06, 0x08, 0x14);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* SC:PT PS2/GC has some quirks, noooo (lame autodetection but this stuff is too hard) */
|
|
|
|
if ((sb->version == 0x00000007 && sb->platform == UBI_PS2) ||
|
|
|
|
(sb->version == 0x00000007 && sb->platform == UBI_GC) ) {
|
|
|
|
int32_t (*read_32bit)(off_t,STREAMFILE*) = sb->big_endian ? read_32bitBE : read_32bitLE;
|
|
|
|
|
|
|
|
/* both SC:PT's LMx and SMx have 33 maps, SC1 doesn't */
|
|
|
|
is_sc2_ps2_gc = read_32bit(0x08, streamFile) == 0x21;
|
|
|
|
|
|
|
|
/* could also load ECHELON.SP1/Echelon.SP3 and test BE 0x04 == 0x00ACBF77,
|
|
|
|
* but it's worse for localization subdirs without it */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Splinter Cell (2002)(PS2)-map */
|
2019-02-03 01:47:44 +01:00
|
|
|
/* Splinter Cell: Pandora Tomorrow (2006)(PS2)-map 0x00000007 */
|
2019-01-26 16:30:36 +01:00
|
|
|
if (sb->version == 0x00000007 && sb->platform == UBI_PS2) {
|
|
|
|
config_sb_entry(sb, 0x40, 0x70);
|
|
|
|
|
|
|
|
config_sb_audio_fb(sb, 0x1c, (1 << 2), (1 << 3), (1 << 4));
|
|
|
|
config_sb_audio_hs(sb, 0x24, 0x28, 0x34, 0x3c, 0x44, 0x6c); /* num_samples may be null */
|
|
|
|
|
|
|
|
config_sb_sequence(sb, 0x2c, 0x30);
|
|
|
|
|
|
|
|
config_sb_layer_hs(sb, 0x24, 0x64, 0x5c, 0x34);
|
|
|
|
config_sb_layer_sh(sb, 0x18, 0x00, 0x06, 0x08, 0x14);
|
|
|
|
|
|
|
|
if (is_sc2_ps2_gc) {
|
|
|
|
sb->cfg.map_entry_size = 0x38;
|
|
|
|
/* some amb .ss2 have bad sizes with mixed random data, bad extraction/unused crap? */
|
2019-02-03 01:47:44 +01:00
|
|
|
/* Pandora Tomorrow voices have bad offsets too */
|
2019-01-26 16:30:36 +01:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Splinter Cell (2002)(GC)-map */
|
|
|
|
/* Splinter Cell: Pandora Tomorrow (2004)(GC)-map */
|
|
|
|
if (sb->version == 0x00000007 && sb->platform == UBI_GC) {
|
|
|
|
config_sb_entry(sb, 0x58, 0x78);
|
|
|
|
|
|
|
|
config_sb_audio_fs(sb, 0x24, 0x24, 0x28); /* no group id? use external flag */
|
|
|
|
config_sb_audio_hs(sb, 0x4a, 0x44, 0x2c, 0x34, 0x50, 0x4c);
|
|
|
|
|
|
|
|
config_sb_sequence(sb, 0x2c, 0x34);
|
|
|
|
|
|
|
|
config_sb_layer_hs(sb, 0x24, 0x64, 0x5c, 0x34);
|
|
|
|
config_sb_layer_sh(sb, 0x18, 0x00, 0x06, 0x08, 0x14);
|
|
|
|
|
|
|
|
if (is_sc2_ps2_gc) {
|
|
|
|
sb->cfg.map_entry_size = 0x38;
|
|
|
|
sb->cfg.audio_external_and = 0x01000000; /* did somebody forget about BE? */
|
|
|
|
}
|
2019-01-07 22:10:48 +01:00
|
|
|
return 1;
|
|
|
|
}
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* Prince of Persia: Sands of Time (2003)(PC)-bank 0x000A0004 / 0x000A0002 (just in case) */
|
|
|
|
if ((sb->version == 0x000A0002 && sb->platform == UBI_PC) ||
|
|
|
|
(sb->version == 0x000A0004 && sb->platform == UBI_PC)) {
|
|
|
|
config_sb_entry(sb, 0x64, 0x80);
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_audio_fs(sb, 0x24, 0x2c, 0x28);
|
|
|
|
config_sb_audio_hs(sb, 0x4a, 0x44, 0x30, 0x38, 0x50, 0x4c);
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.audio_has_internal_names = 1;
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_sequence(sb, 0x28, 0x14);
|
2019-01-13 23:27:29 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_layer_hs(sb, 0x20, 0x60, 0x58, 0x30);
|
|
|
|
config_sb_layer_sh(sb, 0x14, 0x00, 0x06, 0x08, 0x10);
|
2017-11-05 17:06:40 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
/* two configs with same id; use project file as identifier */
|
|
|
|
if (sb->version == 0x000A0007 && sb->platform == UBI_PS2) {
|
|
|
|
STREAMFILE * streamTest = open_streamfile_by_filename(streamFile, "BIAAUDIO.SP1");
|
|
|
|
if (streamTest) {
|
|
|
|
is_bia_ps2 = 1;
|
|
|
|
close_streamfile(streamTest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-28 07:47:24 +01:00
|
|
|
/* Prince of Persia: The Sands of Time (2003)(PS2)-bank 0x000A0004 / 0x000A0002 (POP1 port) */
|
2019-01-19 20:03:48 +01:00
|
|
|
/* Tom Clancy's Rainbow Six 3 (2003)(PS2)-bank 0x000A0007 */
|
2019-01-26 16:30:36 +01:00
|
|
|
/* Tom Clancy's Ghost Recon 2 (2004)(PS2)-bank 0x000A0007 */
|
2019-02-03 01:47:44 +01:00
|
|
|
/* Splinter Cell: Pandora Tomorrow (2006)(PS2)-bank 0x000A0008 (separate banks from main map) */
|
2019-01-19 20:03:48 +01:00
|
|
|
/* Prince of Persia: Warrior Within (2004)(PS2)-bank 0x00120009 */
|
|
|
|
if ((sb->version == 0x000A0002 && sb->platform == UBI_PS2) ||
|
|
|
|
(sb->version == 0x000A0004 && sb->platform == UBI_PS2) ||
|
2019-01-26 16:30:36 +01:00
|
|
|
(sb->version == 0x000A0007 && sb->platform == UBI_PS2 && !is_bia_ps2) ||
|
2019-01-19 20:03:48 +01:00
|
|
|
(sb->version == 0x000A0008 && sb->platform == UBI_PS2) ||
|
|
|
|
(sb->version == 0x00120009 && sb->platform == UBI_PS2)) {
|
|
|
|
config_sb_entry(sb, 0x48, 0x6c);
|
2019-01-05 04:02:14 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_audio_fb(sb, 0x18, (1 << 2), (1 << 3), (1 << 4));
|
|
|
|
config_sb_audio_hs(sb, 0x20, 0x24, 0x30, 0x38, 0x40, 0x68); /* num_samples may be null */
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_sequence(sb, 0x28, 0x10);
|
2019-01-13 23:27:29 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_layer_hs(sb, 0x20, 0x60, 0x58, 0x30);
|
|
|
|
config_sb_layer_sh(sb, 0x14, 0x00, 0x06, 0x08, 0x10);
|
2019-02-03 01:47:44 +01:00
|
|
|
|
|
|
|
config_sb_silence_i(sb, 0x18);
|
|
|
|
|
2019-01-05 04:02:14 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
/* Brothers in Arms: Road to Hill 30 (2005)[PS2] */
|
|
|
|
/* Brothers in Arms: Earned in Blood (2005)[PS2] */
|
|
|
|
if (sb->version == 0x000A0007 && sb->platform == UBI_PS2 && is_bia_ps2) {
|
|
|
|
config_sb_entry(sb, 0x5c, 0x14c);
|
|
|
|
|
|
|
|
config_sb_audio_fb(sb, 0x18, (1 << 2), (1 << 3), (1 << 4));
|
|
|
|
config_sb_audio_hs(sb, 0x20, 0x24, 0x30, 0x38, 0x40, 0x148); /* num_samples may be null */
|
|
|
|
|
|
|
|
config_sb_sequence(sb, 0x28, 0x10);
|
|
|
|
|
|
|
|
config_sb_layer_hs(sb, 0x20, 0x140, 0x138, 0x30);
|
|
|
|
config_sb_layer_sh(sb, 0x14, 0x00, 0x06, 0x08, 0x10);
|
|
|
|
|
|
|
|
sb->cfg.is_padded_section1_offset = 1;
|
|
|
|
sb->cfg.is_padded_section2_offset = 1;
|
|
|
|
sb->cfg.is_padded_section3_offset = 1;
|
|
|
|
sb->cfg.is_padded_sectionX_offset = 1;
|
|
|
|
sb->cfg.is_padded_sounds_offset = 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-28 07:47:24 +01:00
|
|
|
/* Prince of Persia: The Sands of Time (2003)(Xbox)-bank 0x000A0004 / 0x000A0002 (POP1 port) */
|
2019-01-19 20:03:48 +01:00
|
|
|
if ((sb->version == 0x000A0002 && sb->platform == UBI_XBOX) ||
|
|
|
|
(sb->version == 0x000A0004 && sb->platform == UBI_XBOX)) {
|
|
|
|
config_sb_entry(sb, 0x64, 0x78);
|
2019-01-05 04:02:14 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_audio_fs(sb, 0x24, 0x28, 0x2c);
|
|
|
|
config_sb_audio_hs(sb, 0x4a, 0x44, 0x30, 0x38, 0x50, 0x4c); /* stream_type may contain garbage */
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.audio_has_internal_names = 1;
|
2019-01-05 04:02:14 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_sequence(sb, 0x28, 0x14);
|
2019-01-13 23:27:29 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_layer_hs(sb, 0x20, 0x60, 0x58, 0x30);
|
|
|
|
config_sb_layer_sh(sb, 0x14, 0x00, 0x06, 0x08, 0x10);
|
2017-11-05 17:06:40 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* Batman: Rise of Sin Tzu (2003)(GC)-map 0x000A0002 */
|
2019-01-28 07:47:24 +01:00
|
|
|
/* Prince of Persia: The Sands of Time (2003)(GC)-bank 0x000A0004 / 0x000A0002 (POP1 port) */
|
2019-01-26 16:30:36 +01:00
|
|
|
/* Tom Clancy's Rainbow Six 3 (2003)(Xbox)-bank 0x000A0007 */
|
2019-01-19 20:03:48 +01:00
|
|
|
if ((sb->version == 0x000A0002 && sb->platform == UBI_GC) ||
|
2019-01-26 16:30:36 +01:00
|
|
|
(sb->version == 0x000A0004 && sb->platform == UBI_GC) ||
|
|
|
|
(sb->version == 0x000A0007 && sb->platform == UBI_GC)) {
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_entry(sb, 0x64, 0x74);
|
|
|
|
|
|
|
|
config_sb_audio_fs(sb, 0x20, 0x24, 0x28);
|
|
|
|
config_sb_audio_hs(sb, 0x46, 0x40, 0x2c, 0x34, 0x4c, 0x48);
|
|
|
|
|
|
|
|
config_sb_sequence(sb, 0x28, 0x14);
|
|
|
|
|
|
|
|
config_sb_layer_hs(sb, 0x20, 0x60, 0x58, 0x30);
|
|
|
|
config_sb_layer_sh(sb, 0x14, 0x00, 0x06, 0x08, 0x10);
|
2019-01-26 16:30:36 +01:00
|
|
|
|
|
|
|
config_sb_silence_i(sb, 0x18);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Tom Clancy's Rainbow Six 3 (2003)(Xbox)-bank 0x000A0007 */
|
|
|
|
if (sb->version == 0x000A0007 && sb->platform == UBI_XBOX) {
|
|
|
|
config_sb_entry(sb, 0x64, 0x8c);
|
|
|
|
|
|
|
|
config_sb_audio_fs(sb, 0x24, 0x28, 0x40);
|
|
|
|
config_sb_audio_hs(sb, 0x5e, 0x58, 0x44, 0x4c, 0x64, 0x60); /* stream_type may contain garbage */
|
|
|
|
sb->cfg.audio_has_internal_names = 1;
|
|
|
|
|
|
|
|
config_sb_sequence(sb, 0x28, 0x14);
|
|
|
|
|
|
|
|
config_sb_layer_hs(sb, 0x20, 0x60, 0x58, 0x30);
|
|
|
|
config_sb_layer_sh(sb, 0x14, 0x00, 0x06, 0x08, 0x10);
|
|
|
|
|
|
|
|
config_sb_silence_i(sb, 0x18);
|
2019-01-07 18:03:47 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-05 04:02:14 +01:00
|
|
|
/* Myst IV Demo (2004)(PC)-bank */
|
2019-01-13 23:27:29 +01:00
|
|
|
if (sb->version == 0x00100000 && sb->platform == UBI_PC) {
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_entry(sb, 0x68, 0xa4);
|
|
|
|
|
|
|
|
config_sb_audio_fs(sb, 0x24, 0x2c, 0x28);
|
|
|
|
config_sb_audio_hs(sb, 0x4c, 0x44, 0x30, 0x38, 0x54, 0x50);
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.audio_has_internal_names = 1;
|
2017-12-03 20:25:50 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-12-22 22:47:24 +01:00
|
|
|
/* Prince of Persia: Warrior Within (2004)(PC)-bank */
|
2018-12-17 08:05:45 +01:00
|
|
|
if (sb->version == 0x00120009 && sb->platform == UBI_PC) {
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_entry(sb, 0x6c, 0x84);
|
|
|
|
|
|
|
|
config_sb_audio_fs(sb, 0x24, 0x2c, 0x28);
|
|
|
|
config_sb_audio_hs(sb, 0x4c, 0x44, 0x30, 0x38, 0x54, 0x50);
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.audio_has_internal_names = 1;
|
2019-01-19 20:03:48 +01:00
|
|
|
|
|
|
|
config_sb_sequence(sb, 0x28, 0x14);
|
2017-11-05 17:06:40 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-12-22 22:47:24 +01:00
|
|
|
/* Prince of Persia: Warrior Within (2004)(Xbox)-bank */
|
2018-12-17 08:05:45 +01:00
|
|
|
if (sb->version == 0x00120009 && sb->platform == UBI_XBOX) {
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_entry(sb, 0x6c, 0x90);
|
|
|
|
|
|
|
|
config_sb_audio_fs(sb, 0x24, 0x28, 0x40);
|
|
|
|
config_sb_audio_hs(sb, 0x60, 0x58, 0x44, 0x4c, 0x68, 0x64); /* stream_type may contain garbage */
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.audio_has_internal_names = 1;
|
2019-01-19 20:03:48 +01:00
|
|
|
|
|
|
|
config_sb_sequence(sb, 0x28, 0x14);
|
2017-11-05 17:06:40 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-12-22 22:47:24 +01:00
|
|
|
/* Prince of Persia: Warrior Within (2004)(GC)-bank */
|
2018-12-17 08:05:45 +01:00
|
|
|
if (sb->version == 0x00120009 && sb->platform == UBI_GC) {
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_entry(sb, 0x6c, 0x78);
|
|
|
|
|
|
|
|
config_sb_audio_fs(sb, 0x20, 0x24, 0x28);
|
|
|
|
config_sb_audio_hs(sb, 0x48, 0x40, 0x2c, 0x34, 0x50, 0x4c);
|
|
|
|
|
|
|
|
config_sb_sequence(sb, 0x28, 0x14);
|
2017-11-05 17:06:40 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-07 18:03:47 +01:00
|
|
|
/* two configs with same id and both sb4/sm4; use project file as identifier */
|
2018-12-17 08:05:45 +01:00
|
|
|
if (sb->version == 0x0012000C && sb->platform == UBI_PSP) {
|
2018-03-29 22:34:21 +02:00
|
|
|
STREAMFILE * streamTest = open_streamfile_by_filename(streamFile, "BIAAUDIO.SP4");
|
2017-12-07 23:54:05 +01:00
|
|
|
if (streamTest) {
|
|
|
|
is_biadd_psp = 1;
|
|
|
|
close_streamfile(streamTest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-22 22:47:24 +01:00
|
|
|
/* Prince of Persia: Revelations (2005)(PSP)-bank */
|
2018-12-23 02:15:50 +01:00
|
|
|
/* Splinter Cell: Essentials (2006)(PSP)-map */
|
2019-01-07 18:03:47 +01:00
|
|
|
/* Beowulf: The Game (2007)(PSP)-map */
|
2018-12-17 08:05:45 +01:00
|
|
|
if (sb->version == 0x0012000C && sb->platform == UBI_PSP && !is_biadd_psp) {
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_entry(sb, 0x68, 0x84);
|
|
|
|
|
|
|
|
config_sb_audio_fs(sb, 0x24, 0x2c, 0x28);
|
|
|
|
config_sb_audio_hs(sb, 0x4c, 0x44, 0x30, 0x38, 0x54, 0x50);
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.audio_has_internal_names = 1;
|
2019-01-19 20:03:48 +01:00
|
|
|
|
|
|
|
config_sb_sequence(sb, 0x28, 0x14);
|
|
|
|
|
|
|
|
config_sb_layer_hs(sb, 0x1c, 0x60, 0x64, 0x30);
|
|
|
|
config_sb_layer_sh(sb, 0x18, 0x00, 0x08, 0x0c, 0x14);
|
2017-11-05 17:06:40 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
//todo some .sbX have bad external stream offsets, but not all (ex. offset 0xE3641 but should be 0x0A26)
|
|
|
|
/* Brothers in Arms: D-Day (2006)(PSP)-bank */
|
2018-12-17 08:05:45 +01:00
|
|
|
if (sb->version == 0x0012000C && sb->platform == UBI_PSP && is_biadd_psp) {
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_entry(sb, 0x80, 0x94);
|
|
|
|
|
|
|
|
config_sb_audio_fs(sb, 0x24, 0x2c, 0x28);
|
|
|
|
config_sb_audio_hs(sb, 0x4c, 0x44, 0x30, 0x38, 0x54, 0x50);
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.audio_has_internal_names = 1;
|
2017-12-07 23:54:05 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-13 23:27:29 +01:00
|
|
|
/* Splinter Cell: Chaos Theory (2005)(PC)-map */
|
|
|
|
if (sb->version == 0x00120012 && sb->platform == UBI_PC) {
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_entry(sb, 0x68, 0x60);
|
2019-01-13 23:27:29 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_audio_fs(sb, 0x24, 0x2c, 0x28);
|
|
|
|
config_sb_audio_he(sb, 0x4c, 0x44, 0x30, 0x38, 0x54, 0x50);
|
2019-01-13 23:27:29 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_sequence(sb, 0x28, 0x14);
|
2019-01-13 23:27:29 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Myst IV: Revelation (2005)(PC)-bank */
|
|
|
|
/* Splinter Cell: Chaos Theory (2005)(Xbox)-map */
|
|
|
|
if (sb->version == 0x00120012 && sb->platform == UBI_XBOX) {
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_entry(sb, 0x48, 0x4c);
|
|
|
|
|
|
|
|
config_sb_audio_fb(sb, 0x18, (1 << 3), (1 << 4), (1 << 10));
|
|
|
|
config_sb_audio_he(sb, 0x38, 0x30, 0x1c, 0x24, 0x40, 0x3c);
|
|
|
|
|
|
|
|
config_sb_sequence(sb, 0x28, 0x10);
|
2019-01-26 16:30:36 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Splinter Cell: Chaos Theory (2005)(GC)-map */
|
|
|
|
if (sb->version == 0x00130001 && sb->platform == UBI_GC) {
|
|
|
|
config_sb_entry(sb, 0x68, 0x54);
|
2019-01-19 20:03:48 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
config_sb_audio_fs(sb, 0x20, 0x24, 0x28);
|
|
|
|
config_sb_audio_he(sb, 0x48, 0x40, 0x2c, 0x34, 0x50, 0x4c);
|
2019-01-19 20:03:48 +01:00
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
config_sb_sequence(sb, 0x28, 0x14);
|
|
|
|
|
|
|
|
config_sb_layer_he(sb, 0x1c, 0x34, 0x3c, 0x40);
|
|
|
|
config_sb_layer_sh(sb, 0x18, 0x00, 0x08, 0x0c, 0x14);
|
2019-01-13 23:27:29 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-05 04:02:14 +01:00
|
|
|
/* Splinter Cell 3D (2011)(3DS)-map */
|
|
|
|
if (sb->version == 0x00130001 && sb->platform == UBI_3DS) {
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_entry(sb, 0x48, 0x4c);
|
|
|
|
|
|
|
|
config_sb_audio_fb(sb, 0x18, (1 << 2), (1 << 3), (1 << 4));
|
|
|
|
config_sb_audio_he(sb, 0x38, 0x30, 0x1c, 0x24, 0x40, 0x3c);
|
|
|
|
|
|
|
|
config_sb_sequence(sb, 0x28, 0x10);
|
|
|
|
|
|
|
|
config_sb_layer_he(sb, 0x1c, 0x28, 0x30, 0x34);
|
|
|
|
config_sb_layer_sh(sb, 0x18, 0x00, 0x08, 0x0c, 0x14);
|
2019-01-05 04:02:14 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
/* Tom Clancy's Ghost Recon Advanced Warfighter (2006)(PS2)-bank */
|
|
|
|
if (sb->version == 0x00130004 && sb->platform == UBI_PS2) {
|
|
|
|
config_sb_entry(sb, 0x48, 0x50);
|
|
|
|
|
|
|
|
config_sb_audio_fb(sb, 0x18, (1 << 2), (1 << 3), (1 << 4));
|
|
|
|
config_sb_audio_he(sb, 0x20, 0x24, 0x30, 0x38, 0x40, 0x4c);
|
2019-02-03 01:47:44 +01:00
|
|
|
sb->cfg.audio_interleave = 0x8000;
|
2019-01-26 16:30:36 +01:00
|
|
|
|
|
|
|
sb->cfg.is_padded_section1_offset = 1;
|
|
|
|
sb->cfg.is_padded_sounds_offset = 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-12-22 22:47:24 +01:00
|
|
|
/* Prince of Persia: The Two Thrones (2005)(PC)-bank */
|
2018-12-17 08:05:45 +01:00
|
|
|
if (sb->version == 0x00150000 && sb->platform == UBI_PC) {
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_entry(sb, 0x68, 0x78);
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_audio_fs(sb, 0x2c, 0x34, 0x30);
|
|
|
|
config_sb_audio_he(sb, 0x5c, 0x54, 0x40, 0x48, 0x64, 0x60);
|
|
|
|
|
|
|
|
config_sb_sequence(sb, 0x2c, 0x14);
|
2017-11-05 17:06:40 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* Prince of Persia: The Two Thrones (2005)(PS2)-bank */
|
|
|
|
if (sb->version == 0x00150000 && sb->platform == UBI_PS2) {
|
|
|
|
config_sb_entry(sb, 0x48, 0x5c);
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_audio_fb(sb, 0x20, (1 << 2), (1 << 3), (1 << 4));
|
|
|
|
config_sb_audio_he(sb, 0x2c, 0x30, 0x3c, 0x44, 0x4c, 0x50);
|
2019-01-13 23:27:29 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_sequence(sb, 0x2c, 0x10);
|
2018-12-21 15:17:10 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* Prince of Persia: The Two Thrones (2005)(Xbox)-bank 0x00150000 */
|
|
|
|
/* Far Cry Instincts (2005)(Xbox)-bank 0x00150000 */
|
|
|
|
/* Splinter Cell: Double Agent (2006)(Xbox)-map 0x00160002 */
|
2019-01-28 07:47:24 +01:00
|
|
|
/* Far Cry Instincts: Evolution (2006)(Xbox)-bank 0x00170000 */
|
2019-01-19 20:03:48 +01:00
|
|
|
if ((sb->version == 0x00150000 && sb->platform == UBI_XBOX) ||
|
|
|
|
(sb->version == 0x00160002 && sb->platform == UBI_XBOX) ||
|
|
|
|
(sb->version == 0x00170000 && sb->platform == UBI_XBOX)) {
|
|
|
|
config_sb_entry(sb, 0x48, 0x58);
|
2018-12-23 10:49:54 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_audio_fb(sb, 0x20, (1 << 3), (1 << 4), (1 << 10));
|
|
|
|
config_sb_audio_he(sb, 0x44, 0x3c, 0x28, 0x30, 0x4c, 0x48);
|
2018-12-23 10:49:54 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_sequence(sb, 0x2c, 0x10);
|
2019-01-05 04:02:14 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_layer_he(sb, 0x20, 0x2c, 0x34, 0x3c);
|
|
|
|
config_sb_layer_sh(sb, 0x30, 0x00, 0x08, 0x0c, 0x14);
|
2019-01-05 04:02:14 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* Prince of Persia: The Two Thrones (2005)(GC)-bank 0x00150000 */
|
|
|
|
/* Splinter Cell: Double Agent (2006)(GC)-map 0x00160002 */
|
|
|
|
if ((sb->version == 0x00150000 && sb->platform == UBI_GC) ||
|
|
|
|
(sb->version == 0x00160002 && sb->platform == UBI_GC)) {
|
|
|
|
config_sb_entry(sb, 0x68, 0x6c);
|
2019-01-05 04:02:14 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_audio_fs(sb, 0x28, 0x2c, 0x30);
|
|
|
|
config_sb_audio_he(sb, 0x58, 0x50, 0x3c, 0x44, 0x60, 0x5c);
|
2019-01-05 04:02:14 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_sequence(sb, 0x2c, 0x14);
|
2018-12-23 10:49:54 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_layer_he(sb, 0x20, 0x38, 0x40, 0x48);
|
|
|
|
config_sb_layer_sh(sb, 0x30, 0x00, 0x08, 0x0c, 0x14);
|
2019-01-13 23:27:29 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* Splinter Cell: Double Agent (2006)(PS2)-map 0x00160002 */
|
2019-01-26 11:31:50 +01:00
|
|
|
/* Open Season (2006)(PS2)-map 0x00180003 */
|
|
|
|
/* Open Season (2006)(PSP)-map 0x00180003 */
|
2019-01-19 20:03:48 +01:00
|
|
|
/* Shaun White Snowboarding (2008)(PS2)-map 0x00180003 */
|
|
|
|
/* Prince of Persia: Rival Swords (2007)(PSP)-bank 0x00180005 */
|
|
|
|
/* Rainbow Six Vegas (2007)(PSP)-bank 0x00180006 */
|
|
|
|
/* Star Wars: Lethal Alliance (2006)(PSP)-map 0x00180007 */
|
|
|
|
if ((sb->version == 0x00160002 && sb->platform == UBI_PS2) ||
|
|
|
|
(sb->version == 0x00180003 && sb->platform == UBI_PS2) ||
|
2019-01-07 18:03:47 +01:00
|
|
|
(sb->version == 0x00180003 && sb->platform == UBI_PSP) ||
|
|
|
|
(sb->version == 0x00180005 && sb->platform == UBI_PSP) ||
|
|
|
|
(sb->version == 0x00180006 && sb->platform == UBI_PSP) ||
|
|
|
|
(sb->version == 0x00180007 && sb->platform == UBI_PSP)) {
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_entry(sb, 0x48, 0x54);
|
2017-11-11 17:46:18 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_audio_fb(sb, 0x20, (1 << 2), (1 << 3), (1 << 4));
|
|
|
|
config_sb_audio_he(sb, 0x28, 0x2c, 0x34, 0x3c, 0x44, 0x48);
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_sequence(sb, 0x2c, 0x10);
|
|
|
|
|
|
|
|
config_sb_layer_he(sb, 0x20, 0x2c, 0x30, 0x38);
|
|
|
|
config_sb_layer_sh(sb, 0x34, 0x00, 0x08, 0x0c, 0x14);
|
2019-01-26 16:30:36 +01:00
|
|
|
|
|
|
|
config_sb_silence_f(sb, 0x1c);
|
|
|
|
|
|
|
|
/* Rainbow Six Vegas (PSP) has 2 layers with different sample rates, but 2nd layer is silent and can be ignored */
|
|
|
|
if (sb->version == 0x00180006 && sb->platform == UBI_PSP)
|
|
|
|
sb->cfg.ignore_layer_error = 1;
|
2019-01-13 23:27:29 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-03-16 13:58:28 +01:00
|
|
|
/* Tom Clancy's Ghost Recon Advanced Warfighter (2006)(X360)-bank */
|
|
|
|
if (sb->version == 0x00170001 && sb->platform == UBI_X360) {
|
|
|
|
config_sb_entry(sb, 0x68, 0x70);
|
|
|
|
|
|
|
|
config_sb_audio_fs(sb, 0x2c, 0x30, 0x34);
|
|
|
|
config_sb_audio_he(sb, 0x5c, 0x54, 0x40, 0x48, 0x64, 0x60);
|
|
|
|
sb->cfg.audio_xma_offset = 0; /* header is in the extra table */
|
|
|
|
|
|
|
|
config_sb_sequence(sb, 0x2c, 0x14);
|
|
|
|
|
|
|
|
config_sb_layer_he(sb, 0x20, 0x38, 0x3c, 0x48);
|
|
|
|
config_sb_layer_sh(sb, 0x30, 0x00, 0x08, 0x0c, 0x14);
|
|
|
|
sb->cfg.layer_hijack = 1; /* WTF!!! layer format different from other layers using same id!!! */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-28 07:47:24 +01:00
|
|
|
/* Open Season (2006)(PC)-map 0x00180003 */
|
2019-01-26 11:31:50 +01:00
|
|
|
if (sb->version == 0x00180003 && sb->platform == UBI_PC) {
|
|
|
|
config_sb_entry(sb, 0x68, 0x78);
|
|
|
|
|
|
|
|
config_sb_audio_fs(sb, 0x2c, 0x34, 0x30);
|
|
|
|
config_sb_audio_he(sb, 0x5c, 0x54, 0x40, 0x48, 0x64, 0x60);
|
|
|
|
|
|
|
|
config_sb_sequence(sb, 0x2c, 0x14);
|
|
|
|
|
|
|
|
config_sb_layer_he(sb, 0x20, 0x38, 0x3c, 0x44);
|
|
|
|
config_sb_layer_sh(sb, 0x34, 0x00, 0x08, 0x0c, 0x14);
|
2019-02-11 10:37:54 +01:00
|
|
|
|
|
|
|
config_sb_silence_f(sb, 0x1c);
|
2019-01-26 11:31:50 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Open Season (2006)(Xbox)-map 0x00180003 */
|
|
|
|
if (sb->version == 0x00180003 && sb->platform == UBI_XBOX) {
|
|
|
|
config_sb_entry(sb, 0x48, 0x58);
|
|
|
|
|
|
|
|
config_sb_audio_fb(sb, 0x20, (1 << 3), (1 << 4), (1 << 10));
|
|
|
|
config_sb_audio_he(sb, 0x44, 0x3c, 0x28, 0x30, 0x4c, 0x48);
|
|
|
|
|
|
|
|
config_sb_sequence(sb, 0x2c, 0x10);
|
|
|
|
|
|
|
|
config_sb_layer_he(sb, 0x20, 0x2c, 0x30, 0x38);
|
|
|
|
config_sb_layer_sh(sb, 0x34, 0x00, 0x08, 0x0c, 0x14);
|
2019-02-11 10:37:54 +01:00
|
|
|
|
|
|
|
config_sb_silence_f(sb, 0x1c);
|
2019-01-26 11:31:50 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Open Season (2006)(GC)-map 0x00180003 */
|
|
|
|
if (sb->version == 0x00180003 && sb->platform == UBI_GC) {
|
|
|
|
config_sb_entry(sb, 0x68, 0x6c);
|
|
|
|
|
|
|
|
config_sb_audio_fs(sb, 0x28, 0x2c, 0x30);
|
|
|
|
config_sb_audio_he(sb, 0x58, 0x50, 0x3c, 0x44, 0x60, 0x5c);
|
|
|
|
|
|
|
|
config_sb_sequence(sb, 0x2c, 0x14);
|
|
|
|
|
|
|
|
config_sb_layer_he(sb, 0x20, 0x38, 0x3c, 0x44);
|
|
|
|
config_sb_layer_sh(sb, 0x34, 0x00, 0x08, 0x0c, 0x14);
|
2019-02-11 10:37:54 +01:00
|
|
|
|
|
|
|
config_sb_silence_f(sb, 0x1c);
|
2019-01-26 11:31:50 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-03-16 13:58:28 +01:00
|
|
|
|
|
|
|
/* two configs with same id; use project file as identifier */
|
2019-01-13 23:27:29 +01:00
|
|
|
if (sb->version == 0x00180006 && sb->platform == UBI_PC) {
|
2019-03-16 13:58:28 +01:00
|
|
|
STREAMFILE * streamTest = open_streamfile_by_filename(streamFile, "Sc4_online_SoundProject.SP0");
|
|
|
|
if (streamTest) {
|
|
|
|
is_sc4_pc_online = 1;
|
|
|
|
close_streamfile(streamTest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Splinter Cell: Double Agent (2006)(PC)-map (offline) */
|
|
|
|
if (sb->version == 0x00180006 && sb->platform == UBI_PC && !is_sc4_pc_online) {
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_entry(sb, 0x68, 0x7c);
|
2019-01-13 23:27:29 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_audio_fs(sb, 0x2c, 0x34, 0x30);
|
|
|
|
config_sb_audio_he(sb, 0x5c, 0x54, 0x40, 0x48, 0x64, 0x60);
|
2019-01-13 23:27:29 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_layer_he(sb, 0x20, 0x38, 0x3c, 0x44);
|
|
|
|
config_sb_layer_sh(sb, 0x34, 0x00, 0x08, 0x0c, 0x14);
|
2019-01-13 23:27:29 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-03-16 13:58:28 +01:00
|
|
|
/* Splinter Cell: Double Agent (2006)(PC)-map (online) */
|
|
|
|
if (sb->version == 0x00180006 && sb->platform == UBI_PC && is_sc4_pc_online) {
|
|
|
|
config_sb_entry(sb, 0x68, 0x78);
|
|
|
|
|
|
|
|
config_sb_audio_fs(sb, 0x2c, 0x34, 0x30);
|
|
|
|
config_sb_audio_he(sb, 0x5c, 0x54, 0x40, 0x48, 0x64, 0x60);
|
|
|
|
|
|
|
|
config_sb_layer_he(sb, 0x20, 0x38, 0x3c, 0x44);
|
|
|
|
config_sb_layer_sh(sb, 0x34, 0x00, 0x08, 0x0c, 0x14);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-13 23:27:29 +01:00
|
|
|
/* Splinter Cell: Double Agent (2006)(X360)-map */
|
|
|
|
if (sb->version == 0x00180006 && sb->platform == UBI_X360) {
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_entry(sb, 0x68, 0x78);
|
2019-01-13 23:27:29 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_audio_fs(sb, 0x2c, 0x30, 0x34);
|
|
|
|
config_sb_audio_he(sb, 0x5c, 0x54, 0x40, 0x48, 0x64, 0x60);
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.audio_xma_offset = 0x70;
|
2019-01-13 23:27:29 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_layer_he(sb, 0x20, 0x38, 0x3c, 0x44);
|
|
|
|
config_sb_layer_sh(sb, 0x34, 0x00, 0x08, 0x0c, 0x14);
|
2017-12-07 23:54:05 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-26 16:30:36 +01:00
|
|
|
/* Red Steel (2006)(Wii)-bank */
|
2019-01-19 20:03:48 +01:00
|
|
|
if (sb->version == 0x00180006 && sb->platform == UBI_WII) {
|
|
|
|
config_sb_entry(sb, 0x68, 0x6c);
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_audio_fs(sb, 0x28, 0x2c, 0x30);
|
|
|
|
config_sb_audio_he(sb, 0x58, 0x50, 0x3c, 0x44, 0x60, 0x5c);
|
2018-12-17 11:20:53 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_sequence(sb, 0x2c, 0x14);
|
2017-11-05 17:06:40 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_layer_he(sb, 0x20, 0x38, 0x3c, 0x44);
|
|
|
|
config_sb_layer_sh(sb, 0x34, 0x00, 0x08, 0x0c, 0x14);
|
2017-12-03 20:25:50 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* TMNT (2007)(PSP)-map 0x00190001 */
|
|
|
|
/* Surf's Up (2007)(PSP)-map 0x00190005 */
|
|
|
|
if ((sb->version == 0x00190001 && sb->platform == UBI_PSP) ||
|
|
|
|
(sb->version == 0x00190005 && sb->platform == UBI_PSP)) {
|
|
|
|
config_sb_entry(sb, 0x48, 0x58);
|
|
|
|
|
|
|
|
config_sb_audio_fb(sb, 0x20, (1 << 2), (1 << 3), (1 << 4)); /* assumed group_flag */
|
|
|
|
config_sb_audio_he(sb, 0x28, 0x2c, 0x34, 0x3c, 0x44, 0x48);
|
2018-12-17 11:20:53 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_sequence(sb, 0x2c, 0x10);
|
2018-12-17 11:20:53 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_layer_he(sb, 0x20, 0x2c, 0x30, 0x38);
|
|
|
|
config_sb_layer_sh(sb, 0x30, 0x00, 0x04, 0x08, 0x10);
|
2018-12-30 15:38:03 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* TMNT (2007)(GC)-bank */
|
|
|
|
if (sb->version == 0x00190002 && sb->platform == UBI_GC) {
|
|
|
|
config_sb_entry(sb, 0x68, 0x6c);
|
2018-12-30 15:38:03 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_audio_fs(sb, 0x28, 0x2c, 0x30); /* assumed groud_id */
|
|
|
|
config_sb_audio_he(sb, 0x3c, 0x40, 0x48, 0x50, 0x58, 0x5c);
|
2018-12-30 15:38:03 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_sequence(sb, 0x2c, 0x14);
|
|
|
|
|
|
|
|
config_sb_layer_he(sb, 0x20, 0x34, 0x38, 0x40);
|
|
|
|
config_sb_layer_sh(sb, 0x30, 0x00, 0x04, 0x08, 0x10);
|
2019-01-26 16:30:36 +01:00
|
|
|
|
|
|
|
config_sb_silence_f(sb, 0x1c);
|
2018-12-17 11:20:53 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* TMNT (2007)(PS2)-bank */
|
|
|
|
if (sb->version == 0x00190002 && sb->platform == UBI_PS2) {
|
|
|
|
config_sb_entry(sb, 0x48, 0x5c);
|
|
|
|
|
|
|
|
config_sb_audio_fb(sb, 0x20, (1 << 2), (1 << 3), (1 << 4)); /* assumed group_flag */
|
|
|
|
config_sb_audio_he(sb, 0x28, 0x2c, 0x34, 0x3c, 0x44, 0x48);
|
2018-02-17 02:07:43 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_sequence(sb, 0x2c, 0x10);
|
2018-02-17 02:07:43 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_layer_he(sb, 0x20, 0x2c, 0x30, 0x38);
|
|
|
|
config_sb_layer_sh(sb, 0x30, 0x00, 0x04, 0x08, 0x10);
|
2019-01-26 16:30:36 +01:00
|
|
|
|
|
|
|
config_sb_silence_f(sb, 0x1c);
|
2018-02-17 02:07:43 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* TMNT (2007)(X360)-bank 0x00190002 */
|
|
|
|
/* Prince of Persia: Rival Swords (2007)(Wii)-bank 0x00190003 */
|
|
|
|
/* Rainbow Six Vegas (2007)(PS3)-bank 0x00190005 */
|
|
|
|
/* Surf's Up (2007)(PS3)-bank 0x00190005 */
|
|
|
|
/* Surf's Up (2007)(X360)-bank 0x00190005 */
|
|
|
|
/* Splinter Cell: Double Agent (2007)(PS3)-map 0x00190005 */
|
|
|
|
if ((sb->version == 0x00190002 && sb->platform == UBI_X360) ||
|
|
|
|
(sb->version == 0x00190003 && sb->platform == UBI_WII) ||
|
|
|
|
(sb->version == 0x00190005 && sb->platform == UBI_PS3) ||
|
|
|
|
(sb->version == 0x00190005 && sb->platform == UBI_X360)) {
|
|
|
|
config_sb_entry(sb, 0x68, 0x70);
|
2018-12-17 08:05:45 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_audio_fs(sb, 0x28, 0x2c, 0x30);
|
|
|
|
config_sb_audio_he(sb, 0x3c, 0x40, 0x48, 0x50, 0x58, 0x5c);
|
2019-01-26 16:30:36 +01:00
|
|
|
sb->cfg.audio_xma_offset = 0x6c;
|
2019-02-03 01:47:44 +01:00
|
|
|
sb->cfg.audio_interleave = 0x10;
|
2018-12-22 22:47:24 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_sequence(sb, 0x2c, 0x14);
|
2018-12-17 08:05:45 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_layer_he(sb, 0x20, 0x34, 0x38, 0x40);
|
|
|
|
config_sb_layer_sh(sb, 0x30, 0x00, 0x04, 0x08, 0x10);
|
2019-01-26 16:30:36 +01:00
|
|
|
|
2019-02-03 01:47:44 +01:00
|
|
|
//todo Splinter Cell: Double Agent (PS3) #13214 (PS-ADPCM + looping) has double num_samples, may need a flag
|
|
|
|
//AC1 PS3 also does it for PS-ADPCM + looping only (not AT3 or non-looping) */
|
2018-12-17 08:05:45 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
/* TMNT (2007)(PC)-bank 0x00190002 */
|
|
|
|
/* Surf's Up (2007)(PC)-bank 0x00190005 */
|
|
|
|
if ((sb->version == 0x00190002 && sb->platform == UBI_PC) ||
|
|
|
|
(sb->version == 0x00190005 && sb->platform == UBI_PC)) {
|
|
|
|
config_sb_entry(sb, 0x68, 0x74);
|
2019-01-05 04:02:14 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_audio_fs(sb, 0x28, 0x2c, 0x30);
|
|
|
|
config_sb_audio_he(sb, 0x3c, 0x40, 0x48, 0x50, 0x58, 0x5c);
|
2018-12-17 08:05:45 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_sequence(sb, 0x2c, 0x14);
|
|
|
|
|
|
|
|
config_sb_layer_he(sb, 0x20, 0x34, 0x38, 0x40);
|
|
|
|
config_sb_layer_sh(sb, 0x30, 0x00, 0x04, 0x08, 0x10);
|
2019-01-26 16:30:36 +01:00
|
|
|
|
|
|
|
config_sb_silence_f(sb, 0x1c);
|
2018-12-30 15:38:03 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-02-03 01:47:44 +01:00
|
|
|
/* Rainbow Six Vegas 2 (2008)(PS3)-bank */
|
|
|
|
/* Rainbow Six Vegas 2 (2008)(X360)-bank */
|
|
|
|
if ((sb->version == 0x001C0000 && sb->platform == UBI_PS3) ||
|
|
|
|
(sb->version == 0x001C0000 && sb->platform == UBI_X360)) {
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_entry(sb, 0x64, 0x7c);
|
2019-01-05 04:02:14 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_audio_fs(sb, 0x28, 0x30, 0x34);
|
|
|
|
config_sb_audio_he(sb, 0x44, 0x48, 0x50, 0x58, 0x60, 0x64);
|
2019-02-03 01:47:44 +01:00
|
|
|
sb->cfg.audio_xma_offset = 0x78;
|
|
|
|
sb->cfg.audio_interleave = 0x10;
|
|
|
|
|
|
|
|
config_sb_sequence(sb, 0x2c, 0x14);
|
2019-01-05 04:02:14 +01:00
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_layer_he(sb, 0x20, 0x44, 0x48, 0x54);
|
|
|
|
config_sb_layer_sh(sb, 0x30, 0x00, 0x04, 0x08, 0x10);
|
2019-01-05 04:02:14 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Michael Jackson: The Experience (2010)(PSP)-map */
|
2019-01-26 11:31:50 +01:00
|
|
|
if (sb->version == 0x001D0000 && sb->platform == UBI_PSP) {
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_entry(sb, 0x40, 0x60);
|
|
|
|
|
|
|
|
config_sb_audio_fb(sb, 0x20, (1 << 2), (1 << 3), (1 << 5)); /* assumed group_flag */
|
|
|
|
config_sb_audio_he(sb, 0x28, 0x30, 0x38, 0x40, 0x48, 0x4c);
|
2018-12-17 08:05:45 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-12-24 12:29:55 +01:00
|
|
|
/* Splinter Cell Classic Trilogy HD (2011)(PS3)-map */
|
2019-01-26 11:31:50 +01:00
|
|
|
if (sb->version == 0x001D0000 && sb->platform == UBI_PS3) {
|
2019-01-19 20:03:48 +01:00
|
|
|
config_sb_entry(sb, 0x5c, 0x80);
|
2019-02-17 20:53:30 +01:00
|
|
|
sb->cfg.audio_interleave = 0x10;
|
2019-01-19 20:03:48 +01:00
|
|
|
|
|
|
|
config_sb_audio_fs(sb, 0x28, 0x30, 0x34);
|
|
|
|
config_sb_audio_he(sb, 0x44, 0x4c, 0x54, 0x5c, 0x64, 0x68);
|
|
|
|
|
|
|
|
config_sb_sequence(sb, 0x2c, 0x14);
|
|
|
|
|
|
|
|
config_sb_layer_he(sb, 0x20, 0x44, 0x48, 0x54);
|
|
|
|
config_sb_layer_sh(sb, 0x38, 0x00, 0x04, 0x08, 0x10);
|
2018-12-24 12:29:55 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-19 20:03:48 +01:00
|
|
|
VGM_LOG("UBI SB: unknown SB/SM version+platform %08x\n", sb->version);
|
2017-11-05 17:06:40 +01:00
|
|
|
return 0;
|
|
|
|
}
|