mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-13 18:20:50 +01:00
commit
87fc7007d7
@ -183,7 +183,7 @@ static void bruteforce_hca_key(STREAMFILE* sf, hca_codec_data* hca_data, unsigne
|
||||
uint8_t* buf = NULL;
|
||||
int best_score = -1;
|
||||
off_t keys_size, bytes;
|
||||
int i, pos;
|
||||
int pos;
|
||||
|
||||
|
||||
VGM_LOG("HCA: test keys\n");
|
||||
@ -214,7 +214,7 @@ static void bruteforce_hca_key(STREAMFILE* sf, hca_codec_data* hca_data, unsigne
|
||||
if (key == 0)
|
||||
continue;
|
||||
|
||||
test_key(hca_data, keys[i], subkey, &best_score, out_keycode);
|
||||
test_key(hca_data, key, subkey, &best_score, out_keycode);
|
||||
if (best_score == 1)
|
||||
goto done;
|
||||
|
||||
|
@ -340,14 +340,32 @@ static const hcakey_info hcakey_list[] = {
|
||||
/* 22/7 Ongaku no Jikan (Android) */
|
||||
{20190906}, // 00000000013416BA
|
||||
|
||||
/* Dragalia Lost (iOS/Android) */
|
||||
{2967411924141, subkeys_dgl, sizeof(subkeys_dgl) / sizeof(subkeys_dgl[0]) }, // 000002B2E7889CAD
|
||||
|
||||
/* Cardcaptor Sakura: Happiness Memories (Android) */
|
||||
{625144437747651}, // 00023890C8252FC3
|
||||
|
||||
/* Digimon Story: Cyber Sleuth (PC) */
|
||||
{0x283553DCE3FD5FB9}, // 283553DCE3FD5FB9
|
||||
{2897314143465725881}, // 283553DCE3FD5FB9
|
||||
|
||||
/* Alice Re:Code (Android) */
|
||||
{0x82C3C951C561F736}, // 9422596198430275382 / 82C3C951C561F736
|
||||
|
||||
/* Tokyo 7th Sisters (Android) */
|
||||
{0xFDAE531AAB414BA1}, // FDAE531AAB414BA1 / 18279639311550860193
|
||||
|
||||
/* High School Fleet: Kantai Battle de Pinch! (Mobile) */
|
||||
{43472919336422565}, // 009A7263CA658CA5
|
||||
|
||||
/* Disney's Twisted Wonderland (Android) */
|
||||
{2895000877}, // 00000000AC8E352D
|
||||
|
||||
/* B-PROJECT Kaikan Everyday (Android) */
|
||||
{0xAAED297DDEF1D9F6}, // AAED297DDEF1D9F6 / 12316546176516217334
|
||||
|
||||
/* HELIOS Rising Heroes (Android) */
|
||||
{311981570940334162}, // 04546195F85DF052
|
||||
|
||||
/* Dragalia Lost (iOS/Android) */
|
||||
{2967411924141, subkeys_dgl, sizeof(subkeys_dgl) / sizeof(subkeys_dgl[0]) }, // 000002B2E7889CAD
|
||||
|
||||
};
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
static size_t joe_find_padding(STREAMFILE *streamFile, off_t start_offset, size_t data_size, int channels, size_t interleave);
|
||||
static size_t joe_find_padding(STREAMFILE* sf, off_t start_offset, size_t data_size, int channels, size_t interleave);
|
||||
|
||||
/* .JOE - from Asobo Studio games [Up (PS2), Wall-E (PS2)] */
|
||||
VGMSTREAM * init_vgmstream_ps2_joe(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
VGMSTREAM* init_vgmstream_ps2_joe(STREAMFILE* sf) {
|
||||
VGMSTREAM* vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
int channel_count, loop_flag, sample_rate;
|
||||
int32_t num_samples;
|
||||
@ -13,54 +13,59 @@ VGMSTREAM * init_vgmstream_ps2_joe(STREAMFILE *streamFile) {
|
||||
|
||||
|
||||
/* checks */
|
||||
if (!check_extensions(streamFile, "joe"))
|
||||
if (!check_extensions(sf, "joe"))
|
||||
goto fail;
|
||||
|
||||
file_size = get_streamfile_size(streamFile);
|
||||
data_size = read_32bitLE(0x04,streamFile);
|
||||
unknown1 = read_32bitLE(0x08,streamFile);
|
||||
unknown2 = read_32bitLE(0x0c,streamFile);
|
||||
file_size = get_streamfile_size(sf);
|
||||
data_size = read_u32le(0x04,sf);
|
||||
unknown1 = read_u32le(0x08,sf);
|
||||
unknown2 = read_u32le(0x0c,sf);
|
||||
|
||||
/* detect version */
|
||||
if (data_size / 2 == file_size - 0x10
|
||||
&& unknown1 == 0x0045039A && unknown2 == 0x00108920) { /* Super Farm (PS2) */
|
||||
if (data_size == file_size - 0x800
|
||||
&& unknown1 == 0x00002000 && unknown2 == 0xFFFFFFFF) { /* NYR (PS2) */
|
||||
interleave = 0x2000;
|
||||
start_offset = 0x800;
|
||||
}
|
||||
else if (data_size / 2 == file_size - 0x10
|
||||
&& unknown1 == 0x0045039A && unknown2 == 0x00108920) { /* Super Farm (PS2) */
|
||||
data_size = data_size / 2;
|
||||
interleave = 0x4000;
|
||||
start_offset = 0x10;
|
||||
} else if (data_size / 2 == file_size - 0x10
|
||||
&& unknown1 == 0xCCCCCCCC && unknown2 == 0xCCCCCCCC) { /* Sitting Ducks (PS2) */
|
||||
}
|
||||
else if (data_size / 2 == file_size - 0x10
|
||||
&& unknown1 == 0xCCCCCCCC && unknown2 == 0xCCCCCCCC) { /* Sitting Ducks (PS2) */
|
||||
data_size = data_size / 2;
|
||||
interleave = 0x8000;
|
||||
start_offset = 0x10;
|
||||
} else if (data_size == file_size - 0x10
|
||||
&& unknown1 == 0xCCCCCCCC && unknown2 == 0xCCCCCCCC) { /* The Mummy: The Animated Series (PS2) */
|
||||
}
|
||||
else if (data_size == file_size - 0x10
|
||||
&& unknown1 == 0xCCCCCCCC && unknown2 == 0xCCCCCCCC) { /* The Mummy: The Animated Series (PS2) */
|
||||
interleave = 0x8000;
|
||||
start_offset = 0x10;
|
||||
} else if (data_size == file_size - 0x4020) { /* CT Special Forces (PS2), and all games beyond */
|
||||
interleave = unknown1; /* always 0? */
|
||||
if (!interleave)
|
||||
interleave = 0x10;
|
||||
start_offset = 0x4020; /* header padding contains garbage */
|
||||
} else {
|
||||
}
|
||||
else if (data_size == file_size - 0x4020) { /* Counter Terrorism Special Forces (PS2), all games beyond */
|
||||
/* header can be section(?) table (0x08=entry count) then 0xCCCCCCCC, all 0s, or all 0xCCCCCCCC (no table) */
|
||||
interleave = 0x10;
|
||||
start_offset = 0x4020;
|
||||
}
|
||||
else {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
//start_offset = file_size - data_size; /* also ok */
|
||||
channel_count = 2;
|
||||
loop_flag = 0;
|
||||
sample_rate = read_32bitLE(0x00,streamFile);
|
||||
|
||||
/* the file's end is padded with either 0xcdcdcdcd or zeroes */
|
||||
padding_size = joe_find_padding(streamFile, start_offset, data_size, channel_count, interleave);
|
||||
if (padding_size == SIZE_MAX)
|
||||
goto fail;
|
||||
sample_rate = read_s32le(0x00,sf);
|
||||
|
||||
/* the file's end is padded with either 0xcdcdcdcd or zeroes (but not always, ex. NYR) */
|
||||
padding_size = joe_find_padding(sf, start_offset, data_size, channel_count, interleave);
|
||||
data_size -= padding_size;
|
||||
num_samples = ps_bytes_to_samples(data_size, channel_count);
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
vgmstream = allocate_vgmstream(channel_count, loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->sample_rate = sample_rate;
|
||||
@ -72,7 +77,7 @@ VGMSTREAM * init_vgmstream_ps2_joe(STREAMFILE *streamFile) {
|
||||
vgmstream->interleave_block_size = interleave;
|
||||
vgmstream->meta_type = meta_PS2_JOE;
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
@ -81,23 +86,23 @@ fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static size_t joe_find_padding(STREAMFILE *streamFile, off_t start_offset, size_t data_size, int channels, size_t interleave) {
|
||||
uint8_t flag;
|
||||
static size_t joe_find_padding(STREAMFILE* sf, off_t start_offset, size_t data_size, int channels, size_t interleave) {
|
||||
uint32_t pad;
|
||||
off_t min_offset, offset;
|
||||
size_t frame_size = 0x10;
|
||||
size_t padding_size = 0;
|
||||
size_t interleave_consumed = 0;
|
||||
|
||||
if (data_size == 0 || channels == 0 || (channels > 0 && interleave == 0))
|
||||
return SIZE_MAX;
|
||||
return 0;
|
||||
|
||||
offset = start_offset + data_size - interleave * (channels - 1);
|
||||
min_offset = start_offset;
|
||||
|
||||
while (offset > min_offset) {
|
||||
offset -= frame_size;
|
||||
flag = read_8bit(offset + 0x01, streamFile);
|
||||
if (flag == 0x03)
|
||||
pad = read_u32be(offset, sf);
|
||||
if (pad != 0xCDCDCDCD && pad != 0x00000000)
|
||||
break;
|
||||
|
||||
padding_size += frame_size * channels;
|
||||
@ -111,7 +116,7 @@ static size_t joe_find_padding(STREAMFILE *streamFile, off_t start_offset, size_
|
||||
}
|
||||
|
||||
if (padding_size >= data_size)
|
||||
return SIZE_MAX;
|
||||
return 0;
|
||||
|
||||
return padding_size;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user