Compare commits

...

4 Commits

Author SHA1 Message Date
Brad Smith b7202e287c
Merge 021e0dde7d into f65465b96c 2025-01-17 17:28:15 -05:00
JMC47 f65465b96c
Merge pull request #13250 from Charlese2/fix-sound-system-crash
GameINI: fix `Summoner: Goddess Reborn` sound system crash during transitions
2025-01-17 16:42:21 -05:00
Brad Smith 021e0dde7d ArmCPUDetect: Add OpenBSD support for elf_aux_info 2024-12-30 09:11:29 -05:00
Charlese2 635f588690 fix `Summoner: Goddess Reborn` sound system crash during transitions 2024-12-27 18:33:54 -07:00
3 changed files with 67 additions and 8 deletions

View File

@ -1,7 +1,48 @@
# GS2E78 - Summoner 2
[OnFrame]
# Add memory patches to be applied every frame here.
# This game will reinitialize the sound system buffers during transitions while
# sounds are still being played. There are still pointers in the sound list to
# sounds in those buffers when the buffers get cleared, so the game crashes with
# a null pointer dereference.
#
# This patch will clean up the pending sound list during sound system
# reinitialization before continuing to the sound system initialization call
# previously at 0x8017E338.
$Fix Sound System Crash
0x8017E338:dword:0x480954C9
0x80213800:dword:0x9421FFE0
0x80213804:dword:0x7C0802A6
0x80213808:dword:0x90010024
0x8021380C:dword:0x93E1001C
0x80213810:dword:0x93C10018
0x80213814:dword:0x93A10014
0x80213818:dword:0x7C7D1B78
0x8021381C:dword:0x4BF7A7D1
0x80213820:dword:0x83CDA0C0
0x80213824:dword:0x7C7F1B78
0x80213828:dword:0x48000010
0x8021382C:dword:0x807E0008
0x80213830:dword:0x4BF8C721
0x80213834:dword:0x83DE0000
0x80213838:dword:0x281E0000
0x8021383C:dword:0x4082FFF0
0x80213840:dword:0x38000000
0x80213844:dword:0x7FE3FB78
0x80213848:dword:0x900DA0C0
0x8021384C:dword:0x4BF7A7C9
0x80213850:dword:0x7FA3EB78
0x80213854:dword:0x4BF6A49D
0x80213858:dword:0x80010024
0x8021385C:dword:0x83E1001C
0x80213860:dword:0x83C10018
0x80213864:dword:0x83A10014
0x80213868:dword:0x7C0803A6
0x8021386C:dword:0x38210020
0x80213870:dword:0x4E800020
[OnFrame_Enabled]
$Fix Sound System Crash
[ActionReplay]
# Add action replay cheats here.

View File

@ -68,6 +68,11 @@ endif()
add_definitions(-D__STDC_LIMIT_MACROS)
add_definitions(-D__STDC_CONSTANT_MACROS)
check_symbol_exists(elf_aux_info sys/auxv.h HAVE_ELF_AUX_INFO)
if(HAVE_ELF_AUX_INFO)
add_definitions(-DHAVE_ELF_AUX_INFO)
endif()
add_subdirectory(Core)
if (ANDROID)
add_subdirectory(Android/jni)

View File

@ -18,13 +18,16 @@
#elif defined(__linux__)
#include <asm/hwcap.h>
#include <sys/auxv.h>
#elif defined(__FreeBSD__)
#elif defined(HAVE_ELF_AUX_INFO)
#include <sys/auxv.h>
#elif defined(__OpenBSD__)
#include <machine/armreg.h>
#include <machine/cpu.h>
#include <sys/sysctl.h>
#endif
#ifdef __OpenBSD__
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
#include <fmt/format.h>
@ -142,13 +145,13 @@ static bool Read_MIDR_EL1_Sysfs(u64* value)
#endif
#if defined(__linux__) || defined(__FreeBSD__)
#if defined(__linux__) || defined(HAVE_ELF_AUX_INFO)
static u32 ReadHwCap(u32 type)
{
#if defined(__linux__)
return getauxval(type);
#elif defined(__FreeBSD__)
#elif defined(HAVE_ELF_AUX_INFO)
u_long hwcap = 0;
elf_aux_info(type, &hwcap, sizeof(hwcap));
return hwcap;
@ -189,7 +192,7 @@ static bool Read_MIDR_EL1(u64* value)
#endif
#if defined(_WIN32) || defined(__linux__) || defined(__FreeBSD__)
#if defined(_WIN32) || defined(__linux__) || defined(HAVE_ELF_AUX_INFO)
static std::string MIDRToString(u64 midr)
{
@ -254,11 +257,21 @@ void CPUInfo::Detect()
{
cpu_id = MIDRToString(reg);
}
#elif defined(__linux__) || defined(__FreeBSD__)
// Linux, Android, and FreeBSD
#elif defined(__linux__) || defined(HAVE_ELF_AUX_INFO)
// Linux, Android, FreeBSD and OpenBSD with elf_aux_info
#if defined(__FreeBSD__)
SysctlByName(&model_name, "hw.model");
#elif defined(__OpenBSD__)
int mib[2];
size_t len;
char hwmodel[256];
mib[0] = CTL_HW;
mib[1] = HW_MODEL;
len = std::size(hwmodel);
if (sysctl(mib, 2, &hwmodel, &len, nullptr, 0) != -1)
model_name = std::string(hwmodel, len - 1);
#elif defined(__linux__)
if (!ReadDeviceTree(&model_name, "model"))
{