feat: added more ps2 libs to analyze

fix: fix some cast on code gen
This commit is contained in:
Ran-j
2025-11-29 03:09:49 -03:00
parent 3a0cea3286
commit a311b73bf7
2 changed files with 35 additions and 11 deletions
+27 -3
View File
@@ -224,7 +224,11 @@ namespace ps2recomp
// Misc
"qsort", "bsearch", "abs", "div", "labs", "ldiv", "llabs", "lldiv",
"isalnum", "isalpha", "isdigit", "islower", "isupper", "isspace", "tolower", "toupper",
"setjmp", "longjmp", "getenv", "setenv", "unsetenv"};
"setjmp", "longjmp", "getenv", "setenv", "unsetenv",
"perror", "fputc", "getc", "ungetc", "freopen", "setvbuf", "setbuf",
// Extra string helpers
"strnlen", "strspn", "strcspn", "strcasecmp", "strncasecmp"};
// PS2-specific system functions
const std::vector<std::string> ps2SysFuncs = {
@@ -237,6 +241,8 @@ namespace ps2recomp
"CreateThread", "DeleteThread", "StartThread", "SuspendThread", "ResumeThread",
"GetThreadStatus", "ReferThreadStatus", "iWakeupThread", "iResumeThread",
"TerminateThread", "EnableIntc", "DisableIntc", "EnableDmac", "DisableDmac",
"ExitDeleteThread", "ExitHandler", "ExecOSD", "ExecPS2Patch", "EnableCache",
"EndOfHeap", "ExpandScratchPad",
// SIF
"SifInitRpc", "SifExitRpc", "SifBindRpc", "SifCallRpc", "SifRegisterRpc",
@@ -245,6 +251,7 @@ namespace ps2recomp
"sceSifInitCmd", "sceSifExitCmd", "sceSifSetCmdBuffer", "SifDmaInit",
"SifSetDma", "SifSetDChain", "iSifSetDChain", "SifSetOneDma",
"sceSifDmaStat", "sceSifSetDmaIntr", "sceSifResetDmaIntr",
"sceSifWriteBackDCache",
// IOP
"PollSema", "WaitSema", "SignalSema", "iSignalSema", "CreateSema",
@@ -253,7 +260,19 @@ namespace ps2recomp
// Timer
"CreateAlarm", "iSetAlarm", "SetAlarm", "iReleaseAlarm", "ReleaseAlarm",
"USec2SysClock", "GetSystemTime", "SetSystemTime", "SysClock2USec"};
"USec2SysClock", "GetSystemTime", "SetSystemTime", "SysClock2USec",
// CD/DVD driver helpers
"cd_callback", "cmd_sem_init", "ncmd_prechk", "scmd_prechk",
"cdvd_exit", "fileXioInit", "fileXioExit", "fileXioOpen",
"fileXioClose", "fileXioRead", "fileXioWrite", "fileXioLseek",
"fileXioGetStat", "fileXioSetBlockMode",
// Interrupt / DMA handlers
"AddIntcHandler", "AddIntcHandler2", "RemoveIntcHandler", "RemoveIntcHandler2",
"AddDmacHandler", "AddDmacHandler2", "RemoveDmacHandler", "RemoveDmacHandler2",
"AddSbusIntcHandler", "RemoveSbusIntcHandler", "EnableIntcHandler", "EnableDmacHandler"
};
// PS2-specific library functions
const std::vector<std::string> ps2LibFuncs = {
@@ -291,7 +310,12 @@ namespace ps2recomp
"loadModules", "fioInit", "mcInit", "mtapInit", "padInit", "sioInit",
"ethPutIFAddr", "ethGetNetEther", "ethPutNetIFaddr", "ethGetHWaddr",
"ethUsrPkt_input", "ethIntrEnable", "ethSetupIF", "ethPutArpReq",
"ethPktToIF", "ethGetArpEntry", "ethAllocTxPacket", "ethFreeTxPacket"};
"ethPktToIF", "ethGetArpEntry", "ethAllocTxPacket", "ethFreeTxPacket",
"sio_puts", "sio_printf", "sio_getc",
// Extra audsrv helpers
"audsrv_quit", "audsrv_play_audio", "audsrv_stop_audio", "audsrv_wait_audio",
"audsrv_set_format"};
// Add new PS2-specific functions for more complete coverage
const std::vector<std::string> additionalPs2Funcs = {
+8 -8
View File
@@ -603,9 +603,9 @@ namespace ps2recomp
case OPCODE_SWC1:
return fmt::format("{{ float val = ctx->f[{}]; WRITE32(ADD32(GPR_U32(ctx, {}), {}), *(uint32_t*)&val); }}", inst.rt, inst.rs, inst.simmediate);
case OPCODE_LDC2: // was OPCODE_LQC2 need to check
return fmt::format("ctx->vu0_vf[{}] = (__m128)READ128(ADD32(GPR_U32(ctx, {}), {}));", inst.rt, inst.rs, inst.simmediate);
return fmt::format("ctx->vu0_vf[{}] = _mm_castsi128_ps(READ128(ADD32(GPR_U32(ctx, {}), {})));", inst.rt, inst.rs, inst.simmediate);
case OPCODE_SDC2: // was OPCODE_SQC2 need to check
return fmt::format("WRITE128(ADD32(GPR_U32(ctx, {}), {}), (__m128i)ctx->vu0_vf[{}]);", inst.rs, inst.simmediate, inst.rt);
return fmt::format("WRITE128(ADD32(GPR_U32(ctx, {}), {}), _mm_castps_si128(ctx->vu0_vf[{}]));", inst.rs, inst.simmediate, inst.rt);
case OPCODE_DADDI:
return fmt::format(
"{{ int64_t src = (int64_t)GPR_S64(ctx, {}); "
@@ -1481,7 +1481,7 @@ namespace ps2recomp
switch (format)
{
case COP2_QMFC2:
return fmt::format("SET_GPR_VEC(ctx, {}, (__m128i)ctx->vu0_vf[{}]);", rt, rd);
return fmt::format("SET_GPR_VEC(ctx, {}, _mm_castps_si128(ctx->vu0_vf[{}]));", rt, rd);
case COP2_CFC2:
{
switch (rd) // Control register number is in rd
@@ -1493,7 +1493,7 @@ namespace ps2recomp
case VU0_CR_VPU_STAT:
return fmt::format("SET_GPR_U32(ctx, {}, ctx->vu0_vpu_stat);", rt);
case VU0_CR_R:
return fmt::format("SET_GPR_VEC(ctx, {}, (__m128i)ctx->vu0_r);", rt);
return fmt::format("SET_GPR_VEC(ctx, {}, _mm_castps_si128(ctx->vu0_r));", rt);
case VU0_CR_I:
return fmt::format("SET_GPR_U32(ctx, {}, *(uint32_t*)&ctx->vu0_i);", rt);
case VU0_CR_CLIP:
@@ -1525,7 +1525,7 @@ namespace ps2recomp
case VU0_CR_FBRST4:
return fmt::format("SET_GPR_U32(ctx, {}, ctx->vu0_fbrst4);", rt);
case VU0_CR_ACC:
return fmt::format("SET_GPR_VEC(ctx, {}, (__m128i)ctx->vu0_acc);", rt);
return fmt::format("SET_GPR_VEC(ctx, {}, _mm_castps_si128(ctx->vu0_acc));", rt);
case VU0_CR_INFO: // I dd found on offical docs but ok
return fmt::format("SET_GPR_U32(ctx, {}, ctx->vu0_info);", rt);
case VU0_CR_CLIP2:
@@ -1543,7 +1543,7 @@ namespace ps2recomp
}
}
case COP2_QMTC2:
return fmt::format("ctx->vu0_vf[{}] = (__m128)GPR_VEC(ctx, {});", rd, rt);
return fmt::format("ctx->vu0_vf[{}] = _mm_castsi128_ps(GPR_VEC(ctx, {}));", rd, rt);
case COP2_CTC2:
{
switch (rd) // Control register number is in rd
@@ -1557,7 +1557,7 @@ namespace ps2recomp
case VU0_CR_CLIP:
return fmt::format("ctx->vu0_clip_flags = GPR_U32(ctx, {});", rt);
case VU0_CR_R:
return fmt::format("ctx->vu0_r = (__m128)GPR_VEC(ctx, {});", rt);
return fmt::format("ctx->vu0_r = _mm_castsi128_ps(GPR_VEC(ctx, {}));", rt);
case VU0_CR_I:
return fmt::format("ctx->vu0_i = *(float*)&GPR_U32(ctx, {});", rt);
case VU0_CR_TPC:
@@ -1587,7 +1587,7 @@ namespace ps2recomp
case VU0_CR_FBRST4:
return fmt::format("ctx->vu0_fbrst4 = GPR_U32(ctx, {});", rt);
case VU0_CR_ACC:
return fmt::format("ctx->vu0_acc = (__m128)GPR_VEC(ctx, {});", rt);
return fmt::format("ctx->vu0_acc = _mm_castsi128_ps(GPR_VEC(ctx, {}));", rt);
case VU0_CR_INFO:
return fmt::format("ctx->vu0_info = GPR_U32(ctx, {});", rt);
case VU0_CR_CLIP2: