some minor improvements

This commit is contained in:
InoriRus
2022-01-31 17:25:13 +10:00
parent 8651c18423
commit 9a912716f8
27 changed files with 1792 additions and 199 deletions
+16
View File
@@ -0,0 +1,16 @@
#include "Emulator/Libs/Errno.h"
#ifdef KYTY_EMU_ENABLED
namespace Kyty::Libs::Posix {
static thread_local int g_errno = 0;
KYTY_SYSV_ABI int* GetErrorAddr()
{
return &g_errno;
}
} // namespace Kyty::Libs::Posix
#endif
+24 -2
View File
@@ -13,6 +13,13 @@ LIB_VERSION("DiscMap", 1, "DiscMap", 1, 1);
namespace DiscMap {
/*
DISC_MAP_ERROR_INVALID_ARGUMENT = 0x81100001;
DISC_MAP_ERROR_LOCATION_NOT_MAPPED = 0x81100002;
DISC_MAP_ERROR_FILE_NOT_FOUND = 0x81100003;
DISC_MAP_ERROR_NO_BITMAP_INFO = 0x81100004;
*/
static KYTY_SYSV_ABI int DiscMapIsRequestOnHDD(const char* file, uint64_t a2, uint64_t a3, const int* a4)
{
PRINT_NAME();
@@ -25,7 +32,21 @@ static KYTY_SYSV_ABI int DiscMapIsRequestOnHDD(const char* file, uint64_t a2, ui
return 0;
}
static KYTY_SYSV_ABI int Unknown(const char* file, uint64_t a2, uint64_t a3, const uint64_t* a4, const uint64_t* a5, const uint64_t* a6)
static KYTY_SYSV_ABI int Unknown1(const char* file, uint64_t a2, uint64_t a3, const uint64_t* a4, const uint64_t* a5, const uint64_t* a6)
{
PRINT_NAME();
printf("\tfile = %s\n", file);
printf("\ta2 = %016" PRIx64 "\n", a2);
printf("\ta3 = %016" PRIx64 "\n", a3);
printf("\t*a4 = %016" PRIx64 "\n", *a4);
printf("\t*a5 = %016" PRIx64 "\n", *a5);
printf("\t*a6 = %016" PRIx64 "\n", *a6);
return 0;
}
static KYTY_SYSV_ABI int Unknown2(const char* file, uint64_t a2, uint64_t a3, const uint64_t* a4, const uint64_t* a5, const uint64_t* a6)
{
PRINT_NAME();
@@ -44,7 +65,8 @@ static KYTY_SYSV_ABI int Unknown(const char* file, uint64_t a2, uint64_t a3, con
LIB_DEFINE(InitDiscMap_1)
{
LIB_FUNC("lbQKqsERhtE", DiscMap::DiscMapIsRequestOnHDD);
LIB_FUNC("fJgP+wqifno", DiscMap::Unknown);
LIB_FUNC("fJgP+wqifno", DiscMap::Unknown1);
LIB_FUNC("ioKMruft1ek", DiscMap::Unknown2);
}
} // namespace Kyty::Libs
@@ -14,7 +14,10 @@ LIB_DEFINE(InitGraphicsDriver_1)
PRINT_NAME_ENABLE(true);
LIB_FUNC("gAhCn6UiU4Y", Graphics::GraphicsSetVsShader);
LIB_FUNC("V31V01UiScY", Graphics::GraphicsUpdateVsShader);
LIB_FUNC("bQVd5YzCal0", Graphics::GraphicsSetPsShader);
LIB_FUNC("5uFKckiJYRM", Graphics::GraphicsSetPsShader350);
LIB_FUNC("4MgRw-bVNQU", Graphics::GraphicsUpdatePsShader);
LIB_FUNC("Kx-h-nWQJ8A", Graphics::GraphicsSetCsShaderWithModifier);
LIB_FUNC("HlTPoZ-oY7Y", Graphics::GraphicsDrawIndex);
LIB_FUNC("GGsn7jMTxw4", Graphics::GraphicsDrawIndexAuto);
@@ -25,6 +28,9 @@ LIB_DEFINE(InitGraphicsDriver_1)
LIB_FUNC("iBt3Oe00Kvc", Graphics::GraphicsFlushMemory);
LIB_FUNC("b0xyllnVY-I", Graphics::GraphicsAddEqEvent);
LIB_FUNC("PVT+fuoS9gU", Graphics::GraphicsDeleteEqEvent);
LIB_FUNC("Idffwf3yh8s", Graphics::GraphicsDrawInitDefaultHardwareState);
LIB_FUNC("QhnyReteJ1M", Graphics::GraphicsDrawInitDefaultHardwareState175);
LIB_FUNC("0H2vBYbTLHI", Graphics::GraphicsDrawInitDefaultHardwareState200);
LIB_FUNC("yb2cRhagD1I", Graphics::GraphicsDrawInitDefaultHardwareState350);
LIB_FUNC("nF6bFRUBRAU", Graphics::GraphicsDispatchInitDefaultHardwareState);
LIB_FUNC("1qXLHIpROPE", Graphics::GraphicsInsertWaitFlipDone);
@@ -39,6 +45,7 @@ LIB_DEFINE(InitGraphicsDriver_1)
LIB_FUNC("ZFqKFl23aMc", Graphics::GraphicsRegisterOwner);
LIB_FUNC("nvEwfYAImTs", Graphics::GraphicsRegisterResource);
LIB_FUNC("Fwvh++m9IQI", Graphics::GraphicsGetGpuCoreClockFrequency);
LIB_FUNC("jg33rEKLfVs", Graphics::GraphicsIsUserPaEnabled);
}
} // namespace Kyty::Libs
+32 -18
View File
@@ -11,6 +11,7 @@
#include "Emulator/Kernel/FileSystem.h"
#include "Emulator/Kernel/Memory.h"
#include "Emulator/Kernel/Pthread.h"
#include "Emulator/Kernel/Semaphore.h"
#include "Emulator/Libs/Errno.h"
#include "Emulator/Libs/Libs.h"
#include "Emulator/RuntimeLinker.h"
@@ -102,23 +103,16 @@ static const char* g_progname = g_progname_buf;
static get_thread_atexit_count_func_t g_get_thread_atexit_count_func = nullptr;
static thread_atexit_report_func_t g_thread_atexit_report_func = nullptr;
static thread_local int g_errno = 0;
void SetProgName(const String& name)
{
strncpy(g_progname_buf, name.C_Str(), PROGNAME_MAX_SIZE);
}
// struct KernelContext
//{
// Vector<Loader::Program*> programs;
//};
static KYTY_SYSV_ABI int* get_error_addr()
{
PRINT_NAME();
return &g_errno;
return Posix::GetErrorAddr();
}
static KYTY_SYSV_ABI void stack_chk_fail()
@@ -415,17 +409,22 @@ int KYTY_SYSV_ABI clock_gettime(int clock_id, LibKernel::KernelTimespec* time)
{
PRINT_NAME();
if (LibKernel::KernelClockGettime(clock_id, time) < 0)
{
return -1;
}
return 0;
return POSIX_CALL(LibKernel::KernelClockGettime(clock_id, time));
}
LIB_DEFINE(InitLibKernel_1_Posix)
{
LIB_FUNC("lLMT9vJAck0", clock_gettime);
LIB_FUNC("7H0iTOciTLo", Posix::pthread_mutex_lock);
LIB_FUNC("2Z+PpY6CaJg", Posix::pthread_mutex_unlock);
LIB_FUNC("ttHNfU+qDBU", Posix::pthread_mutex_init);
LIB_FUNC("ltCfaGr2JGE", Posix::pthread_mutex_destroy);
LIB_FUNC("mkx2fVhNMsg", Posix::pthread_cond_broadcast);
LIB_FUNC("Op8TBGY5KHg", Posix::pthread_cond_wait);
LIB_FUNC("mqULNdimTn0", Posix::pthread_key_create);
LIB_FUNC("6BpEZuDT7YI", Posix::pthread_key_delete);
LIB_FUNC("WrOLvHU0yQM", Posix::pthread_setspecific);
}
} // namespace Posix
@@ -434,6 +433,7 @@ namespace FileSystem = LibKernel::FileSystem;
namespace Memory = LibKernel::Memory;
namespace EventQueue = LibKernel::EventQueue;
namespace EventFlag = LibKernel::EventFlag;
namespace Semaphore = LibKernel::Semaphore;
LIB_DEFINE(InitLibKernel_1_FS)
{
@@ -459,6 +459,7 @@ LIB_DEFINE(InitLibKernel_1_Mem)
LIB_FUNC("L-Q3LEjIbgA", Memory::KernelMapDirectMemory);
LIB_FUNC("MBuItvba6z8", Memory::KernelReleaseDirectMemory);
LIB_FUNC("WFcfL2lzido", Memory::KernelQueryMemoryProtection);
LIB_FUNC("BHouLQzh0X0", Memory::KernelDirectMemoryQuery);
}
LIB_DEFINE(InitLibKernel_1_Equeue)
@@ -475,6 +476,14 @@ LIB_DEFINE(InitLibKernel_1_EventFlag)
LIB_FUNC("JTvBflhYazQ", EventFlag::KernelWaitEventFlag);
}
LIB_DEFINE(InitLibKernel_1_Semaphore)
{
LIB_FUNC("188x57JYp0g", Semaphore::KernelCreateSema);
LIB_FUNC("R1Jvn8bSCW8", Semaphore::KernelDeleteSema);
LIB_FUNC("Zxa0VhQVTsk", Semaphore::KernelWaitSema);
LIB_FUNC("4czppHBiriw", Semaphore::KernelSignalSema);
}
LIB_DEFINE(InitLibKernel_1_Pthread)
{
LIB_FUNC("9UK1vLZQft4", LibKernel::PthreadMutexLock);
@@ -493,6 +502,9 @@ LIB_DEFINE(InitLibKernel_1_Pthread)
LIB_FUNC("onNY9Byn-W8", LibKernel::PthreadJoin);
LIB_FUNC("4qGrR6eoP9Y", LibKernel::PthreadDetach);
LIB_FUNC("How7B8Oet6k", LibKernel::PthreadGetname);
LIB_FUNC("bt3CTBKmGyI", LibKernel::PthreadSetaffinity);
LIB_FUNC("1tKyG7RlMJo", LibKernel::PthreadGetprio);
LIB_FUNC("W0Hpm2X0uPE", LibKernel::PthreadSetprio);
LIB_FUNC("62KCwEMmzcM", LibKernel::PthreadAttrDestroy);
LIB_FUNC("x1X76arYMxU", LibKernel::PthreadAttrGet);
@@ -504,6 +516,7 @@ LIB_DEFINE(InitLibKernel_1_Pthread)
LIB_FUNC("eXbUSpEaTsA", LibKernel::PthreadAttrSetinheritsched);
LIB_FUNC("DzES9hQF4f4", LibKernel::PthreadAttrSetschedparam);
LIB_FUNC("4+h9EzwKF4I", LibKernel::PthreadAttrSetschedpolicy);
LIB_FUNC("3qxgM4ezETA", LibKernel::PthreadAttrSetaffinity);
LIB_FUNC("6ULAa0fq4jA", LibKernel::PthreadRwlockInit);
LIB_FUNC("BB+kb08Tl9A", LibKernel::PthreadRwlockDestroy);
@@ -522,10 +535,10 @@ LIB_DEFINE(InitLibKernel_1_Pthread)
LIB_FUNC("1j3S3n-tTW4", LibKernel::KernelGetTscFrequency);
LIB_FUNC("4J2sUJmuHZQ", LibKernel::KernelGetProcessTime);
LIB_FUNC("7H0iTOciTLo", LibKernel::pthread_mutex_lock_s);
LIB_FUNC("2Z+PpY6CaJg", LibKernel::pthread_mutex_unlock_s);
LIB_FUNC("mkx2fVhNMsg", LibKernel::pthread_cond_broadcast_s);
LIB_FUNC("Op8TBGY5KHg", LibKernel::pthread_cond_wait_s);
LIB_FUNC("7H0iTOciTLo", Posix::pthread_mutex_lock);
LIB_FUNC("2Z+PpY6CaJg", Posix::pthread_mutex_unlock);
LIB_FUNC("mkx2fVhNMsg", Posix::pthread_cond_broadcast);
LIB_FUNC("Op8TBGY5KHg", Posix::pthread_cond_wait);
}
LIB_DEFINE(InitLibKernel_1)
@@ -534,6 +547,7 @@ LIB_DEFINE(InitLibKernel_1)
InitLibKernel_1_Mem(s);
InitLibKernel_1_Equeue(s);
InitLibKernel_1_EventFlag(s);
InitLibKernel_1_Semaphore(s);
InitLibKernel_1_Pthread(s);
Posix::InitLibKernel_1_Posix(s);
@@ -0,0 +1,129 @@
#include "Kyty/Core/DbgAssert.h"
#include "Kyty/Core/String.h"
#include "Emulator/Common.h"
#include "Emulator/Libs/Errno.h"
#include "Emulator/Libs/Libs.h"
#include "Emulator/SymbolDatabase.h"
#ifdef KYTY_EMU_ENABLED
namespace Kyty::Libs {
LIB_VERSION("SystemService", 1, "SystemService", 1, 1);
namespace SystemService {
[[maybe_unused]] constexpr int PARAM_ID_LANG = 1;
[[maybe_unused]] constexpr int PARAM_ID_DATE_FORMAT = 2;
[[maybe_unused]] constexpr int PARAM_ID_TIME_FORMAT = 3;
[[maybe_unused]] constexpr int PARAM_ID_TIME_ZONE = 4;
[[maybe_unused]] constexpr int PARAM_ID_SUMMERTIME = 5;
[[maybe_unused]] constexpr int PARAM_ID_SYSTEM_NAME = 6;
[[maybe_unused]] constexpr int PARAM_ID_GAME_PARENTAL_LEVEL = 7;
[[maybe_unused]] constexpr int PARAM_ID_ENTER_BUTTON_ASSIGN = 1000;
[[maybe_unused]] constexpr int PARAM_LANG_JAPANESE = 0;
[[maybe_unused]] constexpr int PARAM_LANG_ENGLISH_US = 1;
[[maybe_unused]] constexpr int PARAM_LANG_FRENCH = 2;
[[maybe_unused]] constexpr int PARAM_LANG_SPANISH = 3;
[[maybe_unused]] constexpr int PARAM_LANG_GERMAN = 4;
[[maybe_unused]] constexpr int PARAM_LANG_ITALIAN = 5;
[[maybe_unused]] constexpr int PARAM_LANG_DUTCH = 6;
[[maybe_unused]] constexpr int PARAM_LANG_PORTUGUESE_PT = 7;
[[maybe_unused]] constexpr int PARAM_LANG_RUSSIAN = 8;
[[maybe_unused]] constexpr int PARAM_LANG_KOREAN = 9;
[[maybe_unused]] constexpr int PARAM_LANG_CHINESE_T = 10;
[[maybe_unused]] constexpr int PARAM_LANG_CHINESE_S = 11;
[[maybe_unused]] constexpr int PARAM_LANG_FINNISH = 12;
[[maybe_unused]] constexpr int PARAM_LANG_SWEDISH = 13;
[[maybe_unused]] constexpr int PARAM_LANG_DANISH = 14;
[[maybe_unused]] constexpr int PARAM_LANG_NORWEGIAN = 15;
[[maybe_unused]] constexpr int PARAM_LANG_POLISH = 16;
[[maybe_unused]] constexpr int PARAM_LANG_PORTUGUESE_BR = 17;
[[maybe_unused]] constexpr int PARAM_LANG_ENGLISH_GB = 18;
[[maybe_unused]] constexpr int PARAM_LANG_TURKISH = 19;
[[maybe_unused]] constexpr int PARAM_LANG_SPANISH_LA = 20;
[[maybe_unused]] constexpr int PARAM_LANG_ARABIC = 21;
[[maybe_unused]] constexpr int PARAM_LANG_FRENCH_CA = 22;
[[maybe_unused]] constexpr int PARAM_LANG_CZECH = 23;
[[maybe_unused]] constexpr int PARAM_LANG_HUNGARIAN = 24;
[[maybe_unused]] constexpr int PARAM_LANG_GREEK = 25;
[[maybe_unused]] constexpr int PARAM_LANG_ROMANIAN = 26;
[[maybe_unused]] constexpr int PARAM_LANG_THAI = 27;
[[maybe_unused]] constexpr int PARAM_LANG_VIETNAMESE = 28;
[[maybe_unused]] constexpr int PARAM_LANG_INDONESIAN = 29;
[[maybe_unused]] constexpr int PARAM_DATE_FORMAT_YYYYMMDD = 0;
[[maybe_unused]] constexpr int PARAM_DATE_FORMAT_DDMMYYYY = 1;
[[maybe_unused]] constexpr int PARAM_DATE_FORMAT_MMDDYYYY = 2;
[[maybe_unused]] constexpr int PARAM_TIME_FORMAT_12HOUR = 0;
[[maybe_unused]] constexpr int PARAM_TIME_FORMAT_24HOUR = 1;
[[maybe_unused]] constexpr int MAX_SYSTEM_NAME_LENGTH = 65;
[[maybe_unused]] constexpr int PARAM_GAME_PARENTAL_OFF = 0;
[[maybe_unused]] constexpr int PARAM_GAME_PARENTAL_LEVEL01 = 1;
[[maybe_unused]] constexpr int PARAM_GAME_PARENTAL_LEVEL02 = 2;
[[maybe_unused]] constexpr int PARAM_GAME_PARENTAL_LEVEL03 = 3;
[[maybe_unused]] constexpr int PARAM_GAME_PARENTAL_LEVEL04 = 4;
[[maybe_unused]] constexpr int PARAM_GAME_PARENTAL_LEVEL05 = 5;
[[maybe_unused]] constexpr int PARAM_GAME_PARENTAL_LEVEL06 = 6;
[[maybe_unused]] constexpr int PARAM_GAME_PARENTAL_LEVEL07 = 7;
[[maybe_unused]] constexpr int PARAM_GAME_PARENTAL_LEVEL08 = 8;
[[maybe_unused]] constexpr int PARAM_GAME_PARENTAL_LEVEL09 = 9;
[[maybe_unused]] constexpr int PARAM_GAME_PARENTAL_LEVEL10 = 10;
[[maybe_unused]] constexpr int PARAM_GAME_PARENTAL_LEVEL11 = 11;
[[maybe_unused]] constexpr int PARAM_ENTER_BUTTON_ASSIGN_CIRCLE = 0;
[[maybe_unused]] constexpr int PARAM_ENTER_BUTTON_ASSIGN_CROSS = 1;
static int KYTY_SYSV_ABI SystemServiceHideSplashScreen()
{
PRINT_NAME();
return OK;
}
static int KYTY_SYSV_ABI SystemServiceParamGetInt(int param_id, int* value)
{
PRINT_NAME();
if (value == nullptr)
{
return SYSTEM_SERVICE_ERROR_PARAMETER;
}
int v = 0;
switch (param_id)
{
case PARAM_ID_LANG: v = PARAM_LANG_RUSSIAN; break;
case PARAM_ID_DATE_FORMAT: v = PARAM_DATE_FORMAT_DDMMYYYY; break;
case PARAM_ID_TIME_FORMAT: v = PARAM_TIME_FORMAT_24HOUR; break;
case PARAM_ID_TIME_ZONE: v = +180; break;
case PARAM_ID_SUMMERTIME: v = 0; break;
case PARAM_ID_GAME_PARENTAL_LEVEL: v = PARAM_GAME_PARENTAL_OFF; break;
case PARAM_ID_ENTER_BUTTON_ASSIGN: v = PARAM_ENTER_BUTTON_ASSIGN_CROSS; break;
default: EXIT("unknown param_id: %d\n", param_id);
}
printf(" %d = %d\n", param_id, v);
*value = v;
return OK;
}
} // namespace SystemService
LIB_DEFINE(InitSystemService_1)
{
LIB_FUNC("Vo5V8KAwCmk", SystemService::SystemServiceHideSplashScreen);
LIB_FUNC("fZo48un7LK4", SystemService::SystemServiceParamGetInt);
}
} // namespace Kyty::Libs
#endif // KYTY_EMU_ENABLED
+2
View File
@@ -15,6 +15,7 @@ LIB_DEFINE(InitSysmodule_1);
LIB_DEFINE(InitDiscMap_1);
LIB_DEFINE(InitDebug_1);
LIB_DEFINE(InitGraphicsDriver_1);
LIB_DEFINE(InitSystemService_1);
LIB_DEFINE(InitUserService_1);
LIB_DEFINE(InitPad_1);
@@ -29,6 +30,7 @@ bool Init(const String& id, Loader::SymbolDatabase* s)
LIB_CHECK(U"libDebug_1", InitDebug_1);
LIB_CHECK(U"libGraphicsDriver_1", InitGraphicsDriver_1);
LIB_CHECK(U"libUserService_1", InitUserService_1);
LIB_CHECK(U"libSystemService_1", InitSystemService_1);
LIB_CHECK(U"libPad_1", InitPad_1);
return false;