From a57134dc2bd259f3dcb959dfd45c96493d577f70 Mon Sep 17 00:00:00 2001 From: bnnm Date: Sat, 19 May 2018 11:37:21 +0200 Subject: [PATCH] Add .gwd Ogg [Adagio Cloudburst (PC)] --- src/formats.c | 2 ++ src/meta/ogg_vorbis.c | 22 ++++++++++++++++++++++ src/vgmstream.h | 1 + 3 files changed, 25 insertions(+) diff --git a/src/formats.c b/src/formats.c index aa893007..9ee28ba9 100644 --- a/src/formats.c +++ b/src/formats.c @@ -135,6 +135,7 @@ static const char* extension_list[] = { "gms", "gsb", "gtd", + "gwm", "hca", "hgc1", @@ -1014,6 +1015,7 @@ static const meta_info meta_info_list[] = { {meta_UBI_BAO, "Ubisoft BAO header"}, {meta_DSP_SWITCH_AUDIO, "UE4 Switch Audio header"}, {meta_TA_AAC_VITA, "tri-Ace AAC (Vita) header"}, + {meta_OGG_GWM, "Ogg Vorbis (GWM header)"}, #ifdef VGM_USE_FFMPEG {meta_FFmpeg, "FFmpeg supported file format"}, diff --git a/src/meta/ogg_vorbis.c b/src/meta/ogg_vorbis.c index 8041e79b..93b3b955 100644 --- a/src/meta/ogg_vorbis.c +++ b/src/meta/ogg_vorbis.c @@ -215,6 +215,17 @@ static void ys8_ogg_decryption_callback(void *ptr, size_t size, size_t nmemb, vo } } +static void gwm_ogg_decryption_callback(void *ptr, size_t size, size_t nmemb, void *datasource) { + size_t bytes_read = size*nmemb; + ogg_vorbis_streamfile * const ov_streamfile = datasource; + int i; + + /* bytes are xor'd with key */ + for (i = 0; i < bytes_read; i++) { + ((uint8_t*)ptr)[i] ^= (uint8_t)ov_streamfile->xor_value; + } +} + /* Ogg Vorbis, by way of libvorbisfile; may contain loop comments */ VGMSTREAM * init_vgmstream_ogg_vorbis(STREAMFILE *streamFile) { ogg_vorbis_meta_info_t ovmi = {0}; @@ -227,6 +238,7 @@ VGMSTREAM * init_vgmstream_ogg_vorbis(STREAMFILE *streamFile) { int is_isd = 0; int is_rpgmvo = 0; int is_eno = 0; + int is_gwm = 0; /* check extension */ @@ -248,6 +260,8 @@ VGMSTREAM * init_vgmstream_ogg_vorbis(STREAMFILE *streamFile) { is_rpgmvo = 1; } else if (check_extensions(streamFile,"eno")) { /* .eno: Metronomicon (PC) */ is_eno = 1; + } else if (check_extensions(streamFile,"gwm")) { /* .gwm: Adagio: Cloudburst (PC) */ + is_gwm = 1; } else { goto fail; } @@ -342,6 +356,14 @@ VGMSTREAM * init_vgmstream_ogg_vorbis(STREAMFILE *streamFile) { } + /* check GWM [Adagio: Cloudburst (PC)], encrypted */ + if (is_gwm) { + ovmi.xor_value = 0x5D; + ovmi.decryption_callback = gwm_ogg_decryption_callback; + ovmi.meta_type = meta_OGG_GWM; + } + + return init_vgmstream_ogg_vorbis_callbacks(streamFile, NULL, start_offset, &ovmi); fail: diff --git a/src/vgmstream.h b/src/vgmstream.h index 01ed8682..fe019961 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -676,6 +676,7 @@ typedef enum { meta_UBI_BAO, /* Ubisoft BAO */ meta_DSP_SWITCH_AUDIO, /* Gal Gun 2 (Switch) */ meta_TA_AAC_VITA, /* tri-Ace AAC (Judas Code) */ + meta_OGG_GWM, /* Ogg Vorbis with encryption [Metronomicon (PC)] */ #ifdef VGM_USE_FFMPEG meta_FFmpeg,