Merge pull request #215 from shadps4-emu/miscFixAgain
Misc fixes (mostly LLE)
This commit is contained in:
commit
3532fd1c9c
|
@ -145,4 +145,13 @@ bool SDLAudio::AudioOutSetVolume(s32 handle, s32 bitflag, s32* volume) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool SDLAudio::AudioOutGetStatus(s32 handle, int* type, int* channels_num) {
|
||||
std::scoped_lock lock{m_mutex};
|
||||
auto& port = portsOut[handle - 1];
|
||||
*type = port.type;
|
||||
*channels_num = port.channels_num;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Audio
|
||||
|
|
|
@ -18,6 +18,7 @@ public:
|
|||
Libraries::AudioOut::OrbisAudioOutParam format);
|
||||
s32 AudioOutOutput(s32 handle, const void* ptr);
|
||||
bool AudioOutSetVolume(s32 handle, s32 bitflag, s32* volume);
|
||||
bool AudioOutGetStatus(s32 handle, int* type, int* channels_num);
|
||||
|
||||
private:
|
||||
struct PortOut {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <memory>
|
||||
#include <common/assert.h>
|
||||
#include <magic_enum.hpp>
|
||||
#include "audio_core/sdl_audio.h"
|
||||
#include "common/logging/log.h"
|
||||
|
@ -160,8 +161,38 @@ int PS4_SYSV_ABI sceAudioOutGetLastOutputTime() {
|
|||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceAudioOutGetPortState() {
|
||||
LOG_ERROR(Lib_AudioOut, "(STUBBED) called");
|
||||
int PS4_SYSV_ABI sceAudioOutGetPortState(s32 handle, OrbisAudioOutPortState* state) {
|
||||
|
||||
int type = 0;
|
||||
int channels_num = 0;
|
||||
|
||||
if (!audio->AudioOutGetStatus(handle, &type, &channels_num)) {
|
||||
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
|
||||
}
|
||||
|
||||
state->rerouteCounter = 0;
|
||||
state->volume = 127; // max volume
|
||||
|
||||
switch (type) {
|
||||
case ORBIS_AUDIO_OUT_PORT_TYPE_MAIN:
|
||||
case ORBIS_AUDIO_OUT_PORT_TYPE_BGM:
|
||||
case ORBIS_AUDIO_OUT_PORT_TYPE_VOICE:
|
||||
state->output = 1;
|
||||
state->channel = (channels_num > 2 ? 2 : channels_num);
|
||||
break;
|
||||
case ORBIS_AUDIO_OUT_PORT_TYPE_PERSONAL:
|
||||
case ORBIS_AUDIO_OUT_PORT_TYPE_PADSPK:
|
||||
state->output = 4;
|
||||
state->channel = 1;
|
||||
break;
|
||||
case ORBIS_AUDIO_OUT_PORT_TYPE_AUX:
|
||||
state->output = 0;
|
||||
state->channel = 0;
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,16 @@ struct OrbisAudioOutOutputParam {
|
|||
const void* ptr;
|
||||
};
|
||||
|
||||
struct OrbisAudioOutPortState {
|
||||
u16 output;
|
||||
u8 channel;
|
||||
u8 reserved8_1[1];
|
||||
s16 volume;
|
||||
u16 rerouteCounter;
|
||||
u64 flag;
|
||||
u64 reserved64[2];
|
||||
};
|
||||
|
||||
int PS4_SYSV_ABI sceAudioOutDeviceIdOpen();
|
||||
int PS4_SYSV_ABI sceAudioDeviceControlGet();
|
||||
int PS4_SYSV_ABI sceAudioDeviceControlSet();
|
||||
|
@ -55,7 +65,7 @@ int PS4_SYSV_ABI sceAudioOutGetHandleStatusInfo();
|
|||
int PS4_SYSV_ABI sceAudioOutGetInfo();
|
||||
int PS4_SYSV_ABI sceAudioOutGetInfoOpenNum();
|
||||
int PS4_SYSV_ABI sceAudioOutGetLastOutputTime();
|
||||
int PS4_SYSV_ABI sceAudioOutGetPortState();
|
||||
int PS4_SYSV_ABI sceAudioOutGetPortState(s32 handle, OrbisAudioOutPortState* state);
|
||||
int PS4_SYSV_ABI sceAudioOutGetSimulatedBusUsableStatusByBusType();
|
||||
int PS4_SYSV_ABI sceAudioOutGetSimulatedHandleStatusInfo();
|
||||
int PS4_SYSV_ABI sceAudioOutGetSimulatedHandleStatusInfo2();
|
||||
|
|
|
@ -105,7 +105,7 @@ int PS4_SYSV_ABI sceKernelOpen(const char* path, int flags, u16 mode) {
|
|||
}
|
||||
|
||||
int PS4_SYSV_ABI posix_open(const char* path, int flags, /* SceKernelMode*/ u16 mode) {
|
||||
LOG_INFO(Kernel_Fs, "posix open redirect to sceKernelOpen\n");
|
||||
LOG_INFO(Kernel_Fs, "posix open redirect to sceKernelOpen");
|
||||
int result = sceKernelOpen(path, flags, mode);
|
||||
// Posix calls different only for their return values
|
||||
ASSERT(result >= 0);
|
||||
|
|
|
@ -88,7 +88,7 @@ int PS4_SYSV_ABI sceKernelMmap(void* addr, u64 len, int prot, int flags, int fd,
|
|||
|
||||
void* PS4_SYSV_ABI posix_mmap(void* addr, u64 len, int prot, int flags, int fd, u64 offset) {
|
||||
void* ptr;
|
||||
LOG_INFO(Kernel_Vmm, "posix mmap redirect to sceKernelMmap\n");
|
||||
LOG_INFO(Kernel_Vmm, "posix mmap redirect to sceKernelMmap");
|
||||
// posix call the difference is that there is a different behaviour when it doesn't return 0 or
|
||||
// SCE_OK
|
||||
const VAddr ret_addr = (VAddr)__builtin_return_address(0);
|
||||
|
@ -288,9 +288,21 @@ int PS4_SYSV_ABI sceKernelUuidCreate(OrbisKernelUuid* orbisUuid) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
char* PS4_SYSV_ABI sceKernelGetFsSandboxRandomWord() {
|
||||
char* path = "sys";
|
||||
return path;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI posix_connect() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void LibKernel_Register(Core::Loader::SymbolsResolver* sym) {
|
||||
// obj
|
||||
LIB_OBJ("f7uOxY9mM1U", "libkernel", 1, "libkernel", 1, 1, &g_stack_chk_guard);
|
||||
// misc
|
||||
LIB_FUNCTION("JGfTMBOdUJo", "libkernel", 1, "libkernel", 1, 1, sceKernelGetFsSandboxRandomWord);
|
||||
LIB_FUNCTION("XVL8So3QJUk", "libkernel", 1, "libkernel", 1, 1, posix_connect);
|
||||
// memory
|
||||
LIB_FUNCTION("OMDRKKAZ8I4", "libkernel", 1, "libkernel", 1, 1, sceKernelDebugRaiseException);
|
||||
LIB_FUNCTION("rTXw65xmLIA", "libkernel", 1, "libkernel", 1, 1, sceKernelAllocateDirectMemory);
|
||||
|
|
|
@ -63,10 +63,7 @@ void InitHLELibs(Core::Loader::SymbolsResolver* sym) {
|
|||
Libraries::NpScore::RegisterlibSceNpScore(sym);
|
||||
Libraries::NpTrophy::RegisterlibSceNpTrophy(sym);
|
||||
Libraries::ScreenShot::RegisterlibSceScreenShot(sym);
|
||||
Libraries::LibcInternal::RegisterlibSceLibcInternal(sym);
|
||||
Libraries::AppContent::RegisterlibSceAppContent(sym);
|
||||
Libraries::Rtc::RegisterlibSceRtc(sym);
|
||||
Libraries::DiscMap::RegisterlibSceDiscMap(sym);
|
||||
Libraries::PngDec::RegisterlibScePngDec(sym);
|
||||
Libraries::PlayGo::RegisterlibScePlayGo(sym);
|
||||
Libraries::Usbd::RegisterlibSceUsbd(sym);
|
||||
|
|
|
@ -4,7 +4,10 @@
|
|||
#include <common/logging/log.h>
|
||||
#include <core/file_format/psf.h>
|
||||
#include <core/file_format/splash.h>
|
||||
#include <core/libraries/disc_map/disc_map.h>
|
||||
#include <core/libraries/libc/libc.h>
|
||||
#include <core/libraries/libc_internal/libc_internal.h>
|
||||
#include <core/libraries/rtc/rtc.h>
|
||||
#include <core/libraries/videoout/video_out.h>
|
||||
#include <fmt/core.h>
|
||||
#include "common/config.h"
|
||||
|
@ -136,12 +139,38 @@ void Emulator::Run(const std::filesystem::path& file) {
|
|||
}
|
||||
|
||||
void Emulator::LoadSystemModules(const std::filesystem::path& file) {
|
||||
|
||||
constexpr std::array<SysModules, 4> ModulesToLoad{
|
||||
{{"libSceNgs2.sprx", nullptr},
|
||||
{"libSceLibcInternal.sprx", &Libraries::LibcInternal::RegisterlibSceLibcInternal},
|
||||
{"libSceDiscMap.sprx", &Libraries::DiscMap::RegisterlibSceDiscMap},
|
||||
{"libSceRtc.sprx", &Libraries::Rtc::RegisterlibSceRtc}}};
|
||||
|
||||
std::vector<std::filesystem::path> found_modules;
|
||||
const auto& sys_module_path = Common::FS::GetUserPath(Common::FS::PathType::SysModuleDir);
|
||||
for (const auto& entry : std::filesystem::directory_iterator(sys_module_path)) {
|
||||
if (entry.path().filename() == "libSceNgs2.sprx" ||
|
||||
entry.path().filename() == "libSceLibcInternal.sprx") {
|
||||
LOG_INFO(Loader, "Loading {}", entry.path().string().c_str());
|
||||
linker->LoadModule(entry.path());
|
||||
found_modules.push_back(entry.path());
|
||||
}
|
||||
for (auto it : ModulesToLoad) {
|
||||
bool found = false;
|
||||
std::filesystem::path foundpath;
|
||||
for (auto f : found_modules) {
|
||||
if (f.filename().string() == it.module_name) {
|
||||
found = true;
|
||||
foundpath = f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
LOG_INFO(Loader, "Loading {}", foundpath.string().c_str());
|
||||
linker->LoadModule(foundpath);
|
||||
} else {
|
||||
if (it.callback != nullptr) {
|
||||
LOG_INFO(Loader, "Can't Load {} switching to HLE", it.module_name);
|
||||
it.callback(&linker->GetHLESymbols());
|
||||
} else {
|
||||
LOG_INFO(Loader, "No HLE available for {} module", it.module_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,13 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
using HLEInitDef = void (*)(Core::Loader::SymbolsResolver* sym);
|
||||
|
||||
struct SysModules {
|
||||
std::string_view module_name;
|
||||
HLEInitDef callback;
|
||||
};
|
||||
|
||||
class Emulator {
|
||||
public:
|
||||
Emulator();
|
||||
|
|
Loading…
Reference in New Issue