mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-26 20:31:41 +00:00
audio_patches: implemented Music and SE volume
This commit is contained in:
parent
ac28db9480
commit
6d6c4fad1f
7 changed files with 56 additions and 19 deletions
|
|
@ -66,7 +66,7 @@ set(SWA_HID_CXX_SOURCES
|
|||
|
||||
set(SWA_PATCHES_CXX_SOURCES
|
||||
"patches/ui/CHudPause_patches.cpp"
|
||||
"patches/ui/CTitleMenu_patches.cpp"
|
||||
"patches/ui/CTitleStateMenu_patches.cpp"
|
||||
"patches/ui/frontend_listener.cpp"
|
||||
"patches/audio_patches.cpp"
|
||||
"patches/camera_patches.cpp"
|
||||
|
|
@ -84,6 +84,7 @@ set(SWA_UI_CXX_SOURCES
|
|||
)
|
||||
|
||||
set(SWA_CXX_SOURCES
|
||||
"app.cpp"
|
||||
"exports.cpp"
|
||||
"main.cpp"
|
||||
"misc_impl.cpp"
|
||||
|
|
|
|||
21
UnleashedRecomp/app.cpp
Normal file
21
UnleashedRecomp/app.cpp
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#include <kernel/function.h>
|
||||
#include <ui/window.h>
|
||||
#include <app.h>
|
||||
#include <patches/audio_patches.h>
|
||||
|
||||
double g_deltaTime;
|
||||
|
||||
// CApplication::Update
|
||||
PPC_FUNC_IMPL(__imp__sub_822C1130);
|
||||
PPC_FUNC(sub_822C1130)
|
||||
{
|
||||
g_deltaTime = ctx.f1.f64;
|
||||
|
||||
SDL_PumpEvents();
|
||||
SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT);
|
||||
|
||||
Window::Update();
|
||||
audio_patches::Update(g_deltaTime);
|
||||
|
||||
__imp__sub_822C1130(ctx, base);
|
||||
}
|
||||
3
UnleashedRecomp/app.h
Normal file
3
UnleashedRecomp/app.h
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#pragma once
|
||||
|
||||
extern double g_deltaTime;
|
||||
|
|
@ -1,12 +1,30 @@
|
|||
#include <cpu/guest_code.h>
|
||||
#include <cfg/config.h>
|
||||
#include <kernel/function.h>
|
||||
#include <patches/audio_patches.h>
|
||||
|
||||
PPC_FUNC_IMPL(__imp__sub_82B4E130);
|
||||
PPC_FUNC(sub_82B4E130)
|
||||
be<float>* GetVolume(bool isMusic = true)
|
||||
{
|
||||
auto pMusicVolume = (be<float>*)g_memory.Translate(ctx.r3.u32);
|
||||
auto ppUnkClass = (be<uint32_t>*)g_memory.Translate(0x83362FFC);
|
||||
|
||||
*pMusicVolume = Config::MusicVolume;
|
||||
if (!ppUnkClass->get())
|
||||
return nullptr;
|
||||
|
||||
__imp__sub_82B4E130(ctx, base);
|
||||
// NOTE (Hyper): This is fine, trust me. See 0x82E58728.
|
||||
return (be<float>*)g_memory.Translate(4 * ((int)isMusic + 0x1C) + ((be<uint32_t>*)g_memory.Translate(ppUnkClass->get() + 4))->get());
|
||||
}
|
||||
|
||||
void audio_patches::Update(float deltaTime)
|
||||
{
|
||||
auto pMusicVolume = GetVolume();
|
||||
auto pSEVolume = GetVolume(false);
|
||||
|
||||
if (!pMusicVolume || !pSEVolume)
|
||||
return;
|
||||
|
||||
*pSEVolume = Config::SEVolume;
|
||||
*pMusicVolume = Config::MusicVolume;
|
||||
}
|
||||
|
||||
// Stub volume setter.
|
||||
GUEST_FUNCTION_STUB(sub_82E58728);
|
||||
|
|
|
|||
7
UnleashedRecomp/patches/audio_patches.h
Normal file
7
UnleashedRecomp/patches/audio_patches.h
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
class audio_patches
|
||||
{
|
||||
public:
|
||||
static void Update(float deltaTime);
|
||||
};
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
#include "window.h"
|
||||
#include "sdl_listener.h"
|
||||
#include <cfg/config.h>
|
||||
#include <kernel/function.h>
|
||||
#include <SDL_syswm.h>
|
||||
|
||||
bool m_isFullscreenKeyReleased = true;
|
||||
|
|
@ -175,15 +174,3 @@ void Window::Update()
|
|||
Config::WindowHeight = Window::s_height;
|
||||
}
|
||||
}
|
||||
|
||||
// CApplication::Update
|
||||
PPC_FUNC_IMPL(__imp__sub_822C1130);
|
||||
PPC_FUNC(sub_822C1130)
|
||||
{
|
||||
SDL_PumpEvents();
|
||||
SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT);
|
||||
|
||||
Window::Update();
|
||||
|
||||
__imp__sub_822C1130(ctx, base);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue