mirror of
https://github.com/ran-j/PS2Recomp.git
synced 2026-09-26 08:51:05 -04:00
Added explicit FPU ACC register (#143)
This commit is contained in:
@@ -1842,19 +1842,19 @@ namespace ps2recomp
|
||||
case COP1_S_RSQRT:
|
||||
return fmt::format("ctx->f[{}] = 1.0f / sqrtf(ctx->f[{}]);", fd, fs);
|
||||
case COP1_S_ADDA:
|
||||
return fmt::format("ctx->f[31] = FPU_ADD_S(ctx->f[{}], ctx->f[{}]);", fs, ft);
|
||||
return fmt::format("FPU_SET_ACC(ctx, FPU_ADD_S(ctx->f[{}], ctx->f[{}]));", fs, ft);
|
||||
case COP1_S_SUBA:
|
||||
return fmt::format("ctx->f[31] = FPU_SUB_S(ctx->f[{}], ctx->f[{}]);", fs, ft);
|
||||
return fmt::format("FPU_SET_ACC(ctx, FPU_SUB_S(ctx->f[{}], ctx->f[{}]));", fs, ft);
|
||||
case COP1_S_MULA:
|
||||
return fmt::format("ctx->f[31] = FPU_MUL_S(ctx->f[{}], ctx->f[{}]);", fs, ft);
|
||||
return fmt::format("FPU_SET_ACC(ctx, FPU_MUL_S(ctx->f[{}], ctx->f[{}]));", fs, ft);
|
||||
case COP1_S_MADD:
|
||||
return fmt::format("ctx->f[{}] = FPU_ADD_S(ctx->f[31], FPU_MUL_S(ctx->f[{}], ctx->f[{}]));", fd, fs, ft);
|
||||
return fmt::format("ctx->f[{}] = FPU_ADD_S(ctx->f_acc, FPU_MUL_S(ctx->f[{}], ctx->f[{}]));", fd, fs, ft);
|
||||
case COP1_S_MSUB:
|
||||
return fmt::format("ctx->f[{}] = FPU_SUB_S(ctx->f[31], FPU_MUL_S(ctx->f[{}], ctx->f[{}]));", fd, fs, ft);
|
||||
return fmt::format("ctx->f[{}] = FPU_SUB_S(ctx->f_acc, FPU_MUL_S(ctx->f[{}], ctx->f[{}]));", fd, fs, ft);
|
||||
case COP1_S_MADDA:
|
||||
return fmt::format("ctx->f[31] = FPU_ADD_S(ctx->f[31], FPU_MUL_S(ctx->f[{}], ctx->f[{}]));", fs, ft);
|
||||
return fmt::format("FPU_SET_ACC(ctx, FPU_ADD_S(ctx->f_acc, FPU_MUL_S(ctx->f[{}], ctx->f[{}])));", fs, ft);
|
||||
case COP1_S_MSUBA:
|
||||
return fmt::format("ctx->f[31] = FPU_SUB_S(ctx->f[31], FPU_MUL_S(ctx->f[{}], ctx->f[{}]));", fs, ft);
|
||||
return fmt::format("FPU_SET_ACC(ctx, FPU_SUB_S(ctx->f_acc, FPU_MUL_S(ctx->f[{}], ctx->f[{}])));", fs, ft);
|
||||
case COP1_S_MAX:
|
||||
return fmt::format("ctx->f[{}] = std::max(ctx->f[{}], ctx->f[{}]);", fd, fs, ft);
|
||||
case COP1_S_MIN:
|
||||
|
||||
@@ -128,6 +128,7 @@ struct alignas(16) R5900Context
|
||||
|
||||
// FPU registers (COP1)
|
||||
float f[32];
|
||||
float f_acc; // FPU accumulator
|
||||
uint32_t fcr31; // Control/status register
|
||||
|
||||
R5900Context()
|
||||
|
||||
@@ -550,6 +550,7 @@ inline __m128i ps2_u64_to_epi64_pair(uint64_t value)
|
||||
#define PS2_PMFHL_SH(hi, lo) _mm_shufflehi_epi16(_mm_shufflelo_epi16(_mm_packs_epi32(ps2_u64_to_epi64_pair(lo), ps2_u64_to_epi64_pair(hi)), _MM_SHUFFLE(3, 1, 2, 0)), _MM_SHUFFLE(3, 1, 2, 0))
|
||||
|
||||
// FPU (COP1) operations
|
||||
#define FPU_SET_ACC(ctx, res) (ctx->f_acc = res)
|
||||
#define FPU_ADD_S(a, b) ((float)(a) + (float)(b))
|
||||
#define FPU_SUB_S(a, b) ((float)(a) - (float)(b))
|
||||
#define FPU_MUL_S(a, b) ((float)(a) * (float)(b))
|
||||
|
||||
Reference in New Issue
Block a user