diff --git a/build_vs2022_debug.bat b/build_vs2022_debug.bat new file mode 100644 index 0000000..e8d025f --- /dev/null +++ b/build_vs2022_debug.bat @@ -0,0 +1,6 @@ +mkdir build86 +cd build86 +cmake .. -G "Visual Studio 17 2022" -A "Win32" +cmake --build . --config Debug +cd .. +PAUSE \ No newline at end of file diff --git a/build_vs2022_release.bat b/build_vs2022_release.bat new file mode 100644 index 0000000..5b2f4b7 --- /dev/null +++ b/build_vs2022_release.bat @@ -0,0 +1,6 @@ +mkdir build86 +cd build86 +cmake .. -G "Visual Studio 17 2022" -A "Win32" +cmake --build . --config Release +cd .. +PAUSE \ No newline at end of file diff --git a/src/mods/AudioStutterFix.cpp b/src/mods/AudioStutterFix.cpp index 9e93137..6a5989a 100644 --- a/src/mods/AudioStutterFix.cpp +++ b/src/mods/AudioStutterFix.cpp @@ -199,6 +199,34 @@ void AudioStutterFix::on_draw_ui() { }; } #else +#include "sdk/VoxObj.hpp" + +struct Devil3BgmChannels { + // NOTE(): initialized in dmc3se.exe WinMain + VoxObj* channel[4]; + size_t num_channels; +}; +Devil3BgmChannels* game_snd_channels{ nullptr }; +FunctionHook* cCustomize_hack{ nullptr }; // cCustomize screen doesnt stop the bgm for some reason +uintptr_t c_cusomize_return = 0x00444190; // dmc3se.exe+44190 - 85 F6 - test esi,esi + +static void stop_sound() { + if (!game_snd_channels) { return; } + /*for (size_t i = 0; i < game_snd_channels->num_channels; i++) { + + }*/ + game_snd_channels->channel[0]->pause(); +} + +__declspec(naked) void c_cusomize_detour() { + __asm { + pushad + call stop_sound + popad + push 0000017Ah + jmp DWORD PTR [c_cusomize_return] + } +} std::optional AudioStutterFix::on_initialize() { @@ -229,6 +257,10 @@ std::optional AudioStutterFix::on_initialize() { m_disable_sleep1 = new Patch(0x00404987, bytes, true); m_disable_sleep2 = new Patch(0x00404998, bytes, true); + game_snd_channels = (Devil3BgmChannels*)0x0832DBC; + cCustomize_hack = new FunctionHook(0x0044418B, &c_cusomize_detour); + cCustomize_hack->create(); + return Mod::on_initialize(); }