diff --git a/ps2xRecomp/src/lib/elf_parser.cpp b/ps2xRecomp/src/lib/elf_parser.cpp index 193a521..a2cd126 100644 --- a/ps2xRecomp/src/lib/elf_parser.cpp +++ b/ps2xRecomp/src/lib/elf_parser.cpp @@ -14,7 +14,7 @@ #else #include #endif - +#include "libdwarf_private.h" #include #include #include diff --git a/ps2xRuntime/include/ps2_runtime.h b/ps2xRuntime/include/ps2_runtime.h index cd16608..db73007 100644 --- a/ps2xRuntime/include/ps2_runtime.h +++ b/ps2xRuntime/include/ps2_runtime.h @@ -7,6 +7,7 @@ #include #include #include // For SSE/AVX instructions +#include #include #include #include @@ -225,8 +226,10 @@ struct alignas(16) R5900Context for (int i = 0; i < 32; ++i) { std::cout << "R" << std::setw(2) << std::dec << i << ": 0x" << std::hex - << std::setw(8) << r[i].m128i_u32[3] << std::setw(8) << r[i].m128i_u32[2] << "_" - << std::setw(8) << r[i].m128i_u32[1] << std::setw(8) << r[i].m128i_u32[0] << "\n"; + << std::setw(8) << static_cast(_mm_extract_epi32(r[i], 3)) + << std::setw(8) << static_cast(_mm_extract_epi32(r[i], 2)) << "_" + << std::setw(8) << static_cast(_mm_extract_epi32(r[i], 1)) + << std::setw(8) << static_cast(_mm_extract_epi32(r[i], 0)) << "\n"; } std::cout << "Status: 0x" << std::setw(8) << cop0_status << " Cause: 0x" << std::setw(8) << cop0_cause @@ -243,7 +246,7 @@ inline uint32_t getRegU32(const R5900Context *ctx, int reg) // Check if reg is valid (0-31) if (reg < 0 || reg > 31) return 0; - return ctx->r[reg].m128i_u32[0]; + return static_cast(_mm_extract_epi32(ctx->r[reg], 0)); } inline void setReturnU32(R5900Context *ctx, uint32_t value) diff --git a/ps2xRuntime/include/ps2_runtime_macros.h b/ps2xRuntime/include/ps2_runtime_macros.h index fd5f828..1576f1f 100644 --- a/ps2xRuntime/include/ps2_runtime_macros.h +++ b/ps2xRuntime/include/ps2_runtime_macros.h @@ -1,8 +1,11 @@ #ifndef PS2_RUNTIME_MACROS_H #define PS2_RUNTIME_MACROS_H #include -#include // For SSE/AVX intrinsics -#include +#if defined(_MSC_VER) + #include +#else + #include // For SSE/AVX intrinsics +#endif inline uint32_t ps2_clz32(uint32_t val) { #if defined(_MSC_VER) unsigned long idx; @@ -207,10 +210,10 @@ inline __m128i _mm_custom_srav_epi32(__m128i a, __m128i count) { #define PS2_VCALLMS(addr) // VU0 microprogram calls not supported directly #define PS2_VCALLMSR(reg) // VU0 microprogram calls not supported directly -#define GPR_U32(ctx_ptr, reg_idx) ((reg_idx == 0) ? 0U : ctx_ptr->r[reg_idx].m128i_u32[0]) -#define GPR_S32(ctx_ptr, reg_idx) ((reg_idx == 0) ? 0 : ctx_ptr->r[reg_idx].m128i_i32[0]) -#define GPR_U64(ctx_ptr, reg_idx) ((reg_idx == 0) ? 0ULL : ctx_ptr->r[reg_idx].m128i_u64[0]) -#define GPR_S64(ctx_ptr, reg_idx) ((reg_idx == 0) ? 0LL : ctx_ptr->r[reg_idx].m128i_i64[0]) +#define GPR_U32(ctx_ptr, reg_idx) ((reg_idx == 0) ? 0U : static_cast(_mm_extract_epi32(ctx_ptr->r[reg_idx], 0))) +#define GPR_S32(ctx_ptr, reg_idx) ((reg_idx == 0) ? 0 : _mm_extract_epi32(ctx_ptr->r[reg_idx], 0)) +#define GPR_U64(ctx_ptr, reg_idx) ((reg_idx == 0) ? 0ULL : static_cast(_mm_extract_epi64(ctx_ptr->r[reg_idx], 0))) +#define GPR_S64(ctx_ptr, reg_idx) ((reg_idx == 0) ? 0LL : _mm_extract_epi64(ctx_ptr->r[reg_idx], 0)) #define GPR_VEC(ctx_ptr, reg_idx) ((reg_idx == 0) ? _mm_setzero_si128() : ctx_ptr->r[reg_idx]) #define SET_GPR_U32(ctx_ptr, reg_idx, val) \ diff --git a/ps2xRuntime/src/lib/ps2_runtime.cpp b/ps2xRuntime/src/lib/ps2_runtime.cpp index cd82a87..425d069 100644 --- a/ps2xRuntime/src/lib/ps2_runtime.cpp +++ b/ps2xRuntime/src/lib/ps2_runtime.cpp @@ -331,7 +331,7 @@ void PS2Runtime::executeVU0Microprogram(uint8_t *rdram, R5900Context *ctx, uint3 { std::cout << "[VU0] microprogram @0x" << std::hex << address << " pc=0x" << ctx->pc - << " ra=0x" << ctx->r[31].m128i_u32[0] + << " ra=0x" << static_cast(_mm_extract_epi32(ctx->r[31], 0)) << std::dec << std::endl; } ++count; @@ -430,7 +430,7 @@ void PS2Runtime::run() { entryPoint(m_memory.getRDRAM(), &m_cpuContext, this); std::cout << "Game thread returned. PC=0x" << std::hex << m_cpuContext.pc - << " RA=0x" << m_cpuContext.r[31].m128i_u32[0] << std::dec << std::endl; + << " RA=0x" << static_cast(_mm_extract_epi32(m_cpuContext.r[31], 0)) << std::dec << std::endl; } catch (const std::exception &e) { @@ -445,9 +445,9 @@ void PS2Runtime::run() { std::cout << "[run] activeThreads=" << g_activeThreads.load(std::memory_order_relaxed); std::cout << " pc=0x" << std::hex << m_cpuContext.pc - << " ra=0x" << m_cpuContext.r[31].m128i_u32[0] - << " sp=0x" << m_cpuContext.r[29].m128i_u32[0] - << " gp=0x" << m_cpuContext.r[28].m128i_u32[0] << std::dec << std::endl; + << " ra=0x" << static_cast(_mm_extract_epi32(m_cpuContext.r[31], 0)) + << " sp=0x" << static_cast(_mm_extract_epi32(m_cpuContext.r[29], 0)) + << " gp=0x" << static_cast(_mm_extract_epi32(m_cpuContext.r[28], 0)) << std::dec << std::endl; } if ((tick % 600) == 0) { diff --git a/ps2xRuntime/src/lib/ps2_syscalls.cpp b/ps2xRuntime/src/lib/ps2_syscalls.cpp index 129323a..1d4a7a1 100644 --- a/ps2xRuntime/src/lib/ps2_syscalls.cpp +++ b/ps2xRuntime/src/lib/ps2_syscalls.cpp @@ -1,4 +1,3 @@ - #include "ps2_syscalls.h" #include "ps2_runtime.h" #include "ps2_runtime_macros.h" @@ -15,6 +14,12 @@ #include #include +#ifndef _WIN32 +#include // for unlink,rmdir,chdir +#include // for mkdir +#endif + + std::unordered_map g_fileDescriptors; int g_nextFd = 3; // Start after stdin, stdout, stderr