refactor: Add support for LDJ-20250825
> account for changes in IIDX32 onward affecting `hooks::soundbank` > `hooks::soundbank` should support any ambiguous IIDX32/33 datacodes again
This commit is contained in:
+39
-11
@@ -696,6 +696,7 @@ static struct offset_t
|
|||||||
intptr_t DAT_song_titlel;
|
intptr_t DAT_song_titlel;
|
||||||
intptr_t DAT_song_artistl;
|
intptr_t DAT_song_artistl;
|
||||||
intptr_t DAT_song_id;
|
intptr_t DAT_song_id;
|
||||||
|
bool is_lstr_wchar;
|
||||||
memutils::VProtectGuard *guard;
|
memutils::VProtectGuard *guard;
|
||||||
|
|
||||||
static constexpr unsigned int by_ext(const char *ext, int h = 0)
|
static constexpr unsigned int by_ext(const char *ext, int h = 0)
|
||||||
@@ -705,7 +706,7 @@ static struct offset_t
|
|||||||
} offset_;
|
} offset_;
|
||||||
snd_bank *snd_bank::cache_ = nullptr;
|
snd_bank *snd_bank::cache_ = nullptr;
|
||||||
size_t snd_bank::cachesz_ = 0;
|
size_t snd_bank::cachesz_ = 0;
|
||||||
avcodec::pcm_resampler_t snd_bank::resampler_ = avcodec::bmswac_resampler_s16_ad;
|
avcodec::pcm_resampler_t snd_bank::resampler_ = avcodec::bmswac_resampler_s16_ad; //_REM: Temporary (revert to bmswac_resampler_s16)
|
||||||
static BmsbEnumValidSoundbanks_t BmsbEnumValidSoundbanks;
|
static BmsbEnumValidSoundbanks_t BmsbEnumValidSoundbanks;
|
||||||
void *on_enum_valid_soundbanks(void *song, int32_t difficulty, int32_t unk2)
|
void *on_enum_valid_soundbanks(void *song, int32_t difficulty, int32_t unk2)
|
||||||
{
|
{
|
||||||
@@ -717,7 +718,17 @@ void *on_enum_valid_soundbanks(void *song, int32_t difficulty, int32_t unk2)
|
|||||||
const int32_t id = *(int32_t *) ((const char *) song + offset_.DAT_song_id);
|
const int32_t id = *(int32_t *) ((const char *) song + offset_.DAT_song_id);
|
||||||
const char suffix = *((const char *) song + offset_.DAT_song_id + 8 + difficulty);
|
const char suffix = *((const char *) song + offset_.DAT_song_id + 8 + difficulty);
|
||||||
|
|
||||||
log_info("hooks::soundbank", "Processing s3p->2dx transcoding routine for [{}]({} - {})", id, artistl, titlel);
|
if (offset_.is_lstr_wchar)
|
||||||
|
{
|
||||||
|
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
|
||||||
|
log_info("hooks::soundbank", "Processing s3p->2dx transcoding routine for [{}]({} - {})",
|
||||||
|
id,
|
||||||
|
converter.to_bytes(std::wstring(reinterpret_cast<const wchar_t *>(artistl), wcslen(reinterpret_cast<const wchar_t *>(artistl)))),
|
||||||
|
converter.to_bytes(std::wstring(reinterpret_cast<const wchar_t *>(titlel), wcslen(reinterpret_cast<const wchar_t *>(titlel))))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
log_info("hooks::soundbank", "Processing s3p->2dx transcoding routine for [{}]({} - {})", id, artistl, titlel);
|
||||||
if (!(keysounds = snd_bank::get_bank(id, suffix - '0')))
|
if (!(keysounds = snd_bank::get_bank(id, suffix - '0')))
|
||||||
{
|
{
|
||||||
log_warning("hooks::soundbank", "soundbank::get_bank() was 0x0, this shouldn't happen..");
|
log_warning("hooks::soundbank", "soundbank::get_bank() was 0x0, this shouldn't happen..");
|
||||||
@@ -875,21 +886,37 @@ void init(HINSTANCE hmodule, const char *ext)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Override .text .data per datacode _REV: prefer runtime offset lookup based on universal asm pattern
|
// Override .text .data per datacode _REV: prefer runtime offset lookup based on universal asm pattern
|
||||||
offset_.DAT_song_titlel = 0x00;
|
long extl = strtol(ext, nullptr, 10);
|
||||||
offset_.DAT_song_artistl = 0xc0;
|
if (extl < 2019100800)
|
||||||
offset_.DAT_song_id = 0x3b0;
|
{
|
||||||
|
offset_.DAT_song_titlel = 0x00;
|
||||||
|
offset_.DAT_song_artistl = 0xc0;
|
||||||
|
offset_.DAT_song_id = 0x1c8;
|
||||||
|
offset_.is_lstr_wchar = false;
|
||||||
|
snd_bank::resampler_ = avcodec::bmswac_resampler_s16_ad;
|
||||||
|
}
|
||||||
|
else if (extl < 2024082700)
|
||||||
|
{
|
||||||
|
offset_.DAT_song_titlel = 0x00;
|
||||||
|
offset_.DAT_song_artistl = 0xc0;
|
||||||
|
offset_.DAT_song_id = 0x3b0;
|
||||||
|
offset_.is_lstr_wchar = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
offset_.DAT_song_titlel = 0x00;
|
||||||
|
offset_.DAT_song_artistl = 0x1c0;
|
||||||
|
offset_.DAT_song_id = 0x67c;
|
||||||
|
offset_.is_lstr_wchar = true;
|
||||||
|
}
|
||||||
switch (offset_t::by_ext(ext))
|
switch (offset_t::by_ext(ext))
|
||||||
{
|
{
|
||||||
case offset_t::by_ext("2018091900"):
|
case offset_t::by_ext("2018091900"):
|
||||||
offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + 0x1170b0;
|
offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + 0x1170b0;
|
||||||
offset_.DAT_song_id = 0x1C8;
|
|
||||||
snd_bank::resampler_ = avcodec::bmswac_resampler_s16_ad;
|
|
||||||
break;
|
break;
|
||||||
case offset_t::by_ext("2019090200"):
|
case offset_t::by_ext("2019090200"):
|
||||||
case offset_t::by_ext("2019100700"):
|
case offset_t::by_ext("2019100700"):
|
||||||
offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + 0x37a540;
|
offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + 0x37a540;
|
||||||
offset_.DAT_song_id = 0x1C8;
|
|
||||||
snd_bank::resampler_ = avcodec::bmswac_resampler_s16_ad;
|
|
||||||
break;
|
break;
|
||||||
case offset_t::by_ext("2020092900"):
|
case offset_t::by_ext("2020092900"):
|
||||||
offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + 0x5ac460;
|
offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + 0x5ac460;
|
||||||
@@ -909,10 +936,11 @@ void init(HINSTANCE hmodule, const char *ext)
|
|||||||
case offset_t::by_ext("2024082600"):
|
case offset_t::by_ext("2024082600"):
|
||||||
offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + 0x8eae40;
|
offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + 0x8eae40;
|
||||||
break;
|
break;
|
||||||
|
case offset_t::by_ext("2025082500"):
|
||||||
|
offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + 0x969fb0;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + (int64_t) avcodec::BmswEnumValidSoundbanksAddr();
|
offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + (int64_t) avcodec::BmswEnumValidSoundbanksAddr();
|
||||||
offset_.DAT_song_id = strtol(ext, nullptr, 10) < 2019100800 ? 0x1C8 : offset_.DAT_song_id;
|
|
||||||
snd_bank::resampler_ = strtol(ext, nullptr, 10) < 2019100800 ? avcodec::bmswac_resampler_s16_ad : snd_bank::resampler_;
|
|
||||||
if (offset_.TX_BmsbEnumValidSoundbanks == (intptr_t) hmodule)
|
if (offset_.TX_BmsbEnumValidSoundbanks == (intptr_t) hmodule)
|
||||||
{
|
{
|
||||||
log_warning("hooks::soundbank", "Unsupported game version({}), skipping..", ext);
|
log_warning("hooks::soundbank", "Unsupported game version({}), skipping..", ext);
|
||||||
|
|||||||
Reference in New Issue
Block a user