2023-08-16 23:29:22 +00:00
|
|
|
#include "Project64-rsp-core/Recompiler/RspRecompilerCPU.h"
|
|
|
|
#include "RspProfiling.h"
|
|
|
|
#include "RspRecompilerCPU.h"
|
2023-11-09 01:23:06 +00:00
|
|
|
#include "X86.h"
|
2023-08-16 23:29:22 +00:00
|
|
|
#include <Common/StdString.h>
|
2023-08-10 04:46:57 +00:00
|
|
|
#include <Project64-rsp-core/RSPInfo.h>
|
2024-08-01 23:30:38 +00:00
|
|
|
#include <Project64-rsp-core/Recompiler/RspRecompilerOps.h>
|
2023-08-10 04:46:57 +00:00
|
|
|
#include <Project64-rsp-core/cpu/RSPCpu.h>
|
2023-08-10 00:57:11 +00:00
|
|
|
#include <Project64-rsp-core/cpu/RSPInstruction.h>
|
2023-08-10 04:46:57 +00:00
|
|
|
#include <Project64-rsp-core/cpu/RSPInterpreterOps.h>
|
2023-08-10 00:57:11 +00:00
|
|
|
#include <Project64-rsp-core/cpu/RSPRegisters.h>
|
2023-08-16 23:29:22 +00:00
|
|
|
#include <Project64-rsp-core/cpu/RspLog.h>
|
|
|
|
#include <Project64-rsp-core/cpu/RspMemory.h>
|
2024-08-01 23:30:38 +00:00
|
|
|
#include <Project64-rsp-core/cpu/RspSystem.h>
|
2023-08-10 00:57:11 +00:00
|
|
|
#include <Project64-rsp-core/cpu/RspTypes.h>
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2021-03-19 07:13:35 +00:00
|
|
|
#pragma warning(disable : 4152) // Non-standard extension, function/data pointer conversion in expression
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
extern bool AudioHle, GraphicsHle;
|
2016-01-27 09:39:06 +00:00
|
|
|
UWORD32 Recp, RecpResult, SQroot, SQrootResult;
|
2023-08-10 04:46:57 +00:00
|
|
|
uint32_t ESP_RegSave = 0, EBP_RegSave = 0;
|
|
|
|
uint32_t BranchCompare = 0;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2021-03-19 07:13:35 +00:00
|
|
|
// Align option affects: SW, LH, SH
|
|
|
|
// Align option affects: LRV, SSV, LSV
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
#define Compile_Immediates // ADDI, ADDIU, ANDI, ORI, XORI, LUI
|
|
|
|
#define Compile_GPRLoads // LB, LH, LW, LBU, LHU
|
|
|
|
#define Compile_GPRStores // SB, SH, SW
|
|
|
|
#define Compile_Special // SLL, SRL, SRA, SRLV \
|
|
|
|
// XOR, OR, AND, SUB, SUBU, ADDU, ADD, SLT
|
2016-01-27 09:39:06 +00:00
|
|
|
#define Compile_Cop0
|
|
|
|
#define Compile_Cop2
|
|
|
|
|
|
|
|
#define RSP_VectorMuls
|
|
|
|
#define RSP_VectorLoads
|
|
|
|
#define RSP_VectorMisc
|
|
|
|
|
|
|
|
#ifdef RSP_VectorMuls
|
2024-07-20 07:35:11 +00:00
|
|
|
//#define CompileVmulf
|
|
|
|
//#define CompileVmacf
|
|
|
|
#define CompileVmudm
|
|
|
|
//#define CompileVmudh
|
|
|
|
#define CompileVmudn
|
|
|
|
//#define CompileVmudl
|
|
|
|
//#define CompileVmadl
|
|
|
|
//#define CompileVmadm
|
|
|
|
#define CompileVmadh
|
|
|
|
#define CompileVmadn
|
2016-01-27 09:39:06 +00:00
|
|
|
#endif
|
|
|
|
#ifdef RSP_VectorMisc
|
2024-07-20 07:35:11 +00:00
|
|
|
//#define CompileVne
|
|
|
|
//#define CompileVeq
|
|
|
|
//#define CompileVge
|
|
|
|
//#define CompileVlt
|
|
|
|
//#define CompileVrcp
|
|
|
|
//#define CompileVrcpl
|
|
|
|
//#define CompileVrsqh
|
|
|
|
//#define CompileVrcph
|
|
|
|
//#define CompileVsaw
|
|
|
|
//#define CompileVabs
|
|
|
|
//#define CompileVmov
|
|
|
|
#define CompileVxor
|
|
|
|
#define CompileVor
|
|
|
|
#define CompileVand
|
|
|
|
#define CompileVsub
|
|
|
|
#define CompileVadd
|
2023-06-01 11:46:23 +00:00
|
|
|
#define CompileVaddc
|
|
|
|
#define CompileVsubc
|
2024-07-20 07:35:11 +00:00
|
|
|
//#define CompileVmrg
|
2023-06-01 11:46:23 +00:00
|
|
|
#define CompileVnxor
|
|
|
|
#define CompileVnor
|
|
|
|
#define CompileVnand
|
2016-01-27 09:39:06 +00:00
|
|
|
#endif
|
|
|
|
#ifdef RSP_VectorLoads
|
2023-06-01 11:46:23 +00:00
|
|
|
#define CompileLbv
|
2024-07-20 07:35:11 +00:00
|
|
|
//#define CompileLpv
|
|
|
|
//#define CompileLuv
|
|
|
|
//#define CompileLhv
|
2024-07-20 09:40:36 +00:00
|
|
|
#define CompileSqv
|
2024-07-20 07:35:11 +00:00
|
|
|
#define CompileSdv
|
|
|
|
#define CompileSsv
|
|
|
|
#define CompileLrv
|
|
|
|
#define CompileLqv
|
|
|
|
#define CompileLdv
|
|
|
|
#define CompileLsv
|
|
|
|
#define CompileLlv
|
2023-06-01 11:46:23 +00:00
|
|
|
#define CompileSlv
|
2016-01-27 09:39:06 +00:00
|
|
|
#endif
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
extern p_Recompfunc RSP_Recomp_Opcode[64];
|
|
|
|
extern p_Recompfunc RSP_Recomp_RegImm[32];
|
|
|
|
extern p_Recompfunc RSP_Recomp_Special[64];
|
|
|
|
extern p_Recompfunc RSP_Recomp_Cop0[32];
|
|
|
|
extern p_Recompfunc RSP_Recomp_Cop2[32];
|
|
|
|
extern p_Recompfunc RSP_Recomp_Vector[64];
|
|
|
|
extern p_Recompfunc RSP_Recomp_Lc2[32];
|
|
|
|
extern p_Recompfunc RSP_Recomp_Sc2[32];
|
2024-08-01 23:30:38 +00:00
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
void CRSPRecompilerOps::Cheat_r4300iOpcode(RSPOp::Func FunctAddress, const char * FunctName)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
|
|
|
MoveConstToVariable(m_OpCode.Value, &m_OpCode.Value, "m_OpCode.Value");
|
|
|
|
MoveConstToX86reg((uint32_t) & (RSPSystem.m_Op), x86_ECX);
|
2024-08-01 23:30:38 +00:00
|
|
|
Call_Direct(AddressOf(FunctAddress), FunctName);
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
void CRSPRecompilerOps::Cheat_r4300iOpcodeNoMessage(RSPOp::Func FunctAddress, const char * FunctName)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveConstToVariable(m_OpCode.Value, &m_OpCode.Value, "m_OpCode.Value");
|
|
|
|
MoveConstToX86reg((uint32_t) & (RSPSystem.m_Op), x86_ECX);
|
2024-08-01 23:30:38 +00:00
|
|
|
Call_Direct(AddressOf(FunctAddress), FunctName);
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
void x86_SetBranch8b(void * JumpByte, void * Destination)
|
|
|
|
{
|
|
|
|
// Calculate 32-bit relative offset
|
2023-08-16 23:29:22 +00:00
|
|
|
size_t n = (uint8_t *)Destination - ((uint8_t *)JumpByte + 1);
|
|
|
|
intptr_t signed_n = (intptr_t)n;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
// Check limits, no pun intended
|
|
|
|
if (signed_n > +128 || signed_n < -127)
|
|
|
|
{
|
2023-08-16 23:29:22 +00:00
|
|
|
CompilerWarning(stdstr_f("FATAL: Jump out of 8b range %i (PC = %04X)", n, CompilePC).c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*(uint8_t *)(JumpByte) = (uint8_t)(n & 0xFF);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void x86_SetBranch32b(void * JumpByte, void * Destination)
|
|
|
|
{
|
2023-08-16 23:29:22 +00:00
|
|
|
*(uint32_t *)(JumpByte) = (uint32_t)((uint8_t *)Destination - (uint8_t *)((uint32_t *)JumpByte + 1));
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
void BreakPoint()
|
|
|
|
{
|
|
|
|
CPU_Message(" int 3");
|
|
|
|
*(RecompPos++) = 0xCC;
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-22 08:02:05 +00:00
|
|
|
void CRSPRecompilerOps::CompileBranchExit(uint32_t TargetPC, uint32_t ContinuePC)
|
2016-01-27 09:39:06 +00:00
|
|
|
{
|
2023-08-10 04:46:57 +00:00
|
|
|
uint32_t * X86Loc = NULL;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-29 02:59:07 +00:00
|
|
|
CompConstToVariable(true, &BranchCompare, "BranchCompare");
|
2023-06-01 11:46:23 +00:00
|
|
|
JeLabel32("BranchEqual", 0);
|
2023-08-10 04:46:57 +00:00
|
|
|
X86Loc = (uint32_t *)(RecompPos - 4);
|
2024-08-22 08:02:05 +00:00
|
|
|
MoveConstToVariable(ContinuePC, m_System.m_SP_PC_REG, "RSP PC");
|
2023-06-01 11:46:23 +00:00
|
|
|
Ret();
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
CPU_Message("BranchEqual:");
|
|
|
|
x86_SetBranch32b(X86Loc, RecompPos);
|
2024-08-22 08:02:05 +00:00
|
|
|
MoveConstToVariable(TargetPC, m_System.m_SP_PC_REG, "RSP PC");
|
2023-06-01 11:46:23 +00:00
|
|
|
Ret();
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-08 00:09:45 +00:00
|
|
|
CRSPRecompilerOps::CRSPRecompilerOps(CRSPSystem & System, CRSPRecompiler & Recompiler) :
|
2024-08-07 21:56:15 +00:00
|
|
|
m_System(System),
|
2024-08-22 07:00:20 +00:00
|
|
|
m_RSPRegisterHandler(System.m_RSPRegisterHandler),
|
2024-08-08 00:09:45 +00:00
|
|
|
m_Recompiler(Recompiler),
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction(Recompiler.m_NextInstruction),
|
2024-08-08 03:25:54 +00:00
|
|
|
m_OpCode(System.m_OpCode),
|
2024-08-07 21:56:15 +00:00
|
|
|
m_Reg(System.m_Reg),
|
|
|
|
m_GPR(System.m_Reg.m_GPR),
|
|
|
|
m_ACCUM(System.m_Reg.m_ACCUM),
|
|
|
|
m_Flags(System.m_Reg.m_Flags),
|
|
|
|
m_Vect(System.m_Reg.m_Vect)
|
2024-08-02 12:30:01 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
// Opcode functions
|
2021-03-19 07:13:35 +00:00
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::SPECIAL(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
(this->*RSP_Recomp_Special[m_OpCode.funct])();
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::REGIMM(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
(this->*RSP_Recomp_RegImm[m_OpCode.rt])();
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::J(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
if (m_NextInstruction == RSPPIPELINE_NORMAL)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_DONE)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
JmpLabel32("BranchToJump", 0);
|
2024-08-08 03:25:54 +00:00
|
|
|
m_Recompiler.Branch_AddRef((m_OpCode.target << 2) & 0xFFC, (uint32_t *)(RecompPos - 4));
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_EXIT_DONE)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 08:02:05 +00:00
|
|
|
MoveConstToVariable((m_OpCode.target << 2) & 0xFFC, m_System.m_SP_PC_REG, "RSP PC");
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
Ret();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
CompilerWarning(stdstr_f("J error\nWeird Delay Slot.\n\nNextInstruction = %X\nEmulation will now stop", m_NextInstruction).c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
BreakPoint();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::JAL(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
if (m_NextInstruction == RSPPIPELINE_NORMAL)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveConstToVariable((CompilePC + 8) & 0xFFC, &m_GPR[31].UW, "RA.W");
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_DONE)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
// Before we branch quickly update our stats
|
|
|
|
if (Profiling && IndvidualBlock)
|
|
|
|
{
|
|
|
|
char Str[40];
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Str, "%03X", (m_OpCode.target << 2) & 0xFFC);
|
2023-06-01 11:46:23 +00:00
|
|
|
Push(x86_EAX);
|
2024-08-22 08:02:05 +00:00
|
|
|
PushImm32(Str, *m_System.m_SP_PC_REG);
|
2023-11-09 01:23:06 +00:00
|
|
|
Call_Direct((void *)StartTimer, "StartTimer");
|
2023-06-01 11:46:23 +00:00
|
|
|
AddConstToX86Reg(x86_ESP, 4);
|
|
|
|
Pop(x86_EAX);
|
|
|
|
}
|
|
|
|
JmpLabel32("BranchToJump", 0);
|
2024-08-08 03:25:54 +00:00
|
|
|
m_Recompiler.Branch_AddRef((m_OpCode.target << 2) & 0xFFC, (uint32_t *)(RecompPos - 4));
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_EXIT_DONE)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 08:02:05 +00:00
|
|
|
MoveConstToVariable((m_OpCode.target << 2) & 0xFFC, m_System.m_SP_PC_REG, "RSP PC");
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
Ret();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
CompilerWarning(stdstr_f("J error\nWeird Delay Slot.\n\nNextInstruction = %X\nEmulation will now stop", m_NextInstruction).c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
BreakPoint();
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::BEQ(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
static bool bDelayAffect;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-22 10:14:07 +00:00
|
|
|
if (m_NextInstruction == RSPPIPELINE_NORMAL)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
|
|
|
if (m_OpCode.rs == 0 && m_OpCode.rt == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2024-06-13 03:25:23 +00:00
|
|
|
MoveConstByteToVariable(1, &BranchCompare, "BranchCompare");
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
bDelayAffect = DelaySlotAffectBranch(CompilePC);
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bDelayAffect)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rt == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CompConstToVariable(0, &m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CompConstToVariable(0, &m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt), x86_EAX);
|
|
|
|
CompX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
SetzVariable(&BranchCompare, "BranchCompare");
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_DONE)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Target = (CompilePC + ((short)m_OpCode.offset << 2) + 4) & 0xFFC;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rs == 0 && m_OpCode.rt == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
JmpLabel32("BranchToJump", 0);
|
2024-08-08 00:09:45 +00:00
|
|
|
m_Recompiler.Branch_AddRef(Target, (uint32_t *)(RecompPos - 4));
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bDelayAffect)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rt == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CompConstToVariable(0, &m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CompConstToVariable(0, &m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt), x86_EAX);
|
|
|
|
CompX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
JeLabel32("BranchEqual", 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Take a look at the branch compare variable
|
2023-06-29 02:59:07 +00:00
|
|
|
CompConstToVariable(true, &BranchCompare, "BranchCompare");
|
2023-06-01 11:46:23 +00:00
|
|
|
JeLabel32("BranchEqual", 0);
|
|
|
|
}
|
2024-08-08 00:09:45 +00:00
|
|
|
m_Recompiler.Branch_AddRef(Target, (uint32_t *)(RecompPos - 4));
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_EXIT_DONE)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Target = (CompilePC + ((short)m_OpCode.offset << 2) + 4) & 0xFFC;
|
2023-06-01 11:46:23 +00:00
|
|
|
CompileBranchExit(Target, CompilePC + 8);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
CompilerWarning(stdstr_f("BEQ error\nWeird Delay Slot.\n\nNextInstruction = %X\nEmulation will now stop", m_NextInstruction).c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
BreakPoint();
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::BNE(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
static bool bDelayAffect;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-22 10:14:07 +00:00
|
|
|
if (m_NextInstruction == RSPPIPELINE_NORMAL)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
|
|
|
if (m_OpCode.rs == 0 && m_OpCode.rt == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-06-13 03:25:23 +00:00
|
|
|
MoveConstByteToVariable(0, &BranchCompare, "BranchCompare");
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bDelayAffect = DelaySlotAffectBranch(CompilePC);
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bDelayAffect)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rt == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CompConstToVariable(0, &m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CompConstToVariable(0, &m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt), x86_EAX);
|
|
|
|
CompX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
SetnzVariable(&BranchCompare, "BranchCompare");
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_DONE)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Target = (CompilePC + ((short)m_OpCode.offset << 2) + 4) & 0xFFC;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rs == 0 && m_OpCode.rt == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bDelayAffect)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rt == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CompConstToVariable(0, &m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CompConstToVariable(0, &m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt), x86_EAX);
|
|
|
|
CompX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
JneLabel32("BranchNotEqual", 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Take a look at the branch compare variable
|
2023-06-29 02:59:07 +00:00
|
|
|
CompConstToVariable(true, &BranchCompare, "BranchCompare");
|
2023-06-01 11:46:23 +00:00
|
|
|
JeLabel32("BranchNotEqual", 0);
|
|
|
|
}
|
2024-08-08 00:09:45 +00:00
|
|
|
m_Recompiler.Branch_AddRef(Target, (uint32_t *)(RecompPos - 4));
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_EXIT_DONE)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Target = (CompilePC + ((short)m_OpCode.offset << 2) + 4) & 0xFFC;
|
2023-06-01 11:46:23 +00:00
|
|
|
CompileBranchExit(Target, CompilePC + 8);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
CompilerWarning(stdstr_f("BNE error\nWeird Delay Slot.\n\nNextInstruction = %X\nEmulation will now stop", m_NextInstruction).c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
BreakPoint();
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::BLEZ(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
static bool bDelayAffect;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-22 10:14:07 +00:00
|
|
|
if (m_NextInstruction == RSPPIPELINE_NORMAL)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
|
|
|
if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
bDelayAffect = DelaySlotAffectBranch(CompilePC);
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bDelayAffect)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
CompConstToVariable(0, &m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs));
|
2023-06-01 11:46:23 +00:00
|
|
|
SetleVariable(&BranchCompare, "BranchCompare");
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_DONE)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Target = (CompilePC + ((short)m_OpCode.offset << 2) + 4) & 0xFFC;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
JmpLabel32("BranchToJump", 0);
|
2024-08-08 00:09:45 +00:00
|
|
|
m_Recompiler.Branch_AddRef(Target, (uint32_t *)(RecompPos - 4));
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bDelayAffect)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CompConstToVariable(0, &m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs));
|
2023-06-01 11:46:23 +00:00
|
|
|
JleLabel32("BranchLessEqual", 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Take a look at the branch compare variable
|
2023-06-29 02:59:07 +00:00
|
|
|
CompConstToVariable(true, &BranchCompare, "BranchCompare");
|
2023-06-01 11:46:23 +00:00
|
|
|
JeLabel32("BranchLessEqual", 0);
|
|
|
|
}
|
|
|
|
|
2024-08-08 00:09:45 +00:00
|
|
|
m_Recompiler.Branch_AddRef(Target, (uint32_t *)(RecompPos - 4));
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_EXIT_DONE)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Target = (CompilePC + ((short)m_OpCode.offset << 2) + 4) & 0xFFC;
|
2023-06-01 11:46:23 +00:00
|
|
|
CompileBranchExit(Target, CompilePC + 8);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
CompilerWarning(stdstr_f("BLEZ error\nWeird Delay Slot.\n\nNextInstruction = %X\nEmulation will now stop", m_NextInstruction).c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
BreakPoint();
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::BGTZ(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
static bool bDelayAffect;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-22 10:14:07 +00:00
|
|
|
if (m_NextInstruction == RSPPIPELINE_NORMAL)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
|
|
|
if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
bDelayAffect = DelaySlotAffectBranch(CompilePC);
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bDelayAffect)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
CompConstToVariable(0, &m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs));
|
2023-06-01 11:46:23 +00:00
|
|
|
SetgVariable(&BranchCompare, "BranchCompare");
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_DONE)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Target = (CompilePC + ((short)m_OpCode.offset << 2) + 4) & 0xFFC;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bDelayAffect)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CompConstToVariable(0, &m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs));
|
2023-06-01 11:46:23 +00:00
|
|
|
JgLabel32("BranchGreater", 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Take a look at the branch compare variable
|
2023-06-29 02:59:07 +00:00
|
|
|
CompConstToVariable(true, &BranchCompare, "BranchCompare");
|
2023-06-01 11:46:23 +00:00
|
|
|
JeLabel32("BranchGreater", 0);
|
|
|
|
}
|
2024-08-08 00:09:45 +00:00
|
|
|
m_Recompiler.Branch_AddRef(Target, (uint32_t *)(RecompPos - 4));
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_EXIT_DONE)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Target = (CompilePC + ((short)m_OpCode.offset << 2) + 4) & 0xFFC;
|
2023-06-01 11:46:23 +00:00
|
|
|
CompileBranchExit(Target, CompilePC + 8);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
CompilerWarning(stdstr_f("BGTZ error\nWeird Delay Slot.\n\nNextInstruction = %X\nEmulation will now stop", m_NextInstruction).c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
BreakPoint();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::ADDI(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rt == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-06-20 07:58:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
#ifndef Compile_Immediates
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::ADDI, "RSPOp::ADDI");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
int Immediate = (short)m_OpCode.immediate;
|
|
|
|
if (m_OpCode.rt == m_OpCode.rs)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
if (Immediate != 0)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
AddConstToVariable(Immediate, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveConstToVariable(Immediate, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if ((IsRegConst(m_OpCode.rs) & 1) != 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveConstToVariable(MipsRegConst(m_OpCode.rs) + Immediate, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].UW, GPR_Name(m_OpCode.rs), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
if (Immediate != 0)
|
|
|
|
{
|
|
|
|
AddConstToX86Reg(x86_EAX, Immediate);
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::ADDIU(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rt == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-06-20 07:58:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
#ifndef Compile_Immediates
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::ADDIU, "RSPOp::ADDIU");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
int Immediate = (short)m_OpCode.immediate;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rt == m_OpCode.rs)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
if (Immediate != 0)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
AddConstToVariable(Immediate, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveConstToVariable(Immediate, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].UW, GPR_Name(m_OpCode.rs), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
if (Immediate != 0)
|
|
|
|
{
|
|
|
|
AddConstToX86Reg(x86_EAX, Immediate);
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::SLTI(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rt == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-06-20 07:58:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-06-01 11:46:23 +00:00
|
|
|
#ifndef Compile_Immediates
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::SLTI, "&RSPOp::SLTI");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
int Immediate = (short)m_OpCode.immediate;
|
2023-06-01 11:46:23 +00:00
|
|
|
if (Immediate == 0)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].UW, GPR_Name(m_OpCode.rs), x86_ECX);
|
2023-06-01 11:46:23 +00:00
|
|
|
ShiftRightUnsignImmed(x86_ECX, 31);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
XorX86RegToX86Reg(x86_ECX, x86_ECX);
|
2024-08-08 03:25:54 +00:00
|
|
|
CompConstToVariable(Immediate, &m_GPR[m_OpCode.rs].UW, GPR_Name(m_OpCode.rs));
|
2023-06-01 11:46:23 +00:00
|
|
|
Setl(x86_ECX);
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_ECX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::SLTIU(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rt == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-06-20 07:58:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-06-01 11:46:23 +00:00
|
|
|
#ifndef Compile_Immediates
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::SLTIU, "RSPOp::SLTIU");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
int Immediate;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
Immediate = (short)m_OpCode.immediate;
|
2023-06-01 11:46:23 +00:00
|
|
|
XorX86RegToX86Reg(x86_ECX, x86_ECX);
|
2024-08-08 03:25:54 +00:00
|
|
|
CompConstToVariable(Immediate, &m_GPR[m_OpCode.rs].UW, GPR_Name(m_OpCode.rs));
|
2023-06-01 11:46:23 +00:00
|
|
|
Setb(x86_ECX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_ECX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::ANDI(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rt == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-06-20 07:58:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-06-01 11:46:23 +00:00
|
|
|
#ifndef Compile_Immediates
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::ANDI, "RSPOp::ANDI");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
int Immediate = (unsigned short)m_OpCode.immediate;
|
|
|
|
if (m_OpCode.rt == m_OpCode.rs)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
AndConstToVariable(Immediate, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveConstToVariable(0, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else if (Immediate == 0xFFFF)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveZxVariableToX86regHalf(&m_GPR[m_OpCode.rs].UW, GPR_Name(m_OpCode.rs), x86_EAX);
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].UW, GPR_Name(m_OpCode.rs), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
AndConstToX86Reg(x86_EAX, Immediate);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::ORI(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rt == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-06-20 07:58:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-06-01 11:46:23 +00:00
|
|
|
#ifndef Compile_Immediates
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::ORI, "RSPOp::ORI");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
int Immediate = (unsigned short)m_OpCode.immediate;
|
|
|
|
if (m_OpCode.rt == m_OpCode.rs)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
OrConstToVariable(Immediate, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveConstToVariable(Immediate, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].UW, GPR_Name(m_OpCode.rs), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
if (Immediate != 0)
|
|
|
|
{
|
|
|
|
OrConstToX86Reg(Immediate, x86_EAX);
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::XORI(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rt == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-06-20 07:58:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-06-01 11:46:23 +00:00
|
|
|
#ifndef Compile_Immediates
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::XORI, "RSPOp::XORI");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
int Immediate = (unsigned short)m_OpCode.immediate;
|
|
|
|
if (m_OpCode.rt == m_OpCode.rs)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
XorConstToVariable(&m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt), Immediate);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveConstToVariable(Immediate, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].UW, GPR_Name(m_OpCode.rs), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
if (Immediate != 0)
|
|
|
|
{
|
|
|
|
XorConstToX86Reg(x86_EAX, Immediate);
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::LUI(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rt == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-06-20 07:58:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-06-01 11:46:23 +00:00
|
|
|
#ifndef Compile_Immediates
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::LUI, "RSPOp::LUI");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
int constant = (short)m_OpCode.offset << 16;
|
|
|
|
MoveConstToVariable(constant, &m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt));
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::COP0(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
(this->*RSP_Recomp_Cop0[m_OpCode.rs])();
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::COP2(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
(this->*RSP_Recomp_Cop2[m_OpCode.rs])();
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::LB(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rt == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
2024-06-20 07:58:51 +00:00
|
|
|
}
|
2023-06-01 11:46:23 +00:00
|
|
|
#ifndef Compile_GPRLoads
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::LB, "RSPOp::LB");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
int Offset = (short)m_OpCode.offset;
|
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (IsRegConst(m_OpCode.base))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
char Address[32];
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Addr = (MipsRegConst(m_OpCode.base) + Offset) ^ 3;
|
2023-06-01 11:46:23 +00:00
|
|
|
Addr &= 0xfff;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
sprintf(Address, "Dmem + %Xh", Addr);
|
|
|
|
MoveSxVariableToX86regByte(RSPInfo.DMEM + Addr, Address, x86_EAX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.base].UW, GPR_Name(m_OpCode.base), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
if (Offset != 0) AddConstToX86Reg(x86_EBX, Offset);
|
|
|
|
XorConstToX86Reg(x86_EBX, 3);
|
|
|
|
AndConstToX86Reg(x86_EBX, 0x0fff);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveSxN64MemToX86regByte(x86_EAX, x86_EBX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::LH(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rt == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
2024-06-20 07:58:51 +00:00
|
|
|
}
|
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
#ifndef Compile_GPRLoads
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::LH, "RSPOp::LH");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
int Offset = (short)m_OpCode.offset;
|
2024-06-20 07:58:51 +00:00
|
|
|
uint8_t * Jump[2];
|
2024-08-08 03:25:54 +00:00
|
|
|
if (IsRegConst(m_OpCode.base))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Addr = (MipsRegConst(m_OpCode.base) + Offset) ^ 2;
|
2023-06-01 11:46:23 +00:00
|
|
|
Addr &= 0xfff;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
if ((Addr & 1) != 0)
|
|
|
|
{
|
|
|
|
if ((Addr & 2) == 0)
|
|
|
|
{
|
2023-08-16 23:29:22 +00:00
|
|
|
CompilerWarning(stdstr_f("Unaligned LH at constant address PC = %04X", CompilePC).c_str());
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::LH, "RSPOp::LH");
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char Address[32];
|
|
|
|
sprintf(Address, "DMEM + %Xh", Addr);
|
|
|
|
MoveSxVariableToX86regHalf(RSPInfo.DMEM + (Addr ^ 2), Address, x86_EAX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char Address[32];
|
|
|
|
sprintf(Address, "DMEM + %Xh", Addr);
|
|
|
|
MoveSxVariableToX86regHalf(RSPInfo.DMEM + Addr, Address, x86_EAX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.base].UW, GPR_Name(m_OpCode.base), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
if (Offset != 0) AddConstToX86Reg(x86_EBX, Offset);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
AndConstToX86Reg(x86_EBX, 0x0fff);
|
|
|
|
TestConstToX86Reg(1, x86_EBX);
|
|
|
|
JneLabel32("Unaligned", 0);
|
|
|
|
Jump[0] = RecompPos - 4;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
CompilerToggleBuffer();
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
CPU_Message(" Unaligned:");
|
|
|
|
x86_SetBranch32b(Jump[0], RecompPos);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::LH, "RSPOp::LH");
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
JmpLabel32("Done", 0);
|
|
|
|
Jump[1] = RecompPos - 4;
|
2021-03-19 07:13:35 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
CompilerToggleBuffer();
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
XorConstToX86Reg(x86_EBX, 2);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveSxN64MemToX86regHalf(x86_EAX, x86_EBX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
CPU_Message(" Done:");
|
|
|
|
x86_SetBranch32b(Jump[1], RecompPos);
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::LW(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rt == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
2024-06-20 07:58:51 +00:00
|
|
|
}
|
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
#ifndef Compile_GPRLoads
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::LW, "RSPOp::LW");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
int Offset = (short)m_OpCode.offset;
|
2024-06-20 07:58:51 +00:00
|
|
|
uint8_t * Jump[2];
|
2024-08-08 03:25:54 +00:00
|
|
|
if (IsRegConst(m_OpCode.base))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Addr = (MipsRegConst(m_OpCode.base) + Offset) & 0xfff;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
if ((Addr & 1) != 0)
|
|
|
|
{
|
2023-08-16 23:29:22 +00:00
|
|
|
CompilerWarning(stdstr_f("Unaligned LW at constant address PC = %04X", CompilePC).c_str());
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::LW, "RSPOp::LW");
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else if ((Addr & 2) != 0)
|
|
|
|
{
|
|
|
|
char Address[32];
|
|
|
|
sprintf(Address, "DMEM + %Xh", Addr - 2);
|
2024-07-12 05:32:46 +00:00
|
|
|
MoveVariableToX86regHalf(RSPInfo.DMEM + ((Addr - 2) & 0xFFF), Address, x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
sprintf(Address, "DMEM + %Xh", Addr);
|
2024-07-12 05:32:46 +00:00
|
|
|
MoveVariableToX86regHalf(RSPInfo.DMEM + ((Addr + 4) & 0xFFF), Address, x86_ECX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UHW[1], GPR_Name(m_OpCode.rt));
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_GPR[m_OpCode.rt].UHW[0], GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char Address[32];
|
|
|
|
sprintf(Address, "DMEM + %Xh", Addr);
|
|
|
|
MoveVariableToX86reg(RSPInfo.DMEM + Addr, Address, x86_EAX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.base].UW, GPR_Name(m_OpCode.base), x86_EBX);
|
2024-07-12 05:32:46 +00:00
|
|
|
if (Offset != 0)
|
|
|
|
{
|
|
|
|
AddConstToX86Reg(x86_EBX, Offset);
|
|
|
|
}
|
2023-06-01 11:46:23 +00:00
|
|
|
AndConstToX86Reg(x86_EBX, 0x0fff);
|
|
|
|
TestConstToX86Reg(3, x86_EBX);
|
|
|
|
JneLabel32("Unaligned", 0);
|
|
|
|
Jump[0] = RecompPos - 4;
|
|
|
|
|
|
|
|
CompilerToggleBuffer();
|
|
|
|
|
|
|
|
x86_SetBranch32b(Jump[0], RecompPos);
|
|
|
|
CPU_Message(" Unaligned:");
|
|
|
|
|
|
|
|
LeaSourceAndOffset(x86_ECX, x86_EBX, 2);
|
|
|
|
LeaSourceAndOffset(x86_EDX, x86_EBX, 3);
|
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_EAX);
|
|
|
|
AddConstToX86Reg(x86_EBX, 1);
|
|
|
|
|
|
|
|
XorConstToX86Reg(x86_EAX, 3);
|
|
|
|
XorConstToX86Reg(x86_EBX, 3);
|
|
|
|
XorConstToX86Reg(x86_ECX, 3);
|
|
|
|
XorConstToX86Reg(x86_EDX, 3);
|
|
|
|
MoveN64MemToX86regByte(x86_EAX, x86_EAX);
|
|
|
|
MoveN64MemToX86regByte(x86_EBX, x86_EBX);
|
|
|
|
MoveN64MemToX86regByte(x86_ECX, x86_ECX);
|
|
|
|
MoveN64MemToX86regByte(x86_EDX, x86_EDX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regByteToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UB[3], GPR_Name(m_OpCode.rt));
|
|
|
|
MoveX86regByteToVariable(x86_EBX, &m_GPR[m_OpCode.rt].UB[2], GPR_Name(m_OpCode.rt));
|
|
|
|
MoveX86regByteToVariable(x86_ECX, &m_GPR[m_OpCode.rt].UB[1], GPR_Name(m_OpCode.rt));
|
|
|
|
MoveX86regByteToVariable(x86_EDX, &m_GPR[m_OpCode.rt].UB[0], GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
JmpLabel32("Done", 0);
|
|
|
|
Jump[1] = RecompPos - 4;
|
|
|
|
CompilerToggleBuffer();
|
|
|
|
|
|
|
|
MoveN64MemToX86reg(x86_EAX, x86_EBX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
CPU_Message(" Done:");
|
|
|
|
x86_SetBranch32b(Jump[1], RecompPos);
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::LBU(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rt == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
2024-06-20 07:58:51 +00:00
|
|
|
}
|
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
#ifndef Compile_GPRLoads
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::LBU, "RSPOp::LBU");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
int Offset = (short)m_OpCode.offset;
|
|
|
|
if (IsRegConst(m_OpCode.base))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
char Address[32];
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Addr = (MipsRegConst(m_OpCode.base) + Offset) ^ 3;
|
2023-06-01 11:46:23 +00:00
|
|
|
Addr &= 0xfff;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
sprintf(Address, "DMEM + %Xh", Addr);
|
|
|
|
MoveZxVariableToX86regByte(RSPInfo.DMEM + Addr, Address, x86_EAX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.base].UW, GPR_Name(m_OpCode.base), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
XorX86RegToX86Reg(x86_EAX, x86_EAX);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
if (Offset != 0) AddConstToX86Reg(x86_EBX, Offset);
|
|
|
|
XorConstToX86Reg(x86_EBX, 3);
|
|
|
|
AndConstToX86Reg(x86_EBX, 0x0fff);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveN64MemToX86regByte(x86_EAX, x86_EBX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::LHU(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rt == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
2024-06-20 07:58:51 +00:00
|
|
|
}
|
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
#ifndef Compile_GPRLoads
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::LHU, "RSPOp::LHU");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
int Offset = (short)m_OpCode.offset;
|
2024-06-20 07:58:51 +00:00
|
|
|
uint8_t * Jump[2];
|
2024-08-08 03:25:54 +00:00
|
|
|
if (IsRegConst(m_OpCode.base))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Addr = (MipsRegConst(m_OpCode.base) + Offset) ^ 2;
|
2023-06-01 11:46:23 +00:00
|
|
|
Addr &= 0xfff;
|
|
|
|
|
|
|
|
if ((Addr & 1) != 0)
|
|
|
|
{
|
|
|
|
if ((Addr & 2) == 0)
|
|
|
|
{
|
2023-08-16 23:29:22 +00:00
|
|
|
CompilerWarning(stdstr_f("Unaligned LHU at constant address PC = %04X", CompilePC).c_str());
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::LHU, "RSPOp::LHU");
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char Address[32];
|
|
|
|
sprintf(Address, "DMEM + %Xh", Addr);
|
|
|
|
MoveZxVariableToX86regHalf(RSPInfo.DMEM + (Addr ^ 2), Address, x86_ECX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_ECX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char Address[32];
|
|
|
|
sprintf(Address, "DMEM + %Xh", Addr);
|
|
|
|
MoveZxVariableToX86regHalf(RSPInfo.DMEM + Addr, Address, x86_ECX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_ECX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Should really just do it by bytes but whatever for now
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.base].UW, GPR_Name(m_OpCode.base), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
if (Offset != 0)
|
|
|
|
{
|
|
|
|
AddConstToX86Reg(x86_EBX, Offset);
|
|
|
|
}
|
|
|
|
TestConstToX86Reg(1, x86_EBX);
|
|
|
|
JneLabel32("Unaligned", 0);
|
|
|
|
Jump[0] = RecompPos - 4;
|
|
|
|
|
|
|
|
CompilerToggleBuffer();
|
|
|
|
CPU_Message(" Unaligned:");
|
|
|
|
x86_SetBranch32b(Jump[0], RecompPos);
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::LHU, "RSPOp::LHU");
|
2023-06-01 11:46:23 +00:00
|
|
|
JmpLabel32("Done", 0);
|
|
|
|
Jump[1] = RecompPos - 4;
|
|
|
|
CompilerToggleBuffer();
|
|
|
|
|
|
|
|
XorConstToX86Reg(x86_EBX, 2);
|
|
|
|
AndConstToX86Reg(x86_EBX, 0x0fff);
|
|
|
|
MoveZxN64MemToX86regHalf(x86_EAX, x86_EBX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
CPU_Message(" Done:");
|
|
|
|
x86_SetBranch32b(Jump[1], RecompPos);
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::LWU(void)
|
2024-06-13 03:04:28 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rt == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-06-20 07:58:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::LWU, "RSPOp::LWU");
|
2024-06-13 03:04:28 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::SB(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
#ifndef Compile_GPRStores
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::SB, "RSPOp::SB");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
int Offset = (short)m_OpCode.offset;
|
|
|
|
if (IsRegConst(m_OpCode.base))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
char Address[32];
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Addr = (MipsRegConst(m_OpCode.base) + Offset) ^ 3;
|
2023-06-01 11:46:23 +00:00
|
|
|
Addr &= 0xfff;
|
|
|
|
sprintf(Address, "DMEM + %Xh", Addr);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (IsRegConst(m_OpCode.rt))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveConstByteToVariable((uint8_t)MipsRegConst(m_OpCode.rt), RSPInfo.DMEM + Addr, Address);
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86regByte(&m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86regByteToVariable(x86_EAX, RSPInfo.DMEM + Addr, Address);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (IsRegConst(m_OpCode.rt))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.base].UW, GPR_Name(m_OpCode.base), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
if (Offset != 0) AddConstToX86Reg(x86_EBX, Offset);
|
|
|
|
XorConstToX86Reg(x86_EBX, 3);
|
|
|
|
AndConstToX86Reg(x86_EBX, 0x0fff);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveConstByteToN64Mem((uint8_t)MipsRegConst(m_OpCode.rt), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.base].UW, GPR_Name(m_OpCode.base), x86_EBX);
|
|
|
|
MoveVariableToX86regByte(&m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
if (Offset != 0) AddConstToX86Reg(x86_EBX, Offset);
|
|
|
|
XorConstToX86Reg(x86_EBX, 3);
|
|
|
|
AndConstToX86Reg(x86_EBX, 0x0fff);
|
|
|
|
|
|
|
|
MoveX86regByteToN64Mem(x86_EAX, x86_EBX);
|
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::SH(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
#ifndef Compile_GPRStores
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::SH, "&RSPOp::SH");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
int Offset = (short)m_OpCode.offset;
|
2024-06-20 07:58:51 +00:00
|
|
|
uint8_t * Jump[2];
|
2024-08-08 03:25:54 +00:00
|
|
|
if (IsRegConst(m_OpCode.base))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Addr = (MipsRegConst(m_OpCode.base) + Offset) ^ 2;
|
2023-06-01 11:46:23 +00:00
|
|
|
Addr &= 0xfff;
|
|
|
|
|
|
|
|
if ((Offset & 1) != 0)
|
|
|
|
{
|
2023-08-16 23:29:22 +00:00
|
|
|
CompilerWarning(stdstr_f("Unaligned SH at constant address PC = %04X", CompilePC).c_str());
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::SH, "RSPOp::SH");
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char Address[32];
|
|
|
|
sprintf(Address, "DMEM + %Xh", Addr);
|
2024-08-08 03:25:54 +00:00
|
|
|
if (IsRegConst(m_OpCode.rt))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveConstHalfToVariable((uint16_t)MipsRegConst(m_OpCode.rt), RSPInfo.DMEM + Addr, Address);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86regHalf(&m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86regHalfToVariable(x86_EAX, RSPInfo.DMEM + Addr, Address);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.base].UW, GPR_Name(m_OpCode.base), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
if (Offset != 0) AddConstToX86Reg(x86_EBX, Offset);
|
|
|
|
|
|
|
|
TestConstToX86Reg(1, x86_EBX);
|
|
|
|
JneLabel32("Unaligned", 0);
|
|
|
|
Jump[0] = RecompPos - 4;
|
|
|
|
|
|
|
|
CompilerToggleBuffer();
|
|
|
|
|
|
|
|
CPU_Message(" Unaligned:");
|
|
|
|
x86_SetBranch32b(Jump[0], RecompPos);
|
|
|
|
|
|
|
|
X86BreakPoint(__FILE__, __LINE__);
|
|
|
|
JmpLabel32("Done", 0);
|
|
|
|
Jump[1] = RecompPos - 4;
|
|
|
|
|
|
|
|
CompilerToggleBuffer();
|
|
|
|
|
|
|
|
XorConstToX86Reg(x86_EBX, 2);
|
|
|
|
AndConstToX86Reg(x86_EBX, 0x0fff);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (IsRegConst(m_OpCode.rt))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveConstHalfToN64Mem((uint16_t)MipsRegConst(m_OpCode.rt), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86regHalf(&m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86regHalfToN64Mem(x86_EAX, x86_EBX);
|
|
|
|
}
|
|
|
|
|
|
|
|
CPU_Message(" Done:");
|
|
|
|
x86_SetBranch32b(Jump[1], RecompPos);
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::SW(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
#ifndef Compile_GPRStores
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::SW, "&RSPOp::SW");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
int Offset = (short)m_OpCode.offset;
|
2024-06-20 07:58:51 +00:00
|
|
|
uint8_t * Jump[2];
|
2024-08-08 03:25:54 +00:00
|
|
|
if (IsRegConst(m_OpCode.base))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
char Address[32];
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Addr = (MipsRegConst(m_OpCode.base) + Offset) & 0xfff;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
if ((Addr & 3) != 0)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (IsRegConst(m_OpCode.rt))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-06-20 07:58:51 +00:00
|
|
|
if (Addr > 0xFFC)
|
|
|
|
{
|
|
|
|
g_Notify->DisplayError("There is a problem with:\nRSP_SW_DMEM");
|
|
|
|
return;
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Value = MipsRegConst(m_OpCode.rt);
|
2024-07-12 05:34:18 +00:00
|
|
|
sprintf(Address, "DMEM + %Xh", ((Addr + 0) ^ 3) & 0xFFF);
|
|
|
|
MoveConstByteToVariable((Value >> 24) & 0xFF, RSPInfo.DMEM + (((Addr + 0) ^ 3) & 0xFFF), Address);
|
|
|
|
sprintf(Address, "DMEM + %Xh", ((Addr + 1) ^ 3) & 0xFFF);
|
|
|
|
MoveConstByteToVariable((Value >> 16) & 0xFF, RSPInfo.DMEM + (((Addr + 1) ^ 3) & 0xFFF), Address);
|
|
|
|
sprintf(Address, "DMEM + %Xh", ((Addr + 2) ^ 3) & 0xFFF);
|
|
|
|
MoveConstByteToVariable((Value >> 8) & 0xFF, RSPInfo.DMEM + (((Addr + 2) ^ 3) & 0xFFF), Address);
|
|
|
|
sprintf(Address, "DMEM + %Xh", ((Addr + 3) ^ 3) & 0xFFF);
|
|
|
|
MoveConstByteToVariable((Value >> 0) & 0xFF, RSPInfo.DMEM + (((Addr + 3) ^ 3) & 0xFFF), Address);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-16 23:29:22 +00:00
|
|
|
CompilerWarning(stdstr_f("Unaligned SW at constant address PC = %04X", CompilePC).c_str());
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::SW, "RSPOp::SW");
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprintf(Address, "DMEM + %Xh", Addr);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (IsRegConst(m_OpCode.rt))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveConstToVariable(MipsRegConst(m_OpCode.rt), RSPInfo.DMEM + Addr, Address);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, RSPInfo.DMEM + Addr, Address);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.base].UW, GPR_Name(m_OpCode.base), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
if (Offset != 0) AddConstToX86Reg(x86_EBX, Offset);
|
|
|
|
|
|
|
|
AndConstToX86Reg(x86_EBX, 0x0fff);
|
|
|
|
TestConstToX86Reg(3, x86_EBX);
|
|
|
|
JneLabel32("Unaligned", 0);
|
|
|
|
Jump[0] = RecompPos - 4;
|
|
|
|
|
|
|
|
CompilerToggleBuffer();
|
|
|
|
|
|
|
|
CPU_Message(" Unaligned:");
|
|
|
|
x86_SetBranch32b(Jump[0], RecompPos);
|
|
|
|
|
|
|
|
// X86BreakPoint(__FILE__,__LINE__);
|
|
|
|
|
|
|
|
Push(x86_EBX);
|
|
|
|
LeaSourceAndOffset(x86_ECX, x86_EBX, 2);
|
|
|
|
LeaSourceAndOffset(x86_EDX, x86_EBX, 3);
|
|
|
|
XorConstToX86Reg(x86_ECX, 3);
|
|
|
|
XorConstToX86Reg(x86_EDX, 3);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86regByte(&m_GPR[m_OpCode.rt].UB[1], GPR_Name(m_OpCode.rt), x86_EAX); // CX
|
|
|
|
MoveVariableToX86regByte(&m_GPR[m_OpCode.rt].UB[0], GPR_Name(m_OpCode.rt), x86_EBX); // DX
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86regByteToN64Mem(x86_EAX, x86_ECX);
|
|
|
|
MoveX86regByteToN64Mem(x86_EBX, x86_EDX);
|
|
|
|
Pop(x86_EBX);
|
|
|
|
|
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_EAX);
|
|
|
|
AddConstToX86Reg(x86_EBX, 1);
|
|
|
|
XorConstToX86Reg(x86_EAX, 3);
|
|
|
|
XorConstToX86Reg(x86_EBX, 3);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86regByte(&m_GPR[m_OpCode.rt].UB[3], GPR_Name(m_OpCode.rt), x86_ECX); // AX
|
|
|
|
MoveVariableToX86regByte(&m_GPR[m_OpCode.rt].UB[2], GPR_Name(m_OpCode.rt), x86_EDX); // BX
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
MoveX86regByteToN64Mem(x86_ECX, x86_EAX);
|
|
|
|
MoveX86regByteToN64Mem(x86_EDX, x86_EBX);
|
|
|
|
|
|
|
|
JmpLabel32("Done", 0);
|
|
|
|
Jump[1] = RecompPos - 4;
|
|
|
|
|
|
|
|
CompilerToggleBuffer();
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (IsRegConst(m_OpCode.rt))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveConstToN64Mem(MipsRegConst(m_OpCode.rt), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86regToN64Mem(x86_EAX, x86_EBX);
|
|
|
|
}
|
|
|
|
|
|
|
|
CPU_Message(" Done:");
|
|
|
|
x86_SetBranch32b(Jump[1], RecompPos);
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::LC2(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
(this->*RSP_Recomp_Lc2[m_OpCode.rd])();
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::SC2(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
(this->*RSP_Recomp_Sc2[m_OpCode.rd])();
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
2021-03-19 07:13:35 +00:00
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
// R4300i Opcodes: Special
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Special_SLL(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-06-20 07:58:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-06-01 11:46:23 +00:00
|
|
|
#ifndef Compile_Special
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Special_SLL, "RSPOp::Special_SLL");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == m_OpCode.rt)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
ShiftLeftSignVariableImmed(&m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd), (uint8_t)m_OpCode.sa);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt), x86_EAX);
|
|
|
|
ShiftLeftSignImmed(x86_EAX, (uint8_t)m_OpCode.sa);
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Special_SRL(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-06-20 07:58:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-06-01 11:46:23 +00:00
|
|
|
#ifndef Compile_Special
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Special_SRL, "RSPOp::Special_SRL");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == m_OpCode.rt)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
ShiftRightUnsignVariableImmed(&m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd), (uint8_t)m_OpCode.sa);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt), x86_EAX);
|
|
|
|
ShiftRightUnsignImmed(x86_EAX, (uint8_t)m_OpCode.sa);
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Special_SRA(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-06-20 07:58:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-06-01 11:46:23 +00:00
|
|
|
#ifndef Compile_Special
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Special_SRA, "RSPOp::Special_SRA");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == m_OpCode.rt)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
ShiftRightSignVariableImmed(&m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd), (uint8_t)m_OpCode.sa);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt), x86_EAX);
|
|
|
|
ShiftRightSignImmed(x86_EAX, (uint8_t)m_OpCode.sa);
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Special_SLLV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-06-20 07:58:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Special_SLLV, "RSPOp::Special_SLLV");
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Special_SRLV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-06-20 07:58:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-06-01 11:46:23 +00:00
|
|
|
#ifndef Compile_Special
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Special_SRLV, "RSPOp::Special_SRLV");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt), x86_EAX);
|
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), x86_ECX);
|
2023-06-01 11:46:23 +00:00
|
|
|
AndConstToX86Reg(x86_ECX, 0x1F);
|
|
|
|
ShiftRightUnsign(x86_EAX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Special_SRAV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-06-20 07:58:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Special_SRAV, "RSPOp::Special_SRAV");
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
void UpdateAudioTimer()
|
|
|
|
{
|
|
|
|
/* char Label[100];
|
2024-08-22 08:02:05 +00:00
|
|
|
sprintf(Label,"COMMAND: %02X (PC = %08X)",m_GPR[1].UW >> 1, *m_System.m_SP_PC_REG);
|
2016-01-27 09:39:06 +00:00
|
|
|
StartTimer(Label);*/
|
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Special_JR(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-08-16 23:29:22 +00:00
|
|
|
uint8_t * Jump;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-22 10:14:07 +00:00
|
|
|
if (m_NextInstruction == RSPPIPELINE_NORMAL)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-08-22 08:02:05 +00:00
|
|
|
// Transfer destination to location pointed to by m_System.m_SP_PC_REG
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
AndConstToX86Reg(x86_EAX, 0xFFC);
|
2024-08-22 08:02:05 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, m_System.m_SP_PC_REG, "RSP PC");
|
2023-06-29 02:59:07 +00:00
|
|
|
ChangedPC = true;
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_DONE)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 08:02:05 +00:00
|
|
|
MoveVariableToX86reg(m_System.m_SP_PC_REG, "RSP PC", x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
if (Profiling && IndvidualBlock)
|
|
|
|
{
|
|
|
|
Push(x86_EAX);
|
|
|
|
Push(x86_EAX);
|
2023-11-09 01:23:06 +00:00
|
|
|
Call_Direct((void *)StartTimer, "StartTimer");
|
2023-06-01 11:46:23 +00:00
|
|
|
AddConstToX86Reg(x86_ESP, 4);
|
|
|
|
Pop(x86_EAX);
|
|
|
|
}
|
|
|
|
AddVariableToX86reg(x86_EAX, &JumpTable, "JumpTable");
|
|
|
|
MoveX86regPointerToX86reg(x86_EAX, x86_EAX);
|
|
|
|
|
|
|
|
TestX86RegToX86Reg(x86_EAX, x86_EAX);
|
|
|
|
JeLabel8("Null", 0);
|
|
|
|
Jump = RecompPos - 1;
|
|
|
|
|
|
|
|
// Before we branch quickly update our stats
|
|
|
|
/*if (CompilePC == 0x080) {
|
2016-01-27 09:39:06 +00:00
|
|
|
Pushad();
|
2023-11-09 01:23:06 +00:00
|
|
|
Call_Direct((void *)UpdateAudioTimer, "UpdateAudioTimer");
|
2016-01-27 09:39:06 +00:00
|
|
|
Popad();
|
|
|
|
}*/
|
2023-06-01 11:46:23 +00:00
|
|
|
JumpX86Reg(x86_EAX);
|
|
|
|
|
|
|
|
x86_SetBranch8b(Jump, RecompPos);
|
|
|
|
CPU_Message(" Null:");
|
|
|
|
Ret();
|
2023-06-29 02:59:07 +00:00
|
|
|
ChangedPC = false;
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_EXIT_DONE)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
Ret();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
CompilerWarning(stdstr_f("WTF\n\nJR\nNextInstruction = %X", m_NextInstruction).c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
BreakPoint();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Special_JALR(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-08-16 23:29:22 +00:00
|
|
|
uint8_t * Jump;
|
2023-08-10 04:46:57 +00:00
|
|
|
uint32_t Const = (CompilePC + 8) & 0xFFC;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-22 10:14:07 +00:00
|
|
|
if (m_NextInstruction == RSPPIPELINE_NORMAL)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
AndConstToX86Reg(x86_EAX, 0xFFC);
|
2024-08-22 08:02:05 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, m_System.m_SP_PC_REG, "RSP PC");
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveConstToVariable(Const, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_DONE)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 08:02:05 +00:00
|
|
|
MoveVariableToX86reg(m_System.m_SP_PC_REG, "RSP PC", x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
AddVariableToX86reg(x86_EAX, &JumpTable, "JumpTable");
|
|
|
|
MoveX86regPointerToX86reg(x86_EAX, x86_EAX);
|
|
|
|
|
|
|
|
TestX86RegToX86Reg(x86_EAX, x86_EAX);
|
|
|
|
JeLabel8("Null", 0);
|
|
|
|
Jump = RecompPos - 1;
|
|
|
|
JumpX86Reg(x86_EAX);
|
|
|
|
|
|
|
|
x86_SetBranch8b(Jump, RecompPos);
|
|
|
|
CPU_Message(" Null:");
|
|
|
|
Ret();
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_EXIT_DONE)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
Ret();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
CompilerWarning(stdstr_f("WTF\n\nJALR\nNextInstruction = %X", m_NextInstruction).c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
BreakPoint();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Special_BREAK(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Special_BREAK, "RSPOp::Special_BREAK");
|
2024-08-22 10:14:07 +00:00
|
|
|
if (m_NextInstruction == RSPPIPELINE_NORMAL)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 08:02:05 +00:00
|
|
|
MoveConstToVariable(CompilePC + 4, m_System.m_SP_PC_REG, "RSP PC");
|
2023-06-01 11:46:23 +00:00
|
|
|
Ret();
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT)
|
2024-06-13 03:25:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DELAY_SLOT_EXIT;
|
2024-06-13 03:25:23 +00:00
|
|
|
}
|
2023-06-01 11:46:23 +00:00
|
|
|
else
|
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
CompilerWarning(stdstr_f("WTF\n\nBREAK\nNextInstruction = %X", m_NextInstruction).c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
BreakPoint();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Special_ADD(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-06-20 07:58:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-06-01 11:46:23 +00:00
|
|
|
#ifndef Compile_Special
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Special_ADD, "RSPOp::Special_ADD");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == m_OpCode.rs)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt), x86_EAX);
|
|
|
|
AddX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rd == m_OpCode.rt)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), x86_EAX);
|
|
|
|
AddX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs == m_OpCode.rt)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
AddX86RegToX86Reg(x86_EAX, x86_EAX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt), x86_EAX);
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rt == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), x86_EAX);
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), x86_EAX);
|
|
|
|
AddVariableToX86reg(x86_EAX, &m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt));
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Special_ADDU(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-06-20 07:58:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-06-01 11:46:23 +00:00
|
|
|
#ifndef Compile_Special
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Special_ADDU, "RSPOp::Special_ADDU");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == m_OpCode.rs)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt), x86_EAX);
|
|
|
|
AddX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rd == m_OpCode.rt)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), x86_EAX);
|
|
|
|
AddX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs == m_OpCode.rt)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
AddX86RegToX86Reg(x86_EAX, x86_EAX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt), x86_EAX);
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rt == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), x86_EAX);
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), x86_EAX);
|
|
|
|
AddVariableToX86reg(x86_EAX, &m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt));
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Special_SUB(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-06-20 07:58:51 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
#ifndef Compile_Special
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Special_SUB, "RSPOp::Special_SUB");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == m_OpCode.rs)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt), x86_EAX);
|
|
|
|
SubX86regFromVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, "m_GPR[m_OpCode.rd].W");
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs == m_OpCode.rt)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveConstToVariable(0, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), x86_EAX);
|
|
|
|
SubVariableFromX86reg(x86_EAX, &m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt));
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Special_SUBU(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-06-20 07:58:51 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
#ifndef Compile_Special
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Special_SUBU, "RSPOp::Special_SUBU");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == m_OpCode.rs)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt), x86_EAX);
|
|
|
|
SubX86regFromVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs == m_OpCode.rt)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveConstToVariable(0, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), x86_EAX);
|
|
|
|
SubVariableFromX86reg(x86_EAX, &m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt));
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Special_AND(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-06-20 07:58:51 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
#ifndef Compile_Special
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Special_AND, "RSPOp::Special_AND");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == m_OpCode.rs)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt), x86_EAX);
|
|
|
|
AndX86RegToVariable(&m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rd == m_OpCode.rt)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), x86_EAX);
|
|
|
|
AndX86RegToVariable(&m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs == m_OpCode.rt)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), x86_EAX);
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), x86_EAX);
|
|
|
|
AndVariableToX86Reg(&m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt), x86_EAX);
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Special_OR(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-06-20 07:58:51 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
#ifndef Compile_Special
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(RSPOp::Special_OR, "RSPOp::Special_OR");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == m_OpCode.rs)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt), x86_EAX);
|
|
|
|
OrX86RegToVariable(&m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rd == m_OpCode.rt)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), x86_EAX);
|
|
|
|
OrX86RegToVariable(&m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt), x86_EAX);
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rt == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), x86_EAX);
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), x86_EAX);
|
|
|
|
OrVariableToX86Reg(&m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt), x86_EAX);
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Special_XOR(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-06-20 07:58:51 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
#ifndef Compile_Special
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Special_XOR, "RSPOp::Special_XOR");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == m_OpCode.rs)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt), x86_EAX);
|
|
|
|
XorX86RegToVariable(&m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rd == m_OpCode.rt)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), x86_EAX);
|
|
|
|
XorX86RegToVariable(&m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs == m_OpCode.rt)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveConstToVariable(0, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs), x86_EAX);
|
|
|
|
XorVariableToX86reg(&m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt), x86_EAX);
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rd].W, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Special_NOR(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-06-20 07:58:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Special_NOR, "RSPOp::Special_NOR");
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Special_SLT(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#ifndef Compile_Special
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Special_SLT, "RSPOp::Special_SLT");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rt == m_OpCode.rs)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveConstToVariable(0, &m_GPR[m_OpCode.rd].UW, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
XorX86RegToX86Reg(x86_ECX, x86_ECX);
|
|
|
|
CompConstToX86reg(x86_EAX, 0);
|
|
|
|
Setg(x86_ECX);
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rt == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].UW, GPR_Name(m_OpCode.rs), x86_ECX);
|
2023-06-01 11:46:23 +00:00
|
|
|
ShiftRightUnsignImmed(x86_ECX, 31);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rs].UW, GPR_Name(m_OpCode.rs), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
XorX86RegToX86Reg(x86_ECX, x86_ECX);
|
2024-08-08 03:25:54 +00:00
|
|
|
CompX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
Setl(x86_ECX);
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_ECX, &m_GPR[m_OpCode.rd].UW, GPR_Name(m_OpCode.rd));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Special_SLTU(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == 0)
|
2024-06-20 07:58:51 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-06-20 07:58:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Special_SLTU, "RSPOp::Special_SLTU");
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
// R4300i Opcodes: RegImm
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::RegImm_BLTZ(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
static bool bDelayAffect;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-22 10:14:07 +00:00
|
|
|
if (m_NextInstruction == RSPPIPELINE_NORMAL)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
|
|
|
if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
bDelayAffect = DelaySlotAffectBranch(CompilePC);
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bDelayAffect)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
CompConstToVariable(0, &m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs));
|
2023-06-01 11:46:23 +00:00
|
|
|
SetlVariable(&BranchCompare, "BranchCompare");
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_DONE)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Target = (CompilePC + ((short)m_OpCode.offset << 2) + 4) & 0xFFC;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bDelayAffect)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CompConstToVariable(0, &m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs));
|
2023-06-01 11:46:23 +00:00
|
|
|
JlLabel32("BranchLess", 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Take a look at the branch compare variable
|
2023-06-29 02:59:07 +00:00
|
|
|
CompConstToVariable(true, &BranchCompare, "BranchCompare");
|
2023-06-01 11:46:23 +00:00
|
|
|
JeLabel32("BranchLess", 0);
|
|
|
|
}
|
2024-08-08 00:09:45 +00:00
|
|
|
m_Recompiler.Branch_AddRef(Target, (uint32_t *)(RecompPos - 4));
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_EXIT_DONE)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Target = (CompilePC + ((short)m_OpCode.offset << 2) + 4) & 0xFFC;
|
2023-06-01 11:46:23 +00:00
|
|
|
CompileBranchExit(Target, CompilePC + 8);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
CompilerWarning(stdstr_f("BLTZ error\nWeird Delay Slot.\n\nNextInstruction = %X\nPC = %X\nEmulation will now stop", m_NextInstruction, CompilePC).c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
BreakPoint();
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::RegImm_BGEZ(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
static bool bDelayAffect;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-22 10:14:07 +00:00
|
|
|
if (m_NextInstruction == RSPPIPELINE_NORMAL)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
|
|
|
if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
bDelayAffect = DelaySlotAffectBranch(CompilePC);
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bDelayAffect)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
CompConstToVariable(0, &m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs));
|
2023-06-01 11:46:23 +00:00
|
|
|
SetgeVariable(&BranchCompare, "BranchCompare");
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_DONE)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Target = (CompilePC + ((short)m_OpCode.offset << 2) + 4) & 0xFFC;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
JmpLabel32("BranchToJump", 0);
|
2024-08-08 00:09:45 +00:00
|
|
|
m_Recompiler.Branch_AddRef(Target, (uint32_t *)(RecompPos - 4));
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bDelayAffect)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CompConstToVariable(0, &m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs));
|
2023-06-01 11:46:23 +00:00
|
|
|
JgeLabel32("BranchGreaterEqual", 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Take a look at the branch compare variable
|
2023-06-29 02:59:07 +00:00
|
|
|
CompConstToVariable(true, &BranchCompare, "BranchCompare");
|
2023-06-01 11:46:23 +00:00
|
|
|
JeLabel32("BranchGreaterEqual", 0);
|
|
|
|
}
|
2024-08-08 00:09:45 +00:00
|
|
|
m_Recompiler.Branch_AddRef(Target, (uint32_t *)(RecompPos - 4));
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_EXIT_DONE)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Target = (CompilePC + ((short)m_OpCode.offset << 2) + 4) & 0xFFC;
|
2023-06-01 11:46:23 +00:00
|
|
|
CompileBranchExit(Target, CompilePC + 8);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
CompilerWarning(stdstr_f("BGEZ error\nWeird Delay Slot.\n\nNextInstruction = %X\nEmulation will now stop", m_NextInstruction).c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
BreakPoint();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::RegImm_BLTZAL(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
if (m_NextInstruction == RSPPIPELINE_NORMAL)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
|
|
|
if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveConstToVariable((CompilePC + 8) & 0xFFC, &m_GPR[31].UW, "RA.W");
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
CompConstToVariable(0, &m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs));
|
2023-06-01 11:46:23 +00:00
|
|
|
SetlVariable(&BranchCompare, "BranchCompare");
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveConstToVariable((CompilePC + 8) & 0xFFC, &m_GPR[31].UW, "RA.W");
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_DONE)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Target = (CompilePC + ((short)m_OpCode.offset << 2) + 4) & 0xFFC;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Take a look at the branch compare variable
|
2023-06-29 02:59:07 +00:00
|
|
|
CompConstToVariable(true, &BranchCompare, "BranchCompare");
|
2023-06-01 11:46:23 +00:00
|
|
|
JeLabel32("BranchLessEqual", 0);
|
2024-08-08 00:09:45 +00:00
|
|
|
m_Recompiler.Branch_AddRef(Target, (uint32_t *)(RecompPos - 4));
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_EXIT_DONE)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Target = (CompilePC + ((short)m_OpCode.offset << 2) + 4) & 0xFFC;
|
2023-06-01 11:46:23 +00:00
|
|
|
CompileBranchExit(Target, CompilePC + 8);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
CompilerWarning(stdstr_f("BLTZAL error\nWeird Delay Slot.\n\nNextInstruction = %X\nEmulation will now stop", m_NextInstruction).c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
BreakPoint();
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::RegImm_BGEZAL(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
static bool bDelayAffect;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-22 10:14:07 +00:00
|
|
|
if (m_NextInstruction == RSPPIPELINE_NORMAL)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
|
|
|
if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveConstToVariable((CompilePC + 8) & 0xFFC, &m_GPR[31].UW, "RA.W");
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
bDelayAffect = DelaySlotAffectBranch(CompilePC);
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bDelayAffect)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
CompConstToVariable(0, &m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs));
|
2023-06-01 11:46:23 +00:00
|
|
|
SetgeVariable(&BranchCompare, "BranchCompare");
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveConstToVariable((CompilePC + 8) & 0xFFC, &m_GPR[31].UW, "RA.W");
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DO_DELAY_SLOT;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_DONE)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Target = (CompilePC + ((short)m_OpCode.offset << 2) + 4) & 0xFFC;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rs == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
JmpLabel32("BranchToJump", 0);
|
2024-08-08 00:09:45 +00:00
|
|
|
m_Recompiler.Branch_AddRef(Target, (uint32_t *)(RecompPos - 4));
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bDelayAffect)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CompConstToVariable(0, &m_GPR[m_OpCode.rs].W, GPR_Name(m_OpCode.rs));
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveConstToVariable((CompilePC + 8) & 0xFFC, &m_GPR[31].UW, "RA.W");
|
2023-06-01 11:46:23 +00:00
|
|
|
JgeLabel32("BranchGreaterEqual", 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Take a look at the branch compare variable
|
2023-06-29 02:59:07 +00:00
|
|
|
CompConstToVariable(true, &BranchCompare, "BranchCompare");
|
2023-06-01 11:46:23 +00:00
|
|
|
JeLabel32("BranchGreaterEqual", 0);
|
|
|
|
}
|
2024-08-08 00:09:45 +00:00
|
|
|
m_Recompiler.Branch_AddRef(Target, (uint32_t *)(RecompPos - 4));
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT_EXIT_DONE)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Target = (CompilePC + ((short)m_OpCode.offset << 2) + 4) & 0xFFC;
|
2023-06-01 11:46:23 +00:00
|
|
|
CompileBranchExit(Target, CompilePC + 8);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
CompilerWarning(stdstr_f("BGEZAL error\nWeird Delay Slot.\n\nNextInstruction = %X\nEmulation will now stop", m_NextInstruction).c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
BreakPoint();
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2021-03-19 07:13:35 +00:00
|
|
|
// COP0 functions
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Cop0_MF(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
if (LogRDP)
|
|
|
|
{
|
|
|
|
char str[40];
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(str, "%d", m_OpCode.rd);
|
|
|
|
PushImm32(str, m_OpCode.rd);
|
2023-06-01 11:46:23 +00:00
|
|
|
sprintf(str, "%X", CompilePC);
|
|
|
|
PushImm32(str, CompilePC);
|
2024-08-15 04:13:56 +00:00
|
|
|
MoveConstToX86reg((uint32_t)(&RDPLog), x86_ECX);
|
|
|
|
Call_Direct(AddressOf(&CRDPLog::LogMF0), "CRDPLog::LogMF0");
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
|
|
|
#ifndef Compile_Cop0
|
2023-06-01 11:46:23 +00:00
|
|
|
Cheat_r4300iOpcode(RSP_Cop0_MF, "RSP_Cop0_MF");
|
2024-08-22 10:14:07 +00:00
|
|
|
if (m_NextInstruction == RSPPIPELINE_NORMAL)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 08:02:05 +00:00
|
|
|
MoveConstToVariable(CompilePC + 4, m_System.m_SP_PC_REG, "RSP PC");
|
2023-06-01 11:46:23 +00:00
|
|
|
Ret();
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DELAY_SLOT_EXIT;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
CompilerWarning(stdstr_f("MF error\nWeird Delay Slot.\n\nNextInstruction = %X\nEmulation will now stop", m_NextInstruction).c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
BreakPoint();
|
|
|
|
}
|
|
|
|
return;
|
2023-11-09 01:23:06 +00:00
|
|
|
#elif defined(_M_IX86) && defined(_MSC_VER)
|
2024-08-08 03:25:54 +00:00
|
|
|
switch (m_OpCode.rd)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
case 0:
|
2024-08-22 07:00:20 +00:00
|
|
|
MoveConstToX86reg((uint32_t)m_RSPRegisterHandler, x86_ECX);
|
2023-09-28 02:22:06 +00:00
|
|
|
PushImm32("RSPRegister_MEM_ADDR", RSPRegister_MEM_ADDR);
|
|
|
|
Call_Direct(AddressOf(&RSPRegisterHandlerPlugin::ReadReg), "RSPRegisterHandlerPlugin::ReadReg");
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2024-08-22 07:00:20 +00:00
|
|
|
MoveConstToX86reg((uint32_t)m_RSPRegisterHandler, x86_ECX);
|
2023-09-28 02:22:06 +00:00
|
|
|
PushImm32("RSPRegister_DRAM_ADDR", RSPRegister_DRAM_ADDR);
|
|
|
|
Call_Direct(AddressOf(&RSPRegisterHandlerPlugin::ReadReg), "RSPRegisterHandlerPlugin::ReadReg");
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
2024-06-20 09:52:57 +00:00
|
|
|
case 2:
|
2024-08-22 07:00:20 +00:00
|
|
|
MoveConstToX86reg((uint32_t)m_RSPRegisterHandler, x86_ECX);
|
2024-06-20 09:52:57 +00:00
|
|
|
PushImm32("RSPRegister_RD_LEN", RSPRegister_RD_LEN);
|
|
|
|
Call_Direct(AddressOf(&RSPRegisterHandlerPlugin::ReadReg), "RSPRegisterHandlerPlugin::ReadReg");
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2024-06-20 09:52:57 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2024-08-22 07:00:20 +00:00
|
|
|
MoveConstToX86reg((uint32_t)m_RSPRegisterHandler, x86_ECX);
|
2024-06-20 09:52:57 +00:00
|
|
|
PushImm32("RSPRegister_WR_LEN", RSPRegister_WR_LEN);
|
|
|
|
Call_Direct(AddressOf(&RSPRegisterHandlerPlugin::ReadReg), "RSPRegisterHandlerPlugin::ReadReg");
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2024-06-20 09:52:57 +00:00
|
|
|
break;
|
2024-06-20 07:58:51 +00:00
|
|
|
case 4:
|
2024-08-22 07:00:20 +00:00
|
|
|
MoveConstToX86reg((uint32_t)m_RSPRegisterHandler, x86_ECX);
|
2024-06-20 07:58:51 +00:00
|
|
|
PushImm32("RSPRegister_STATUS", RSPRegister_STATUS);
|
|
|
|
Call_Direct(AddressOf(&RSPRegisterHandlerPlugin::ReadReg), "RSPRegisterHandlerPlugin::ReadReg");
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2024-06-20 07:58:51 +00:00
|
|
|
break;
|
2023-06-01 11:46:23 +00:00
|
|
|
case 5:
|
|
|
|
MoveVariableToX86reg(RSPInfo.SP_DMA_FULL_REG, "SP_DMA_FULL_REG", x86_EAX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
MoveVariableToX86reg(RSPInfo.SP_DMA_BUSY_REG, "SP_DMA_BUSY_REG", x86_EAX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
if (AudioHle || GraphicsHle || SemaphoreExit == 0)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveConstToVariable(0, &m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MoveVariableToX86reg(RSPInfo.SP_SEMAPHORE_REG, "SP_SEMAPHORE_REG", x86_EAX);
|
|
|
|
MoveConstToVariable(0, &RSP_Running, "RSP_Running");
|
|
|
|
MoveConstToVariable(1, RSPInfo.SP_SEMAPHORE_REG, "SP_SEMAPHORE_REG");
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt));
|
2024-08-22 10:14:07 +00:00
|
|
|
if (m_NextInstruction == RSPPIPELINE_NORMAL)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 08:02:05 +00:00
|
|
|
MoveConstToVariable(CompilePC + 4, m_System.m_SP_PC_REG, "RSP PC");
|
2023-06-01 11:46:23 +00:00
|
|
|
Ret();
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_SUB_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DELAY_SLOT_EXIT;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
CompilerWarning(stdstr_f("MF error\nWeird Delay Slot.\n\nNextInstruction = %X\nEmulation will now stop", m_NextInstruction).c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
BreakPoint();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
MoveVariableToX86reg(RSPInfo.DPC_START_REG, "DPC_START_REG", x86_EAX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
MoveVariableToX86reg(RSPInfo.DPC_END_REG, "DPC_END_REG", x86_EAX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
MoveVariableToX86reg(RSPInfo.DPC_CURRENT_REG, "DPC_CURRENT_REG", x86_EAX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
case 11:
|
|
|
|
MoveVariableToX86reg(RSPInfo.DPC_STATUS_REG, "DPC_STATUS_REG", x86_EAX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
MoveVariableToX86reg(RSPInfo.DPC_CLOCK_REG, "DPC_CLOCK_REG", x86_EAX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2024-08-08 03:25:54 +00:00
|
|
|
g_Notify->DisplayError(stdstr_f("We have not implemented RSP MF CP0 reg %s (%d)", COP0_Name(m_OpCode.rd), m_OpCode.rd).c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2023-11-09 01:23:06 +00:00
|
|
|
#else
|
|
|
|
g_Notify->BreakPoint(__FILE__, __LINE__);
|
2016-01-27 09:39:06 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Cop0_MT(void)
|
2016-01-27 09:39:06 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
if (LogRDP)
|
|
|
|
{
|
|
|
|
char str[40];
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
Push(x86_EAX);
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(str, "%d", m_OpCode.rd);
|
|
|
|
PushImm32(str, m_OpCode.rd);
|
2023-06-01 11:46:23 +00:00
|
|
|
sprintf(str, "%X", CompilePC);
|
|
|
|
PushImm32(str, CompilePC);
|
2024-08-15 04:13:56 +00:00
|
|
|
MoveConstToX86reg((uint32_t)(&RDPLog), x86_ECX);
|
|
|
|
Call_Direct(AddressOf(&CRDPLog::LogMT0), "CRDPLog::LogMT0");
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
|
|
|
#ifndef Compile_Cop0
|
2023-06-01 11:46:23 +00:00
|
|
|
Cheat_r4300iOpcode(RSP_Cop0_MT, "RSP_Cop0_MT");
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == 4)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
if (m_NextInstruction == RSPPIPELINE_NORMAL)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 08:02:05 +00:00
|
|
|
MoveConstToVariable(CompilePC + 4, m_System.m_SP_PC_REG, "RSP PC");
|
2023-06-01 11:46:23 +00:00
|
|
|
Ret();
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_BLOCK;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DELAY_SLOT_EXIT;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
CompilerWarning(stdstr_f("MF error\nWeird Delay Slot.\n\nNextInstruction = %X\nEmulation will now stop", m_NextInstruction).c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
BreakPoint();
|
|
|
|
}
|
|
|
|
}
|
2023-11-09 01:23:06 +00:00
|
|
|
#elif defined(_M_IX86) && defined(_MSC_VER)
|
2024-08-08 03:25:54 +00:00
|
|
|
switch (m_OpCode.rd)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
case 0:
|
2024-08-22 07:00:20 +00:00
|
|
|
MoveConstToX86reg((uint32_t)m_RSPRegisterHandler, x86_ECX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt), x86_EAX);
|
2023-09-28 02:22:06 +00:00
|
|
|
Push(x86_EAX);
|
|
|
|
PushImm32("RSPRegister_MEM_ADDR", RSPRegister_MEM_ADDR);
|
|
|
|
Call_Direct(AddressOf(&RSPRegisterHandlerPlugin::WriteReg), "RSPRegisterHandlerPlugin::WriteReg");
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2024-08-22 07:00:20 +00:00
|
|
|
MoveConstToX86reg((uint32_t)m_RSPRegisterHandler, x86_ECX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt), x86_EAX);
|
2023-09-28 02:22:06 +00:00
|
|
|
Push(x86_EAX);
|
|
|
|
PushImm32("RSPRegister_DRAM_ADDR", RSPRegister_DRAM_ADDR);
|
|
|
|
Call_Direct(AddressOf(&RSPRegisterHandlerPlugin::WriteReg), "RSPRegisterHandlerPlugin::WriteReg");
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2024-08-22 07:00:20 +00:00
|
|
|
MoveConstToX86reg((uint32_t)m_RSPRegisterHandler, x86_ECX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt), x86_EAX);
|
2023-09-28 02:22:06 +00:00
|
|
|
Push(x86_EAX);
|
|
|
|
PushImm32("RSPRegister_RD_LEN", RSPRegister_RD_LEN);
|
|
|
|
Call_Direct(AddressOf(&RSPRegisterHandlerPlugin::WriteReg), "RSPRegisterHandlerPlugin::WriteReg");
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2024-08-22 07:00:20 +00:00
|
|
|
MoveConstToX86reg((uint32_t)m_RSPRegisterHandler, x86_ECX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt), x86_EAX);
|
2023-09-28 02:22:06 +00:00
|
|
|
Push(x86_EAX);
|
|
|
|
PushImm32("RSPRegister_WR_LEN", RSPRegister_WR_LEN);
|
|
|
|
Call_Direct(AddressOf(&RSPRegisterHandlerPlugin::WriteReg), "RSPRegisterHandlerPlugin::WriteReg");
|
|
|
|
break;
|
|
|
|
case 4:
|
2024-08-22 07:00:20 +00:00
|
|
|
MoveConstToX86reg((uint32_t)m_RSPRegisterHandler, x86_ECX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt), x86_EAX);
|
2023-09-28 02:22:06 +00:00
|
|
|
Push(x86_EAX);
|
|
|
|
PushImm32("RSPRegister_STATUS", RSPRegister_STATUS);
|
|
|
|
Call_Direct(AddressOf(&RSPRegisterHandlerPlugin::WriteReg), "RSPRegisterHandlerPlugin::WriteReg");
|
2024-08-22 10:14:07 +00:00
|
|
|
if (m_NextInstruction == RSPPIPELINE_NORMAL)
|
2023-09-28 02:22:06 +00:00
|
|
|
{
|
2024-08-22 08:02:05 +00:00
|
|
|
MoveConstToVariable(CompilePC + 4, m_System.m_SP_PC_REG, "RSP PC");
|
2023-09-28 02:22:06 +00:00
|
|
|
Ret();
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_BLOCK;
|
2023-09-28 02:22:06 +00:00
|
|
|
}
|
2024-08-22 10:14:07 +00:00
|
|
|
else if (m_NextInstruction == RSPPIPELINE_DELAY_SLOT)
|
2023-09-28 02:22:06 +00:00
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_DELAY_SLOT_EXIT;
|
2023-09-28 02:22:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-22 10:14:07 +00:00
|
|
|
CompilerWarning(stdstr_f("MF error\nWeird Delay Slot.\n\nNextInstruction = %X\nEmulation will now stop", m_NextInstruction).c_str());
|
2023-09-28 02:22:06 +00:00
|
|
|
BreakPoint();
|
|
|
|
}
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
MoveConstToVariable(0, RSPInfo.SP_SEMAPHORE_REG, "SP_SEMAPHORE_REG");
|
|
|
|
break;
|
|
|
|
case 8:
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, RSPInfo.DPC_START_REG, "DPC_START_REG");
|
|
|
|
MoveX86regToVariable(x86_EAX, RSPInfo.DPC_CURRENT_REG, "DPC_CURRENT_REG");
|
|
|
|
break;
|
|
|
|
case 9:
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, RSPInfo.DPC_END_REG, "DPC_END_REG");
|
|
|
|
|
|
|
|
if (LogRDP)
|
|
|
|
{
|
2024-08-15 04:13:56 +00:00
|
|
|
MoveConstToX86reg((uint32_t)(&RDPLog), x86_ECX);
|
|
|
|
Call_Direct(AddressOf(&CRDPLog::LogDlist), "CRDPLog::LogDlist");
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (RSPInfo.ProcessRdpList != NULL)
|
|
|
|
{
|
|
|
|
if (Profiling)
|
|
|
|
{
|
2023-08-10 04:46:57 +00:00
|
|
|
PushImm32("Timer_RDP_Running", (uint32_t)Timer_RDP_Running);
|
2023-11-09 01:23:06 +00:00
|
|
|
Call_Direct((void *)StartTimer, "StartTimer");
|
2023-06-01 11:46:23 +00:00
|
|
|
AddConstToX86Reg(x86_ESP, 4);
|
|
|
|
Push(x86_EAX);
|
|
|
|
}
|
2023-11-09 01:23:06 +00:00
|
|
|
Call_Direct((void *)RSPInfo.ProcessRdpList, "ProcessRdpList");
|
2023-06-01 11:46:23 +00:00
|
|
|
if (Profiling)
|
|
|
|
{
|
2023-11-09 01:23:06 +00:00
|
|
|
Call_Direct((void *)StartTimer, "StartTimer");
|
2023-06-01 11:46:23 +00:00
|
|
|
AddConstToX86Reg(x86_ESP, 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 10:
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.rt].UW, GPR_Name(m_OpCode.rt), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, RSPInfo.DPC_CURRENT_REG, "DPC_CURRENT_REG");
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Cop0_MT, "RSPOp::Cop0_MT");
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
}
|
2023-11-09 01:23:06 +00:00
|
|
|
#else
|
2023-11-09 02:29:40 +00:00
|
|
|
g_Notify->BreakPoint(__FILE__, __LINE__);
|
2016-01-27 09:39:06 +00:00
|
|
|
#endif
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == 2 && !ChangedPC)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-08-16 23:29:22 +00:00
|
|
|
uint8_t * Jump;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
TestConstToVariable(0x1000, RSPInfo.SP_MEM_ADDR_REG, "RSPInfo.SP_MEM_ADDR_REG");
|
|
|
|
JeLabel8("DontExit", 0);
|
|
|
|
Jump = RecompPos - 1;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-22 08:02:05 +00:00
|
|
|
MoveConstToVariable(CompilePC + 4, m_System.m_SP_PC_REG, "RSP PC");
|
2023-06-01 11:46:23 +00:00
|
|
|
Ret();
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
CPU_Message("DontExit:");
|
|
|
|
x86_SetBranch8b(Jump, RecompPos);
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
2021-03-19 07:13:35 +00:00
|
|
|
|
|
|
|
// COP2 functions
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Cop2_MF(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rt == 0)
|
2024-07-06 09:23:19 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-07-06 09:23:19 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-06-20 07:58:51 +00:00
|
|
|
#ifndef Compile_Cop2
|
|
|
|
Cheat_r4300iOpcode(RSP_Cop2_MF, "RSP_Cop2_MF");
|
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2024-08-08 03:25:54 +00:00
|
|
|
uint8_t element = (uint8_t)(m_OpCode.sa >> 1);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t element1 = 15 - element;
|
|
|
|
uint8_t element2 = 15 - ((element + 1) % 16);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
if (element2 != (element1 - 1))
|
|
|
|
{
|
|
|
|
XorX86RegToX86Reg(x86_EAX, x86_EAX);
|
|
|
|
XorX86RegToX86Reg(x86_EBX, x86_EBX);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rd, element1);
|
|
|
|
MoveVariableToX86regByte(&m_Vect[m_OpCode.vs].s8(element1), Reg, x86_EAX);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rd, element2);
|
|
|
|
MoveVariableToX86regByte(&m_Vect[m_OpCode.vs].s8(element2), Reg, x86_EBX);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
ShiftLeftSignImmed(x86_EAX, 8);
|
|
|
|
OrX86RegToX86Reg(x86_EAX, x86_EBX);
|
|
|
|
Cwde();
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rd, element2);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vs].s8(element2), Reg, x86_EAX);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Cop2_CF(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
#ifndef Compile_Cop2
|
|
|
|
Cheat_r4300iOpcode(RSP_Cop2_CF, "RSP_Cop2_CF");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
switch ((m_OpCode.rd & 0x03))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
case 0:
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveSxVariableToX86regHalf(&m_Flags[0].HW[0], "m_Flags[0].HW[0]", x86_EAX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveSxVariableToX86regHalf(&m_Flags[1].HW[0], "m_Flags[1].HW[0]", x86_EAX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 3:
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveSxVariableToX86regHalf(&m_Flags[2].HW[0], "m_Flags[2].HW[0]", x86_EAX);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_GPR[m_OpCode.rt].W, GPR_Name(m_OpCode.rt));
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Cop2_MT(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
#ifndef Compile_Cop2
|
|
|
|
Cheat_r4300iOpcode(RSP_Cop2_MT, "RSP_Cop2_MT");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-06-20 07:58:51 +00:00
|
|
|
char Reg[256];
|
2024-08-08 03:25:54 +00:00
|
|
|
uint8_t element = (uint8_t)(15 - (m_OpCode.sa >> 1));
|
2024-06-20 07:58:51 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
if (element == 0)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_GPR[%i].B[1]", m_OpCode.rt);
|
|
|
|
MoveVariableToX86regByte(&m_GPR[m_OpCode.rt].B[1], Reg, x86_EAX);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rd, element);
|
|
|
|
MoveX86regByteToVariable(x86_EAX, &m_Vect[m_OpCode.vs].s8(element), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_GPR[%i].B[0]", m_OpCode.rt);
|
|
|
|
MoveVariableToX86regHalf(&m_GPR[m_OpCode.rt].B[0], Reg, x86_EAX);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rd, element - 1);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_Vect[m_OpCode.vs].s8(element - 1), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Cop2_CT(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
#ifndef Compile_Cop2
|
|
|
|
Cheat_r4300iOpcode(RSP_Cop2_CT, "RSP_Cop2_CT");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rt == 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
switch ((m_OpCode.rd & 0x03))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
case 0:
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveConstHalfToVariable(0, &m_Flags[0].HW[0], "m_Flags[0].HW[0]");
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveConstHalfToVariable(0, &m_Flags[1].HW[0], "m_Flags[1].HW[0]");
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 3:
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveConstByteToVariable(0, &m_Flags[2].B[0], "m_Flags[2].B[0]");
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
switch ((m_OpCode.rd & 0x03))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
case 0:
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86regHalf(&m_GPR[m_OpCode.rt].HW[0], GPR_Name(m_OpCode.rt), x86_EAX);
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_Flags[0].HW[0], "m_Flags[0].HW[0]");
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86regHalf(&m_GPR[m_OpCode.rt].HW[0], GPR_Name(m_OpCode.rt), x86_EAX);
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_Flags[1].HW[0], "m_Flags[1].HW[0]");
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 3:
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86regByte(&m_GPR[m_OpCode.rt].B[0], GPR_Name(m_OpCode.rt), x86_EAX);
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveX86regByteToVariable(x86_EAX, &m_Flags[2].B[0], "m_Flags[2].B[0]");
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::COP2_VECTOR(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
(this->*RSP_Recomp_Vector[m_OpCode.funct])();
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2021-03-19 07:13:35 +00:00
|
|
|
// Vector functions
|
2016-01-27 09:39:06 +00:00
|
|
|
|
|
|
|
UDWORD MMX_Scratch;
|
|
|
|
|
2024-08-22 10:14:07 +00:00
|
|
|
bool CRSPRecompilerOps::IsNextInstructionMmx(uint32_t PC)
|
|
|
|
{
|
|
|
|
RSPOpcode RspOp;
|
|
|
|
|
|
|
|
if (!IsMmxEnabled)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
PC += 4;
|
|
|
|
if (PC >= 0x1000) return false;
|
|
|
|
RspOp.Value = *(uint32_t *)(RSPInfo.IMEM + (PC & 0xFFC));
|
|
|
|
|
|
|
|
if (RspOp.op != RSP_CP2)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((RspOp.rs & 0x10) != 0)
|
|
|
|
{
|
|
|
|
switch (RspOp.funct)
|
|
|
|
{
|
|
|
|
case RSP_VECTOR_VMULF:
|
|
|
|
case RSP_VECTOR_VMUDL: // Warning: Not all handled?
|
|
|
|
case RSP_VECTOR_VMUDM:
|
|
|
|
case RSP_VECTOR_VMUDN:
|
|
|
|
case RSP_VECTOR_VMUDH:
|
|
|
|
if (true == WriteToAccum(7, PC))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if ((RspOp.rs & 0x0f) >= 2 && (RspOp.rs & 0x0f) <= 7 && IsMmx2Enabled == false)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case RSP_VECTOR_VABS:
|
|
|
|
case RSP_VECTOR_VAND:
|
|
|
|
case RSP_VECTOR_VOR:
|
|
|
|
case RSP_VECTOR_VXOR:
|
|
|
|
case RSP_VECTOR_VNAND:
|
|
|
|
case RSP_VECTOR_VNOR:
|
|
|
|
case RSP_VECTOR_VNXOR:
|
|
|
|
if (true == WriteToAccum(Low16BitAccum, PC))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if ((RspOp.rs & 0x0f) >= 2 && (RspOp.rs & 0x0f) <= 7 && IsMmx2Enabled == false)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case RSP_VECTOR_VADD:
|
|
|
|
case RSP_VECTOR_VSUB:
|
|
|
|
// Requires no accumulator write, and no flags!
|
|
|
|
if (WriteToAccum(Low16BitAccum, PC) == true)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if (UseRspFlags(PC) == true)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if ((RspOp.rs & 0x0f) >= 2 && (RspOp.rs & 0x0f) <= 7 && IsMmx2Enabled == false)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CRSPRecompilerOps::UseRspFlags(int PC)
|
|
|
|
{
|
|
|
|
RSPOpcode RspOp;
|
|
|
|
int Instruction_State = m_NextInstruction;
|
|
|
|
|
|
|
|
if (Compiler.bFlags == false) return true;
|
|
|
|
|
|
|
|
if (Instruction_State == RSPPIPELINE_DELAY_SLOT)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
PC -= 4;
|
|
|
|
if (PC < 0)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
RspOp.Value = *(uint32_t *)(RSPInfo.IMEM + (PC & 0xFFC));
|
|
|
|
|
|
|
|
switch (RspOp.op)
|
|
|
|
{
|
|
|
|
|
|
|
|
case RSP_REGIMM:
|
|
|
|
switch (RspOp.rt)
|
|
|
|
{
|
|
|
|
case RSP_REGIMM_BLTZ:
|
|
|
|
case RSP_REGIMM_BGEZ:
|
|
|
|
case RSP_REGIMM_BLTZAL:
|
|
|
|
case RSP_REGIMM_BGEZAL:
|
|
|
|
Instruction_State = RSPPIPELINE_DO_DELAY_SLOT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
CompilerWarning(stdstr_f("Unknown opcode in UseRspFlags\n%s", RSPInstruction(PC, RspOp.Value).NameAndParam().c_str()).c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RSP_SPECIAL:
|
|
|
|
switch (RspOp.funct)
|
|
|
|
{
|
|
|
|
case RSP_SPECIAL_SLL:
|
|
|
|
case RSP_SPECIAL_SRL:
|
|
|
|
case RSP_SPECIAL_SRA:
|
|
|
|
case RSP_SPECIAL_SLLV:
|
|
|
|
case RSP_SPECIAL_SRLV:
|
|
|
|
case RSP_SPECIAL_SRAV:
|
|
|
|
case RSP_SPECIAL_ADD:
|
|
|
|
case RSP_SPECIAL_ADDU:
|
|
|
|
case RSP_SPECIAL_SUB:
|
|
|
|
case RSP_SPECIAL_SUBU:
|
|
|
|
case RSP_SPECIAL_AND:
|
|
|
|
case RSP_SPECIAL_OR:
|
|
|
|
case RSP_SPECIAL_XOR:
|
|
|
|
case RSP_SPECIAL_NOR:
|
|
|
|
case RSP_SPECIAL_SLT:
|
|
|
|
case RSP_SPECIAL_SLTU:
|
|
|
|
case RSP_SPECIAL_BREAK:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RSP_SPECIAL_JR:
|
|
|
|
Instruction_State = RSPPIPELINE_DO_DELAY_SLOT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
CompilerWarning(stdstr_f("Unknown opcode in WriteToVectorDest\n%s", RSPInstruction(PC, RspOp.Value).NameAndParam().c_str()).c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RSP_J:
|
|
|
|
case RSP_JAL:
|
|
|
|
case RSP_BEQ:
|
|
|
|
case RSP_BNE:
|
|
|
|
case RSP_BLEZ:
|
|
|
|
case RSP_BGTZ:
|
|
|
|
Instruction_State = RSPPIPELINE_DO_DELAY_SLOT;
|
|
|
|
break;
|
|
|
|
case RSP_ADDI:
|
|
|
|
case RSP_ADDIU:
|
|
|
|
case RSP_SLTI:
|
|
|
|
case RSP_SLTIU:
|
|
|
|
case RSP_ANDI:
|
|
|
|
case RSP_ORI:
|
|
|
|
case RSP_XORI:
|
|
|
|
case RSP_LUI:
|
|
|
|
case RSP_CP0:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RSP_CP2:
|
|
|
|
if ((RspOp.rs & 0x10) != 0)
|
|
|
|
{
|
|
|
|
switch (RspOp.funct)
|
|
|
|
{
|
|
|
|
case RSP_VECTOR_VMULF:
|
|
|
|
case RSP_VECTOR_VMULU:
|
|
|
|
case RSP_VECTOR_VMUDL:
|
|
|
|
case RSP_VECTOR_VMUDM:
|
|
|
|
case RSP_VECTOR_VMUDN:
|
|
|
|
case RSP_VECTOR_VMUDH:
|
|
|
|
break;
|
|
|
|
case RSP_VECTOR_VMACF:
|
|
|
|
case RSP_VECTOR_VMACU:
|
|
|
|
case RSP_VECTOR_VMADL:
|
|
|
|
case RSP_VECTOR_VMADM:
|
|
|
|
case RSP_VECTOR_VMADN:
|
|
|
|
case RSP_VECTOR_VMADH:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RSP_VECTOR_VSUB:
|
|
|
|
case RSP_VECTOR_VADD:
|
|
|
|
return false;
|
|
|
|
case RSP_VECTOR_VSUBC:
|
|
|
|
case RSP_VECTOR_VADDC:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case RSP_VECTOR_VABS:
|
|
|
|
case RSP_VECTOR_VAND:
|
|
|
|
case RSP_VECTOR_VOR:
|
|
|
|
case RSP_VECTOR_VXOR:
|
|
|
|
case RSP_VECTOR_VNAND:
|
|
|
|
case RSP_VECTOR_VNOR:
|
|
|
|
case RSP_VECTOR_VNXOR:
|
|
|
|
case RSP_VECTOR_VRCPH:
|
|
|
|
case RSP_VECTOR_VRSQL:
|
|
|
|
case RSP_VECTOR_VRSQH:
|
|
|
|
case RSP_VECTOR_VRCPL:
|
|
|
|
case RSP_VECTOR_VRCP:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RSP_VECTOR_VCR:
|
|
|
|
case RSP_VECTOR_VCH:
|
|
|
|
case RSP_VECTOR_VCL:
|
|
|
|
case RSP_VECTOR_VLT:
|
|
|
|
case RSP_VECTOR_VEQ:
|
|
|
|
case RSP_VECTOR_VGE:
|
|
|
|
case RSP_VECTOR_VNE:
|
|
|
|
case RSP_VECTOR_VMRG:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case RSP_VECTOR_VSAW:
|
|
|
|
case RSP_VECTOR_VMOV:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
CompilerWarning(stdstr_f("Unknown opcode in UseRspFlags\n%s", RSPInstruction(PC, RspOp.Value).NameAndParam().c_str()).c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (RspOp.rs)
|
|
|
|
{
|
|
|
|
case RSP_COP2_CT:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case RSP_COP2_CF:
|
|
|
|
case RSP_COP2_MT:
|
|
|
|
case RSP_COP2_MF:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
CompilerWarning(stdstr_f("Unknown opcode in UseRspFlags\n%s", RSPInstruction(PC, RspOp.Value).NameAndParam().c_str()).c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RSP_LB:
|
|
|
|
case RSP_LH:
|
|
|
|
case RSP_LW:
|
|
|
|
case RSP_LBU:
|
|
|
|
case RSP_LHU:
|
|
|
|
case RSP_SB:
|
|
|
|
case RSP_SH:
|
|
|
|
case RSP_SW:
|
|
|
|
break;
|
|
|
|
case RSP_LC2:
|
|
|
|
switch (RspOp.rd)
|
|
|
|
{
|
|
|
|
case RSP_LSC2_BV:
|
|
|
|
case RSP_LSC2_SV:
|
|
|
|
case RSP_LSC2_DV:
|
|
|
|
case RSP_LSC2_RV:
|
|
|
|
case RSP_LSC2_QV:
|
|
|
|
case RSP_LSC2_LV:
|
|
|
|
case RSP_LSC2_UV:
|
|
|
|
case RSP_LSC2_PV:
|
|
|
|
case RSP_LSC2_TV:
|
|
|
|
case RSP_LSC2_HV:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
CompilerWarning(stdstr_f("Unknown opcode in UseRspFlags\n%s", RSPInstruction(PC, RspOp.Value).NameAndParam().c_str()).c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RSP_SC2:
|
|
|
|
switch (RspOp.rd)
|
|
|
|
{
|
|
|
|
case RSP_LSC2_BV:
|
|
|
|
case RSP_LSC2_SV:
|
|
|
|
case RSP_LSC2_LV:
|
|
|
|
case RSP_LSC2_DV:
|
|
|
|
case RSP_LSC2_QV:
|
|
|
|
case RSP_LSC2_RV:
|
|
|
|
case RSP_LSC2_PV:
|
|
|
|
case RSP_LSC2_UV:
|
|
|
|
case RSP_LSC2_HV:
|
|
|
|
case RSP_LSC2_FV:
|
|
|
|
case RSP_LSC2_WV:
|
|
|
|
case RSP_LSC2_TV:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
CompilerWarning(stdstr_f("Unknown opcode in UseRspFlags\n%s", RSPInstruction(PC, RspOp.Value).NameAndParam().c_str()).c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
CompilerWarning(stdstr_f("Unknown opcode in UseRspFlags\n%s", RSPInstruction(PC, RspOp.Value).NameAndParam().c_str()).c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
switch (Instruction_State)
|
|
|
|
{
|
|
|
|
case RSPPIPELINE_NORMAL: break;
|
|
|
|
case RSPPIPELINE_DO_DELAY_SLOT:
|
|
|
|
Instruction_State = RSPPIPELINE_DELAY_SLOT;
|
|
|
|
break;
|
|
|
|
case RSPPIPELINE_DELAY_SLOT:
|
|
|
|
Instruction_State = RSPPIPELINE_FINISH_BLOCK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (Instruction_State != RSPPIPELINE_FINISH_BLOCK);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CRSPRecompilerOps::WriteToAccum(int Location, int PC)
|
|
|
|
{
|
|
|
|
uint32_t value = WriteToAccum2(Location, PC, false);
|
|
|
|
|
|
|
|
if (value == HIT_BRANCH)
|
|
|
|
{
|
|
|
|
return true; /* ??? */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return value != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t CRSPRecompilerOps::WriteToAccum2(int Location, int PC, bool RecursiveCall)
|
|
|
|
{
|
|
|
|
RSPOpcode RspOp;
|
|
|
|
uint32_t BranchTarget = 0;
|
|
|
|
signed int BranchImmed = 0;
|
|
|
|
int Instruction_State = m_NextInstruction;
|
|
|
|
|
|
|
|
if (Compiler.bAccum == false) return true;
|
|
|
|
|
|
|
|
if (Instruction_State == RSPPIPELINE_DELAY_SLOT)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
PC += 4;
|
|
|
|
if (PC >= 0x1000)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
RspOp.Value = *(uint32_t *)(RSPInfo.IMEM + (PC & 0xFFC));
|
|
|
|
|
|
|
|
switch (RspOp.op)
|
|
|
|
{
|
|
|
|
case RSP_REGIMM:
|
|
|
|
switch (RspOp.rt)
|
|
|
|
{
|
|
|
|
case RSP_REGIMM_BLTZ:
|
|
|
|
case RSP_REGIMM_BGEZ:
|
|
|
|
case RSP_REGIMM_BLTZAL:
|
|
|
|
case RSP_REGIMM_BGEZAL:
|
|
|
|
Instruction_State = RSPPIPELINE_DO_DELAY_SLOT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
CompilerWarning(stdstr_f("Unknown opcode in WriteToAccum\n%s", RSPInstruction(PC, RspOp.Value).NameAndParam().c_str()).c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RSP_SPECIAL:
|
|
|
|
switch (RspOp.funct)
|
|
|
|
{
|
|
|
|
case RSP_SPECIAL_SLL:
|
|
|
|
case RSP_SPECIAL_SRL:
|
|
|
|
case RSP_SPECIAL_SRA:
|
|
|
|
case RSP_SPECIAL_SLLV:
|
|
|
|
case RSP_SPECIAL_SRLV:
|
|
|
|
case RSP_SPECIAL_SRAV:
|
|
|
|
case RSP_SPECIAL_ADD:
|
|
|
|
case RSP_SPECIAL_ADDU:
|
|
|
|
case RSP_SPECIAL_SUB:
|
|
|
|
case RSP_SPECIAL_SUBU:
|
|
|
|
case RSP_SPECIAL_AND:
|
|
|
|
case RSP_SPECIAL_OR:
|
|
|
|
case RSP_SPECIAL_XOR:
|
|
|
|
case RSP_SPECIAL_NOR:
|
|
|
|
case RSP_SPECIAL_SLT:
|
|
|
|
case RSP_SPECIAL_SLTU:
|
|
|
|
case RSP_SPECIAL_BREAK:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RSP_SPECIAL_JALR:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case RSP_SPECIAL_JR:
|
|
|
|
Instruction_State = RSPPIPELINE_DO_DELAY_SLOT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
CompilerWarning(stdstr_f("Unknown opcode in WriteToAccum\n%s", RSPInstruction(PC, RspOp.Value).NameAndParam().c_str()).c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RSP_J:
|
|
|
|
// There is no way a loopback is going to use accumulator
|
|
|
|
if (Compiler.bAudioUcode && (((int)(RspOp.target << 2) & 0xFFC) < PC))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// Rarely occurs, so we let them have their way
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Instruction_State = RSPPIPELINE_DO_DELAY_SLOT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case RSP_JAL:
|
|
|
|
// There is no way calling a subroutine is going to use an accumulator
|
|
|
|
// or come back and continue an existing calculation
|
|
|
|
if (Compiler.bAudioUcode)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Instruction_State = RSPPIPELINE_DO_DELAY_SLOT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case RSP_BEQ:
|
|
|
|
case RSP_BNE:
|
|
|
|
case RSP_BLEZ:
|
|
|
|
case RSP_BGTZ:
|
|
|
|
BranchImmed = (short)RspOp.offset;
|
|
|
|
if (Compiler.bAudioUcode)
|
|
|
|
{
|
|
|
|
RSPOpcode NextOp;
|
|
|
|
|
|
|
|
// Ignore backward branches and pretend it's a NOP
|
|
|
|
if (BranchImmed <= 0)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// If the opcode (which is 8 bytes before the destination and also a J backward) then ignore this
|
|
|
|
BranchImmed = (PC + ((short)RspOp.offset << 2) + 4) & 0xFFC;
|
|
|
|
NextOp.Value = *(uint32_t *)(RSPInfo.IMEM + ((BranchImmed - 8) & 0xFFC));
|
|
|
|
|
|
|
|
if (RspOp.op == RSP_J && (int)(RspOp.target << 2) < PC)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BranchTarget = (PC + ((short)RspOp.offset << 2) + 4) & 0xFFC;
|
|
|
|
Instruction_State = RSPPIPELINE_DO_DELAY_SLOT;
|
|
|
|
break;
|
|
|
|
case RSP_ADDI:
|
|
|
|
case RSP_ADDIU:
|
|
|
|
case RSP_SLTI:
|
|
|
|
case RSP_SLTIU:
|
|
|
|
case RSP_ANDI:
|
|
|
|
case RSP_ORI:
|
|
|
|
case RSP_XORI:
|
|
|
|
case RSP_LUI:
|
|
|
|
case RSP_CP0:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RSP_CP2:
|
|
|
|
if ((RspOp.rs & 0x10) != 0)
|
|
|
|
{
|
|
|
|
switch (RspOp.funct)
|
|
|
|
{
|
|
|
|
case RSP_VECTOR_VMULF:
|
|
|
|
case RSP_VECTOR_VMULU:
|
|
|
|
case RSP_VECTOR_VMUDL:
|
|
|
|
case RSP_VECTOR_VMUDM:
|
|
|
|
case RSP_VECTOR_VMUDN:
|
|
|
|
case RSP_VECTOR_VMUDH:
|
|
|
|
return false;
|
|
|
|
case RSP_VECTOR_VMACF:
|
|
|
|
case RSP_VECTOR_VMACU:
|
|
|
|
case RSP_VECTOR_VMADL:
|
|
|
|
case RSP_VECTOR_VMADM:
|
|
|
|
case RSP_VECTOR_VMADN:
|
|
|
|
return true;
|
|
|
|
case RSP_VECTOR_VMADH:
|
|
|
|
if (Location == Low16BitAccum)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case RSP_VECTOR_VABS:
|
|
|
|
case RSP_VECTOR_VADD:
|
|
|
|
case RSP_VECTOR_VADDC:
|
|
|
|
case RSP_VECTOR_VSUB:
|
|
|
|
case RSP_VECTOR_VSUBC:
|
|
|
|
case RSP_VECTOR_VAND:
|
|
|
|
case RSP_VECTOR_VNAND:
|
|
|
|
case RSP_VECTOR_VOR:
|
|
|
|
case RSP_VECTOR_VNOR:
|
|
|
|
case RSP_VECTOR_VXOR:
|
|
|
|
case RSP_VECTOR_VNXOR:
|
|
|
|
// Since these modify the accumulator lower-16 bits we can
|
|
|
|
// safely assume these 'reset' the accumulator no matter what
|
|
|
|
// return false;
|
|
|
|
case RSP_VECTOR_VCR:
|
|
|
|
case RSP_VECTOR_VCH:
|
|
|
|
case RSP_VECTOR_VCL:
|
|
|
|
case RSP_VECTOR_VRCP:
|
|
|
|
case RSP_VECTOR_VRCPL:
|
|
|
|
case RSP_VECTOR_VRCPH:
|
|
|
|
case RSP_VECTOR_VRSQL:
|
|
|
|
case RSP_VECTOR_VRSQH:
|
|
|
|
case RSP_VECTOR_VLT:
|
|
|
|
case RSP_VECTOR_VEQ:
|
|
|
|
case RSP_VECTOR_VGE:
|
|
|
|
case RSP_VECTOR_VNE:
|
|
|
|
case RSP_VECTOR_VMRG:
|
|
|
|
case RSP_VECTOR_VMOV:
|
|
|
|
if (Location == Low16BitAccum)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RSP_VECTOR_VSAW:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
CompilerWarning(stdstr_f("Unknown opcode in WriteToAccum\n%s", RSPInstruction(PC, RspOp.Value).NameAndParam().c_str()).c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (RspOp.rs)
|
|
|
|
{
|
|
|
|
case RSP_COP2_CF:
|
|
|
|
case RSP_COP2_CT:
|
|
|
|
case RSP_COP2_MT:
|
|
|
|
case RSP_COP2_MF:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
CompilerWarning(stdstr_f("Unknown opcode in WriteToAccum\n%s", RSPInstruction(PC, RspOp.Value).NameAndParam().c_str()).c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RSP_LB:
|
|
|
|
case RSP_LH:
|
|
|
|
case RSP_LW:
|
|
|
|
case RSP_LBU:
|
|
|
|
case RSP_LHU:
|
|
|
|
case RSP_SB:
|
|
|
|
case RSP_SH:
|
|
|
|
case RSP_SW:
|
|
|
|
break;
|
|
|
|
case RSP_LC2:
|
|
|
|
switch (RspOp.rd)
|
|
|
|
{
|
|
|
|
case RSP_LSC2_BV:
|
|
|
|
case RSP_LSC2_SV:
|
|
|
|
case RSP_LSC2_DV:
|
|
|
|
case RSP_LSC2_RV:
|
|
|
|
case RSP_LSC2_QV:
|
|
|
|
case RSP_LSC2_LV:
|
|
|
|
case RSP_LSC2_UV:
|
|
|
|
case RSP_LSC2_PV:
|
|
|
|
case RSP_LSC2_TV:
|
|
|
|
case RSP_LSC2_HV:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
CompilerWarning(stdstr_f("Unknown opcode in WriteToAccum\n%s", RSPInstruction(PC, RspOp.Value).NameAndParam().c_str()).c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RSP_SC2:
|
|
|
|
switch (RspOp.rd)
|
|
|
|
{
|
|
|
|
case RSP_LSC2_BV:
|
|
|
|
case RSP_LSC2_SV:
|
|
|
|
case RSP_LSC2_LV:
|
|
|
|
case RSP_LSC2_DV:
|
|
|
|
case RSP_LSC2_QV:
|
|
|
|
case RSP_LSC2_RV:
|
|
|
|
case RSP_LSC2_PV:
|
|
|
|
case RSP_LSC2_UV:
|
|
|
|
case RSP_LSC2_HV:
|
|
|
|
case RSP_LSC2_FV:
|
|
|
|
case RSP_LSC2_WV:
|
|
|
|
case RSP_LSC2_TV:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
CompilerWarning(stdstr_f("Unknown opcode in WriteToAccum\n%s", RSPInstruction(PC, RspOp.Value).NameAndParam().c_str()).c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
CompilerWarning(stdstr_f("Unknown opcode in WriteToAccum\n%s", RSPInstruction(PC, RspOp.Value).NameAndParam().c_str()).c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
switch (Instruction_State)
|
|
|
|
{
|
|
|
|
case RSPPIPELINE_NORMAL: break;
|
|
|
|
case RSPPIPELINE_DO_DELAY_SLOT:
|
|
|
|
Instruction_State = RSPPIPELINE_DELAY_SLOT;
|
|
|
|
break;
|
|
|
|
case RSPPIPELINE_DELAY_SLOT:
|
|
|
|
Instruction_State = RSPPIPELINE_FINISH_BLOCK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (Instruction_State != RSPPIPELINE_FINISH_BLOCK);
|
|
|
|
|
|
|
|
/*
|
|
|
|
This is a tricky situation because most of the
|
|
|
|
microcode does loops, so looping back and checking
|
|
|
|
can prove effective, but it's still a branch...
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (BranchTarget != 0 && RecursiveCall == false)
|
|
|
|
{
|
|
|
|
uint32_t BranchTaken, BranchFall;
|
|
|
|
|
|
|
|
// Analysis of branch taken
|
|
|
|
BranchTaken = WriteToAccum2(Location, BranchTarget - 4, true);
|
|
|
|
// Analysis of branch as NOP
|
|
|
|
BranchFall = WriteToAccum2(Location, PC, true);
|
|
|
|
|
|
|
|
if (BranchImmed < 0)
|
|
|
|
{
|
|
|
|
if (BranchTaken != false)
|
|
|
|
{
|
|
|
|
|
|
|
|
// Took this back branch and found a place
|
|
|
|
// that needs this vector as a source
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (BranchFall == HIT_BRANCH)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// Otherwise this is completely valid
|
|
|
|
return BranchFall;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (BranchFall != false)
|
|
|
|
{
|
|
|
|
|
|
|
|
// Took this forward branch and found a place
|
|
|
|
// that needs this vector as a source
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (BranchTaken == HIT_BRANCH)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// Otherwise this is completely valid
|
|
|
|
return BranchTaken;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CRSPRecompilerOps::WriteToVectorDest(uint32_t DestReg, int PC)
|
|
|
|
{
|
|
|
|
uint32_t value;
|
|
|
|
value = WriteToVectorDest2(DestReg, PC, false);
|
|
|
|
|
|
|
|
if (value == HIT_BRANCH)
|
|
|
|
{
|
|
|
|
return true; // TODO: ???
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return value != 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CRSPRecompilerOps::WriteToVectorDest2(uint32_t DestReg, int PC, bool RecursiveCall)
|
|
|
|
{
|
|
|
|
RSPOpcode RspOp;
|
|
|
|
uint32_t BranchTarget = 0;
|
|
|
|
signed int BranchImmed = 0;
|
|
|
|
|
|
|
|
int Instruction_State = m_NextInstruction;
|
|
|
|
|
|
|
|
if (Compiler.bDest == false) return true;
|
|
|
|
|
|
|
|
if (Instruction_State == RSPPIPELINE_DELAY_SLOT)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
PC += 4;
|
|
|
|
if (PC >= 0x1000)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
RspOp.Value = *(uint32_t *)(RSPInfo.IMEM + (PC & 0xFFC));
|
|
|
|
|
|
|
|
switch (RspOp.op)
|
|
|
|
{
|
|
|
|
|
|
|
|
case RSP_REGIMM:
|
|
|
|
switch (RspOp.rt)
|
|
|
|
{
|
|
|
|
case RSP_REGIMM_BLTZ:
|
|
|
|
case RSP_REGIMM_BGEZ:
|
|
|
|
case RSP_REGIMM_BLTZAL:
|
|
|
|
case RSP_REGIMM_BGEZAL:
|
|
|
|
Instruction_State = RSPPIPELINE_DO_DELAY_SLOT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
CompilerWarning(stdstr_f("Unknown opcode in WriteToVectorDest\n%s", RSPInstruction(PC, RspOp.Value).NameAndParam().c_str()).c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RSP_SPECIAL:
|
|
|
|
switch (RspOp.funct)
|
|
|
|
{
|
|
|
|
case RSP_SPECIAL_SLL:
|
|
|
|
case RSP_SPECIAL_SRL:
|
|
|
|
case RSP_SPECIAL_SRA:
|
|
|
|
case RSP_SPECIAL_SLLV:
|
|
|
|
case RSP_SPECIAL_SRLV:
|
|
|
|
case RSP_SPECIAL_SRAV:
|
|
|
|
case RSP_SPECIAL_ADD:
|
|
|
|
case RSP_SPECIAL_ADDU:
|
|
|
|
case RSP_SPECIAL_SUB:
|
|
|
|
case RSP_SPECIAL_SUBU:
|
|
|
|
case RSP_SPECIAL_AND:
|
|
|
|
case RSP_SPECIAL_OR:
|
|
|
|
case RSP_SPECIAL_XOR:
|
|
|
|
case RSP_SPECIAL_NOR:
|
|
|
|
case RSP_SPECIAL_SLT:
|
|
|
|
case RSP_SPECIAL_SLTU:
|
|
|
|
case RSP_SPECIAL_BREAK:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RSP_SPECIAL_JALR:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case RSP_SPECIAL_JR:
|
|
|
|
Instruction_State = RSPPIPELINE_DO_DELAY_SLOT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
CompilerWarning(stdstr_f("Unknown opcode in WriteToVectorDest\n%s", RSPInstruction(PC, RspOp.Value).NameAndParam().c_str()).c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RSP_J:
|
|
|
|
// There is no way a loopback is going to use accumulator
|
|
|
|
if (Compiler.bAudioUcode && (int)(RspOp.target << 2) < PC)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// Rarely occurs, so we let them have their way
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case RSP_JAL:
|
|
|
|
// Assume register is being passed to function or used after the function call
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case RSP_BEQ:
|
|
|
|
case RSP_BNE:
|
|
|
|
case RSP_BLEZ:
|
|
|
|
case RSP_BGTZ:
|
|
|
|
BranchImmed = (short)RspOp.offset;
|
|
|
|
if (Compiler.bAudioUcode)
|
|
|
|
{
|
|
|
|
RSPOpcode NextOp;
|
|
|
|
|
|
|
|
// Ignore backward branches and pretend it's a NOP
|
|
|
|
if (BranchImmed <= 0)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// If the opcode (which is 8 bytes before the destination and also a J backward) then ignore this
|
|
|
|
BranchImmed = (PC + ((short)RspOp.offset << 2) + 4) & 0xFFC;
|
|
|
|
RSP_LW_IMEM(BranchImmed - 8, &NextOp.Value);
|
|
|
|
if (RspOp.op == RSP_J && (int)(RspOp.target << 2) < PC)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BranchTarget = (PC + ((short)RspOp.offset << 2) + 4) & 0xFFC;
|
|
|
|
Instruction_State = RSPPIPELINE_DO_DELAY_SLOT;
|
|
|
|
break;
|
|
|
|
case RSP_ADDI:
|
|
|
|
case RSP_ADDIU:
|
|
|
|
case RSP_SLTI:
|
|
|
|
case RSP_SLTIU:
|
|
|
|
case RSP_ANDI:
|
|
|
|
case RSP_ORI:
|
|
|
|
case RSP_XORI:
|
|
|
|
case RSP_LUI:
|
|
|
|
case RSP_CP0:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RSP_CP2:
|
|
|
|
if ((RspOp.rs & 0x10) != 0)
|
|
|
|
{
|
|
|
|
switch (RspOp.funct)
|
|
|
|
{
|
|
|
|
case RSP_VECTOR_VMULF:
|
|
|
|
case RSP_VECTOR_VMULU:
|
|
|
|
case RSP_VECTOR_VMUDL:
|
|
|
|
case RSP_VECTOR_VMUDM:
|
|
|
|
case RSP_VECTOR_VMUDN:
|
|
|
|
case RSP_VECTOR_VMUDH:
|
|
|
|
case RSP_VECTOR_VMACF:
|
|
|
|
case RSP_VECTOR_VMACU:
|
|
|
|
case RSP_VECTOR_VMADL:
|
|
|
|
case RSP_VECTOR_VMADM:
|
|
|
|
case RSP_VECTOR_VMADN:
|
|
|
|
case RSP_VECTOR_VMADH:
|
|
|
|
case RSP_VECTOR_VADD:
|
|
|
|
case RSP_VECTOR_VADDC:
|
|
|
|
case RSP_VECTOR_VSUB:
|
|
|
|
case RSP_VECTOR_VSUBC:
|
|
|
|
case RSP_VECTOR_VAND:
|
|
|
|
case RSP_VECTOR_VNAND:
|
|
|
|
case RSP_VECTOR_VOR:
|
|
|
|
case RSP_VECTOR_VNOR:
|
|
|
|
case RSP_VECTOR_VXOR:
|
|
|
|
case RSP_VECTOR_VNXOR:
|
|
|
|
case RSP_VECTOR_VABS:
|
|
|
|
if (DestReg == RspOp.rd)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (DestReg == RspOp.rt)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (DestReg == RspOp.sa)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RSP_VECTOR_VMOV:
|
|
|
|
case RSP_VECTOR_VRCP:
|
|
|
|
case RSP_VECTOR_VRCPL:
|
|
|
|
case RSP_VECTOR_VRCPH:
|
|
|
|
case RSP_VECTOR_VRSQL:
|
|
|
|
case RSP_VECTOR_VRSQH:
|
|
|
|
if (DestReg == RspOp.rt)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RSP_VECTOR_VCH:
|
|
|
|
case RSP_VECTOR_VCL:
|
|
|
|
case RSP_VECTOR_VCR:
|
|
|
|
case RSP_VECTOR_VMRG:
|
|
|
|
case RSP_VECTOR_VLT:
|
|
|
|
case RSP_VECTOR_VEQ:
|
|
|
|
case RSP_VECTOR_VGE:
|
|
|
|
case RSP_VECTOR_VNE:
|
|
|
|
if (DestReg == RspOp.rd)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (DestReg == RspOp.rt)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (DestReg == RspOp.sa)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RSP_VECTOR_VSAW:
|
|
|
|
if (DestReg == RspOp.sa)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
CompilerWarning(stdstr_f("Unknown opcode in WriteToVectorDest\n%s", RSPInstruction(PC, RspOp.Value).NameAndParam().c_str()).c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (RspOp.rs)
|
|
|
|
{
|
|
|
|
case RSP_COP2_CF:
|
|
|
|
case RSP_COP2_CT:
|
|
|
|
break;
|
|
|
|
case RSP_COP2_MT:
|
|
|
|
/* if (DestReg == RspOp.rd) { return false; } */
|
|
|
|
break;
|
|
|
|
case RSP_COP2_MF:
|
|
|
|
if (DestReg == RspOp.rd)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
CompilerWarning(stdstr_f("Unknown opcode in WriteToVectorDest\n%s", RSPInstruction(PC, RspOp.Value).NameAndParam().c_str()).c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RSP_LB:
|
|
|
|
case RSP_LH:
|
|
|
|
case RSP_LW:
|
|
|
|
case RSP_LBU:
|
|
|
|
case RSP_LHU:
|
|
|
|
case RSP_SB:
|
|
|
|
case RSP_SH:
|
|
|
|
case RSP_SW:
|
|
|
|
break;
|
|
|
|
case RSP_LC2:
|
|
|
|
switch (RspOp.rd)
|
|
|
|
{
|
|
|
|
case RSP_LSC2_SV:
|
|
|
|
case RSP_LSC2_DV:
|
|
|
|
case RSP_LSC2_RV:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RSP_LSC2_QV:
|
|
|
|
case RSP_LSC2_BV:
|
|
|
|
case RSP_LSC2_LV:
|
|
|
|
case RSP_LSC2_TV:
|
|
|
|
break;
|
|
|
|
case RSP_LSC2_PV:
|
|
|
|
case RSP_LSC2_UV:
|
|
|
|
case RSP_LSC2_HV:
|
|
|
|
if (DestReg == RspOp.rt)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
CompilerWarning(stdstr_f("Unknown opcode in WriteToVectorDest\n%s", RSPInstruction(PC, RspOp.Value).NameAndParam().c_str()).c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RSP_SC2:
|
|
|
|
switch (RspOp.rd)
|
|
|
|
{
|
|
|
|
case RSP_LSC2_BV:
|
|
|
|
case RSP_LSC2_SV:
|
|
|
|
case RSP_LSC2_LV:
|
|
|
|
case RSP_LSC2_DV:
|
|
|
|
case RSP_LSC2_QV:
|
|
|
|
case RSP_LSC2_RV:
|
|
|
|
case RSP_LSC2_PV:
|
|
|
|
case RSP_LSC2_UV:
|
|
|
|
case RSP_LSC2_HV:
|
|
|
|
case RSP_LSC2_FV:
|
|
|
|
case RSP_LSC2_WV:
|
|
|
|
if (DestReg == RspOp.rt)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RSP_LSC2_TV:
|
|
|
|
if (8 <= 32 - RspOp.rt)
|
|
|
|
{
|
|
|
|
if (DestReg >= RspOp.rt && DestReg <= RspOp.rt + 7)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int length = 32 - RspOp.rt, count, del = RspOp.del >> 1, vect = RspOp.rt;
|
|
|
|
for (count = 0; count < length; count++)
|
|
|
|
{
|
|
|
|
if (DestReg == (uint32_t)(vect + del))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
del = (del + 1) & 7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
CompilerWarning(stdstr_f("Unknown opcode in WriteToVectorDest\n%s", RSPInstruction(PC, RspOp.Value).NameAndParam().c_str()).c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
CompilerWarning(stdstr_f("Unknown opcode in WriteToVectorDest\n%s", RSPInstruction(PC, RspOp.Value).NameAndParam().c_str()).c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
switch (Instruction_State)
|
|
|
|
{
|
|
|
|
case RSPPIPELINE_NORMAL: break;
|
|
|
|
case RSPPIPELINE_DO_DELAY_SLOT:
|
|
|
|
Instruction_State = RSPPIPELINE_DELAY_SLOT;
|
|
|
|
break;
|
|
|
|
case RSPPIPELINE_DELAY_SLOT:
|
|
|
|
Instruction_State = RSPPIPELINE_FINISH_BLOCK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (Instruction_State != RSPPIPELINE_FINISH_BLOCK);
|
|
|
|
|
|
|
|
/*
|
|
|
|
This is a tricky situation because most of the
|
|
|
|
microcode does loops, so looping back and checking
|
|
|
|
can prove effective, but it's still a branch...
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (BranchTarget != 0 && RecursiveCall == false)
|
|
|
|
{
|
|
|
|
uint32_t BranchTaken, BranchFall;
|
|
|
|
|
|
|
|
// Analysis of branch taken
|
|
|
|
BranchTaken = WriteToVectorDest2(DestReg, BranchTarget - 4, true);
|
|
|
|
// Analysis of branch as NOP
|
|
|
|
BranchFall = WriteToVectorDest2(DestReg, PC, true);
|
|
|
|
|
|
|
|
if (BranchImmed < 0)
|
|
|
|
{
|
|
|
|
if (BranchTaken != false)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Took this back branch and found a place
|
|
|
|
* that needs this vector as a source
|
|
|
|
*/
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (BranchFall == HIT_BRANCH)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// Otherwise this is completely valid
|
|
|
|
return BranchFall != 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (BranchFall != false)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Took this forward branch and found a place
|
|
|
|
* that needs this vector as a source
|
|
|
|
*/
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (BranchTaken == HIT_BRANCH)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// Otherwise this is completely valid
|
|
|
|
return BranchTaken != 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
void CRSPRecompilerOps::RSP_Element2Mmx(int MmxReg)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
char Reg[256];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Rs = m_OpCode.rs & 0x0f;
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t el;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
switch (Rs)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
case 3:
|
|
|
|
case 4:
|
|
|
|
case 5:
|
|
|
|
case 6:
|
|
|
|
case 7:
|
|
|
|
CompilerWarning("Unimplemented RSP_Element2Mmx");
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/*
|
2016-01-27 09:39:06 +00:00
|
|
|
* Noticed the exclusive-or of seven to take into account
|
|
|
|
* the pseudo-swapping we have in the vector registers
|
|
|
|
*/
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
el = (m_OpCode.rs & 0x07) ^ 7;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsMmx2Enabled)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, el);
|
|
|
|
MoveVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(el), Reg, x86_ECX);
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86regHalfToVariable(x86_ECX, &MMX_Scratch.HW[0], "MMX_Scratch.HW[0]");
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &MMX_Scratch.HW[1], "MMX_Scratch.HW[1]");
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &MMX_Scratch.HW[2], "MMX_Scratch.HW[2]");
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &MMX_Scratch.HW[3], "MMX_Scratch.HW[3]");
|
|
|
|
MmxMoveQwordVariableToReg(MmxReg, &MMX_Scratch.HW[0], "MMX_Scratch.HW[0]");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t Qword = (el >> 2) & 0x1;
|
2023-06-01 11:46:23 +00:00
|
|
|
el &= 0x3;
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].DW[%i]", m_OpCode.rt, Qword);
|
|
|
|
MmxShuffleMemoryToReg(MmxReg, &m_Vect[m_OpCode.vt].u64(Qword), Reg, _MMX_SHUFFLE(el, el, el, el));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
void CRSPRecompilerOps::RSP_MultiElement2Mmx(int MmxReg1, int MmxReg2)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
char Reg[256];
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Rs = m_OpCode.rs & 0x0f;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
/*
|
2021-03-19 07:13:35 +00:00
|
|
|
* OK, this is tricky, hopefully this clears it up:
|
2016-01-27 09:39:06 +00:00
|
|
|
*
|
|
|
|
* $vd[0] = $vd[0] + $vt[2]
|
|
|
|
* because of swapped registers becomes:
|
|
|
|
* $vd[7] = $vd[7] + $vt[5]
|
|
|
|
*
|
2021-03-19 07:13:35 +00:00
|
|
|
* We must perform this swap correctly, this involves the 3-bit
|
2023-08-10 04:46:57 +00:00
|
|
|
* exclusive or, 2-bits of which are done within a uint32_t boundary,
|
2016-01-27 09:39:06 +00:00
|
|
|
* the last bit, is ignored because we are loading the source linearly,
|
2021-05-18 11:51:36 +00:00
|
|
|
* so the exclusive or has transparently happened on that side.
|
2016-01-27 09:39:06 +00:00
|
|
|
*/
|
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
switch (Rs)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
case 1:
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.rt);
|
|
|
|
MmxMoveQwordVariableToReg(MmxReg1, &m_Vect[m_OpCode.vt].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.rt);
|
|
|
|
MmxMoveQwordVariableToReg(MmxReg2, &m_Vect[m_OpCode.vt].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
/* [0q] | 0 | 0 | 2 | 2 | 4 | 4 | 6 | 6 | */
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].DW[0]", m_OpCode.rt);
|
|
|
|
MmxShuffleMemoryToReg(MmxReg1, &m_Vect[m_OpCode.vt].u64(0), Reg, 0xF5);
|
|
|
|
sprintf(Reg, "m_Vect[%i].DW[1]", m_OpCode.rt);
|
|
|
|
MmxShuffleMemoryToReg(MmxReg2, &m_Vect[m_OpCode.vt].u64(1), Reg, 0xF5);
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
/* [1q] | 1 | 1 | 3 | 3 | 5 | 5 | 7 | 7 | */
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].DW[0]", m_OpCode.rt);
|
|
|
|
MmxShuffleMemoryToReg(MmxReg1, &m_Vect[m_OpCode.vt].u64(0), Reg, 0xA0);
|
|
|
|
//MmxShuffleMemoryToReg(MmxReg1, &m_Vect[m_OpCode.vt].s64(0), Reg, 0x0A);
|
|
|
|
sprintf(Reg, "m_Vect[%i].DW[1]", m_OpCode.rt);
|
|
|
|
MmxShuffleMemoryToReg(MmxReg2, &m_Vect[m_OpCode.vt].u64(1), Reg, 0xA0);
|
|
|
|
//MmxShuffleMemoryToReg(MmxReg2, &m_Vect[m_OpCode.vt].s64(1), Reg, 0x0A);
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
/* [0h] | 0 | 0 | 0 | 0 | 4 | 4 | 4 | 4 | */
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].DW[0]", m_OpCode.rt);
|
|
|
|
MmxShuffleMemoryToReg(MmxReg1, &m_Vect[m_OpCode.vt].u64(0), Reg, 0xFF);
|
|
|
|
sprintf(Reg, "m_Vect[%i].DW[1]", m_OpCode.rt);
|
|
|
|
MmxShuffleMemoryToReg(MmxReg2, &m_Vect[m_OpCode.vt].u64(1), Reg, 0xFF);
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
/* [1h] | 1 | 1 | 1 | 1 | 5 | 5 | 5 | 5 | */
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].DW[0]", m_OpCode.rt);
|
|
|
|
MmxShuffleMemoryToReg(MmxReg1, &m_Vect[m_OpCode.vt].u64(0), Reg, 0xAA);
|
|
|
|
sprintf(Reg, "m_Vect[%i].DW[1]", m_OpCode.rt);
|
|
|
|
MmxShuffleMemoryToReg(MmxReg2, &m_Vect[m_OpCode.vt].u64(1), Reg, 0xAA);
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
/* [2h] | 2 | 2 | 2 | 2 | 6 | 6 | 6 | 6 | */
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].DW[0]", m_OpCode.rt);
|
|
|
|
MmxShuffleMemoryToReg(MmxReg1, &m_Vect[m_OpCode.vt].u64(0), Reg, 0x55);
|
|
|
|
sprintf(Reg, "m_Vect[%i].DW[1]", m_OpCode.rt);
|
|
|
|
MmxShuffleMemoryToReg(MmxReg2, &m_Vect[m_OpCode.vt].u64(1), Reg, 0x55);
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
/* [3h] | 3 | 3 | 3 | 3 | 7 | 7 | 7 | 7 | */
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].DW[0]", m_OpCode.rt);
|
|
|
|
MmxShuffleMemoryToReg(MmxReg1, &m_Vect[m_OpCode.vt].u64(0), Reg, 0x00);
|
|
|
|
sprintf(Reg, "m_Vect[%i].DW[1]", m_OpCode.rt);
|
|
|
|
MmxShuffleMemoryToReg(MmxReg2, &m_Vect[m_OpCode.vt].u64(1), Reg, 0x00);
|
2023-06-01 11:46:23 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
CompilerWarning("Unimplemented RSP_MultiElement2Mmx [?]");
|
|
|
|
break;
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
bool CRSPRecompilerOps::Compile_Vector_VMULF_MMX(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Do our MMX checks here
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsMmxEnabled)
|
|
|
|
return false;
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.rs & 0x0f) >= 2 && !(m_OpCode.rs & 8) && IsMmx2Enabled == false)
|
2023-06-29 02:59:07 +00:00
|
|
|
return false;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
// NOTE: Problem here is the lack of +/- 0x8000 rounding
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM0, &m_Vect[m_OpCode.vs].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM1, &m_Vect[m_OpCode.vs].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.rs & 0xF) < 2)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == m_OpCode.rt)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
MmxPmulhwRegToReg(x86_MM0, x86_MM0);
|
|
|
|
MmxPmulhwRegToReg(x86_MM1, x86_MM1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.rt);
|
|
|
|
MmxPmulhwRegToVariable(x86_MM0, &m_Vect[m_OpCode.vt].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.rt);
|
|
|
|
MmxPmulhwRegToVariable(x86_MM1, &m_Vect[m_OpCode.vt].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs & 8)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
RSP_Element2Mmx(x86_MM2);
|
|
|
|
MmxPmulhwRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPmulhwRegToReg(x86_MM1, x86_MM2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RSP_MultiElement2Mmx(x86_MM2, x86_MM3);
|
|
|
|
MmxPmulhwRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPmulhwRegToReg(x86_MM1, x86_MM3);
|
|
|
|
}
|
|
|
|
MmxPsllwImmed(x86_MM0, 1);
|
|
|
|
MmxPsllwImmed(x86_MM1, 1);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM0, &m_Vect[m_OpCode.vd].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM1, &m_Vect[m_OpCode.vd].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsNextInstructionMmx(CompilePC))
|
2023-06-01 11:46:23 +00:00
|
|
|
MmxEmptyMultimediaState();
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
return true;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VMULF(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-06-20 07:58:51 +00:00
|
|
|
#ifndef CompileVmulf
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VMULF, "&RSPOp::Vector_VMULF");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t count, el, del;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bOptimize = (m_OpCode.rs & 8) ? true : false;
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(EntireAccum, CompilePC);
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bWriteToDest = WriteToVectorDest(m_OpCode.sa, CompilePC);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bWriteToAccum)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
if (true == Compile_Vector_VMULF_MMX())
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bOptimize)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
del = (m_OpCode.rs & 0x07) ^ 7;
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
MoveConstToX86reg(0x7fff0000, x86_ESI);
|
|
|
|
}
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
XorX86RegToX86Reg(x86_EDI, x86_EDI);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
|
|
|
CPU_Message(" Iteration: %i", count);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
el = Indx[m_OpCode.e].B[count];
|
|
|
|
del = EleSpec[m_OpCode.e].B[el];
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rd, el);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vs].s16(el), Reg, x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rt == m_OpCode.rd && !bOptimize)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
imulX86reg(x86_EAX);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bOptimize)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
imulX86reg(x86_EBX);
|
|
|
|
}
|
|
|
|
|
|
|
|
ShiftLeftSignImmed(x86_EAX, 1);
|
|
|
|
AddConstToX86Reg(x86_EAX, 0x8000);
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_ACCUM[el].HW[1], "m_ACCUM[el].HW[1]");
|
2023-06-01 11:46:23 +00:00
|
|
|
// Calculate sign extension into EDX
|
|
|
|
MoveX86RegToX86Reg(x86_EAX, x86_EDX);
|
|
|
|
ShiftRightSignImmed(x86_EDX, 31);
|
|
|
|
}
|
|
|
|
|
|
|
|
CompConstToX86reg(x86_EAX, 0x80008000);
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
CondMoveEqual(x86_EDX, x86_EDI);
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveX86regHalfToVariable(x86_EDX, &m_ACCUM[el].HW[3], "m_ACCUM[el].HW[3]");
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
CondMoveEqual(x86_EAX, x86_ESI);
|
|
|
|
ShiftRightUnsignImmed(x86_EAX, 16);
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_Vect[m_OpCode.vd].s16(el), "m_Vect[m_OpCode.vd].s16(el)");
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VMULU(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VMULU, "RSPOp::Vector_VMULU");
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VRNDN(void)
|
2024-07-06 09:38:20 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VRNDN, "RSPOp::Vector_VRNDN");
|
2024-07-06 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VRNDP(void)
|
2024-06-20 09:52:57 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VRNDP, "RSPOp::Vector_VRNDP");
|
2024-06-20 09:52:57 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VMULQ(void)
|
2024-06-20 09:52:57 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VMULQ, "&RSPOp::Vector_VMULQ");
|
2024-06-20 09:52:57 +00:00
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
bool CRSPRecompilerOps::Compile_Vector_VMUDL_MMX(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Do our MMX checks here
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsMmxEnabled)
|
|
|
|
return false;
|
|
|
|
if (!IsMmx2Enabled)
|
|
|
|
return false;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM0, &m_Vect[m_OpCode.vs].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM1, &m_Vect[m_OpCode.vs].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.rs & 0xF) < 2)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == m_OpCode.rt)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
MmxPmulhuwRegToReg(x86_MM0, x86_MM0);
|
|
|
|
MmxPmulhuwRegToReg(x86_MM1, x86_MM1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.rt);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM2, &m_Vect[m_OpCode.vt].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.rt);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM3, &m_Vect[m_OpCode.vt].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
MmxPmulhuwRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPmulhuwRegToReg(x86_MM1, x86_MM3);
|
|
|
|
}
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs & 8)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
RSP_Element2Mmx(x86_MM2);
|
|
|
|
MmxPmulhuwRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPmulhuwRegToReg(x86_MM1, x86_MM2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RSP_MultiElement2Mmx(x86_MM2, x86_MM3);
|
|
|
|
MmxPmulhuwRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPmulhuwRegToReg(x86_MM1, x86_MM3);
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM0, &m_Vect[m_OpCode.vd].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM1, &m_Vect[m_OpCode.vd].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsNextInstructionMmx(CompilePC))
|
2023-06-01 11:46:23 +00:00
|
|
|
MmxEmptyMultimediaState();
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
return true;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VMUDL(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-06-20 07:58:51 +00:00
|
|
|
#ifndef CompileVmudl
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VMUDL, "&RSPOp::Vector_VMUDL");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t count, el, del;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bOptimize = (m_OpCode.rs & 8) ? true : false;
|
|
|
|
bool bWriteToDest = WriteToVectorDest(m_OpCode.sa, CompilePC);
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(EntireAccum, CompilePC);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bWriteToAccum)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
if (true == Compile_Vector_VMUDL_MMX())
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bOptimize)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
del = (m_OpCode.rs & 0x07) ^ 7;
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveZxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum)
|
2023-06-01 11:46:23 +00:00
|
|
|
XorX86RegToX86Reg(x86_EDI, x86_EDI);
|
|
|
|
|
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
|
|
|
CPU_Message(" Iteration: %i", count);
|
2024-08-08 03:25:54 +00:00
|
|
|
el = Indx[m_OpCode.e].B[count];
|
|
|
|
del = EleSpec[m_OpCode.e].B[el];
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[%i]", m_OpCode.rd, el);
|
|
|
|
MoveZxVariableToX86regHalf(&m_Vect[m_OpCode.vs].u16(el), Reg, x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bOptimize)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveZxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
imulX86reg(x86_EBX);
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].UW[0]", el);
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_ACCUM[el].UW[0], Reg);
|
|
|
|
sprintf(Reg, "m_ACCUM[%i].UW[1]", el);
|
|
|
|
MoveX86regToVariable(x86_EDI, &m_ACCUM[el].UW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
ShiftRightUnsignImmed(x86_EAX, 16);
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_Vect[m_OpCode.vd].s16(el), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
bool CRSPRecompilerOps::Compile_Vector_VMUDM_MMX(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Do our MMX checks here
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsMmxEnabled)
|
|
|
|
return false;
|
|
|
|
if (!IsMmx2Enabled)
|
|
|
|
return false;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM0, &m_Vect[m_OpCode.vs].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM1, &m_Vect[m_OpCode.vs].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.rs & 0xF) < 2)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.rt);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM4, &m_Vect[m_OpCode.vt].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.rt);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM5, &m_Vect[m_OpCode.vt].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
// Copy the signed portion
|
|
|
|
MmxMoveRegToReg(x86_MM2, x86_MM0);
|
|
|
|
MmxMoveRegToReg(x86_MM3, x86_MM1);
|
|
|
|
|
|
|
|
// high((u16)a * b)
|
|
|
|
MmxPmulhuwRegToReg(x86_MM0, x86_MM4);
|
|
|
|
MmxPmulhuwRegToReg(x86_MM1, x86_MM5);
|
|
|
|
|
|
|
|
// low((a >> 15) * b)
|
|
|
|
MmxPsrawImmed(x86_MM2, 15);
|
|
|
|
MmxPsrawImmed(x86_MM3, 15);
|
|
|
|
MmxPmullwRegToReg(x86_MM2, x86_MM4);
|
|
|
|
MmxPmullwRegToReg(x86_MM3, x86_MM5);
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs & 8)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
RSP_Element2Mmx(x86_MM4);
|
|
|
|
|
|
|
|
// Copy the signed portion
|
|
|
|
MmxMoveRegToReg(x86_MM2, x86_MM0);
|
|
|
|
MmxMoveRegToReg(x86_MM3, x86_MM1);
|
|
|
|
|
|
|
|
// high((u16)a * b)
|
|
|
|
MmxPmulhuwRegToReg(x86_MM0, x86_MM4);
|
|
|
|
MmxPmulhuwRegToReg(x86_MM1, x86_MM4);
|
|
|
|
|
|
|
|
// low((a >> 15) * b)
|
|
|
|
MmxPsrawImmed(x86_MM2, 15);
|
|
|
|
MmxPsrawImmed(x86_MM3, 15);
|
|
|
|
MmxPmullwRegToReg(x86_MM2, x86_MM4);
|
|
|
|
MmxPmullwRegToReg(x86_MM3, x86_MM4);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RSP_MultiElement2Mmx(x86_MM4, x86_MM5);
|
|
|
|
|
|
|
|
// Copy the signed portion
|
|
|
|
MmxMoveRegToReg(x86_MM2, x86_MM0);
|
|
|
|
MmxMoveRegToReg(x86_MM3, x86_MM1);
|
|
|
|
|
|
|
|
// high((u16)a * b)
|
|
|
|
MmxPmulhuwRegToReg(x86_MM0, x86_MM4);
|
|
|
|
MmxPmulhuwRegToReg(x86_MM1, x86_MM5);
|
|
|
|
|
|
|
|
// low((a >> 15) * b)
|
|
|
|
MmxPsrawImmed(x86_MM2, 15);
|
|
|
|
MmxPsrawImmed(x86_MM3, 15);
|
|
|
|
MmxPmullwRegToReg(x86_MM2, x86_MM4);
|
|
|
|
MmxPmullwRegToReg(x86_MM3, x86_MM5);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add them up
|
|
|
|
MmxPaddwRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPaddwRegToReg(x86_MM1, x86_MM3);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM0, &m_Vect[m_OpCode.vd].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM1, &m_Vect[m_OpCode.vd].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsNextInstructionMmx(CompilePC))
|
2023-06-01 11:46:23 +00:00
|
|
|
MmxEmptyMultimediaState();
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
return true;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VMUDM(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVmudm
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VMUDM, "&RSPOp::Vector_VMUDM");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t count, el, del;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bOptimize = (m_OpCode.rs & 8) ? true : false;
|
|
|
|
bool bWriteToDest = WriteToVectorDest(m_OpCode.sa, CompilePC);
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(EntireAccum, CompilePC);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bWriteToAccum)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
if (true == Compile_Vector_VMUDM_MMX())
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bOptimize)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
del = (m_OpCode.rs & 0x07) ^ 7;
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveZxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Push(x86_EBP);
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rd);
|
|
|
|
MoveOffsetToX86reg((size_t)&m_Vect[m_OpCode.vs].s16(0), Reg, x86_EBP);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
if (bWriteToDest)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.sa);
|
|
|
|
MoveOffsetToX86reg((size_t)&m_Vect[m_OpCode.vd].s16(0), Reg, x86_ECX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else if (!bOptimize)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rt);
|
|
|
|
MoveOffsetToX86reg((size_t)&m_Vect[m_OpCode.vt].s16(0), Reg, x86_ECX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
|
|
|
CPU_Message(" Iteration: %i", count);
|
2024-08-08 03:25:54 +00:00
|
|
|
el = Indx[m_OpCode.e].B[count];
|
|
|
|
del = EleSpec[m_OpCode.e].B[el];
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
/*sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rd, el);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vs].s16(el), Reg, x86_EAX);*/
|
2023-08-16 23:29:22 +00:00
|
|
|
MoveSxX86RegPtrDispToX86RegHalf(x86_EBP, (uint8_t)(el * 2), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bOptimize)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveZxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-16 23:29:22 +00:00
|
|
|
MoveZxX86RegPtrDispToX86RegHalf(x86_ECX, (uint8_t)(del * 2), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
imulX86reg(x86_EBX);
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum == false && bWriteToDest == true)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
ShiftRightUnsignImmed(x86_EAX, 16);
|
2024-08-08 03:25:54 +00:00
|
|
|
/*sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_Vect[m_OpCode.vd].s16(el), Reg);*/
|
2023-08-16 23:29:22 +00:00
|
|
|
MoveX86regHalfToX86regPointerDisp(x86_EAX, x86_ECX, (uint8_t)(el * 2));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MoveX86RegToX86Reg(x86_EAX, x86_EDX);
|
|
|
|
ShiftRightSignImmed(x86_EDX, 16);
|
|
|
|
ShiftLeftSignImmed(x86_EAX, 16);
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].UW[0]", el);
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_ACCUM[el].UW[0], Reg);
|
|
|
|
sprintf(Reg, "m_ACCUM[%i].UW[1]", el);
|
|
|
|
MoveX86regToVariable(x86_EDX, &m_ACCUM[el].UW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
/*sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_EDX, &m_Vect[m_OpCode.vd].s16(el), Reg);*/
|
2023-08-16 23:29:22 +00:00
|
|
|
MoveX86regHalfToX86regPointerDisp(x86_EDX, x86_ECX, (uint8_t)(el * 2));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
Pop(x86_EBP);
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
bool CRSPRecompilerOps::Compile_Vector_VMUDN_MMX(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Do our MMX checks here
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsMmxEnabled)
|
|
|
|
return false;
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.rs & 0x0f) >= 2 && !(m_OpCode.rs & 8) && IsMmx2Enabled == false)
|
2023-06-29 02:59:07 +00:00
|
|
|
return false;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM0, &m_Vect[m_OpCode.vs].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM1, &m_Vect[m_OpCode.vs].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.rs & 0xF) < 2)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.rt);
|
|
|
|
MmxPmullwVariableToReg(x86_MM0, &m_Vect[m_OpCode.vt].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.rt);
|
|
|
|
MmxPmullwVariableToReg(x86_MM1, &m_Vect[m_OpCode.vt].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs & 8)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
RSP_Element2Mmx(x86_MM2);
|
|
|
|
MmxPmullwRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPmullwRegToReg(x86_MM1, x86_MM2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RSP_MultiElement2Mmx(x86_MM2, x86_MM3);
|
|
|
|
MmxPmullwRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPmullwRegToReg(x86_MM1, x86_MM3);
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM0, &m_Vect[m_OpCode.vd].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM1, &m_Vect[m_OpCode.vd].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsNextInstructionMmx(CompilePC))
|
2023-06-01 11:46:23 +00:00
|
|
|
MmxEmptyMultimediaState();
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
return true;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VMUDN(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVmudn
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VMUDN, "RSPOp::Vector_VMUDN");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t count, el, del;
|
2016-02-14 18:49:47 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bOptimize = (m_OpCode.rs & 8) ? true : false;
|
|
|
|
bool bWriteToDest = WriteToVectorDest(m_OpCode.sa, CompilePC);
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(EntireAccum, CompilePC);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bWriteToAccum)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
if (true == Compile_Vector_VMUDN_MMX())
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bOptimize)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
del = (m_OpCode.rs & 0x07) ^ 7;
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
Push(x86_EBP);
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rd);
|
|
|
|
MoveOffsetToX86reg((size_t)&m_Vect[m_OpCode.vs].s16(0), Reg, x86_EBP);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
|
|
|
CPU_Message(" Iteration: %i", count);
|
2024-08-08 03:25:54 +00:00
|
|
|
el = Indx[m_OpCode.e].B[count];
|
|
|
|
del = EleSpec[m_OpCode.e].B[el];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
/*sprintf(Reg, "m_Vect[%i].UHW[%i]", m_OpCode.rd, el);
|
|
|
|
MoveZxVariableToX86regHalf(&m_Vect[m_OpCode.vs].u16(el), Reg, x86_EAX);*/
|
2023-08-16 23:29:22 +00:00
|
|
|
MoveZxX86RegPtrDispToX86RegHalf(x86_EBP, (uint8_t)(el * 2), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bOptimize)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
imulX86reg(x86_EBX);
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_Vect[m_OpCode.vd].s16(el), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
MoveX86RegToX86Reg(x86_EAX, x86_EDX);
|
|
|
|
ShiftRightSignImmed(x86_EDX, 16);
|
|
|
|
ShiftLeftSignImmed(x86_EAX, 16);
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].UW[0]", el);
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_ACCUM[el].UW[0], Reg);
|
|
|
|
sprintf(Reg, "m_ACCUM[%i].UW[1]", el);
|
|
|
|
MoveX86regToVariable(x86_EDX, &m_ACCUM[el].UW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Pop(x86_EBP);
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
bool CRSPRecompilerOps::Compile_Vector_VMUDH_MMX(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Do our MMX checks here
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsMmxEnabled)
|
|
|
|
return false;
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.rs & 0x0f) >= 2 && !(m_OpCode.rs & 8) && IsMmx2Enabled == false)
|
2023-06-29 02:59:07 +00:00
|
|
|
return false;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM0, &m_Vect[m_OpCode.vs].s16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[4]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM1, &m_Vect[m_OpCode.vs].s16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
// Registers 4 and 5 are high
|
|
|
|
MmxMoveRegToReg(x86_MM4, x86_MM0);
|
|
|
|
MmxMoveRegToReg(x86_MM5, x86_MM1);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.rs & 0x0f) < 2)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == m_OpCode.rt)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
MmxPmullwRegToReg(x86_MM0, x86_MM0);
|
|
|
|
MmxPmulhwRegToReg(x86_MM4, x86_MM4);
|
|
|
|
MmxPmullwRegToReg(x86_MM1, x86_MM1);
|
|
|
|
MmxPmulhwRegToReg(x86_MM5, x86_MM5);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rt);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM2, &m_Vect[m_OpCode.vt].s16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[4]", m_OpCode.rt);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM3, &m_Vect[m_OpCode.vt].s16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
MmxPmullwRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPmulhwRegToReg(x86_MM4, x86_MM2);
|
|
|
|
MmxPmullwRegToReg(x86_MM1, x86_MM3);
|
|
|
|
MmxPmulhwRegToReg(x86_MM5, x86_MM3);
|
|
|
|
}
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs & 8)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
RSP_Element2Mmx(x86_MM2);
|
|
|
|
|
|
|
|
MmxPmullwRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPmulhwRegToReg(x86_MM4, x86_MM2);
|
|
|
|
MmxPmullwRegToReg(x86_MM1, x86_MM2);
|
|
|
|
MmxPmulhwRegToReg(x86_MM5, x86_MM2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RSP_MultiElement2Mmx(x86_MM2, x86_MM3);
|
|
|
|
|
|
|
|
MmxPmullwRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPmulhwRegToReg(x86_MM4, x86_MM2);
|
|
|
|
MmxPmullwRegToReg(x86_MM1, x86_MM3);
|
|
|
|
MmxPmulhwRegToReg(x86_MM5, x86_MM3);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0 and 1 are low, 4 and 5 are high
|
|
|
|
MmxMoveRegToReg(x86_MM6, x86_MM0);
|
|
|
|
MmxMoveRegToReg(x86_MM7, x86_MM1);
|
|
|
|
|
|
|
|
MmxUnpackLowWord(x86_MM0, x86_MM4);
|
|
|
|
MmxUnpackHighWord(x86_MM6, x86_MM4);
|
|
|
|
MmxUnpackLowWord(x86_MM1, x86_MM5);
|
|
|
|
MmxUnpackHighWord(x86_MM7, x86_MM5);
|
|
|
|
|
|
|
|
// Integrate copies
|
|
|
|
MmxPackSignedDwords(x86_MM0, x86_MM6);
|
|
|
|
MmxPackSignedDwords(x86_MM1, x86_MM7);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM0, &m_Vect[m_OpCode.vd].s16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[4]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM1, &m_Vect[m_OpCode.vd].s16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsNextInstructionMmx(CompilePC))
|
2023-06-01 11:46:23 +00:00
|
|
|
MmxEmptyMultimediaState();
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
return true;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VMUDH(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVmudh
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VMUDH, "RSPOp::Vector_VMUDH");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t count, el, del;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bOptimize = (m_OpCode.rs & 8) ? true : false;
|
|
|
|
bool bWriteToDest = WriteToVectorDest(m_OpCode.sa, CompilePC);
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(EntireAccum, CompilePC);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bWriteToAccum)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
if (true == Compile_Vector_VMUDH_MMX())
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest == false && bOptimize == true)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
Push(x86_EBP);
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rd);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
// Load source
|
2024-08-08 03:25:54 +00:00
|
|
|
del = (m_OpCode.rs & 0x07) ^ 7;
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
// Pipe lined segment 0
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rd);
|
|
|
|
MoveOffsetToX86reg((size_t)&m_Vect[m_OpCode.vs].s16(0), Reg, x86_EBP);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
MoveSxX86RegPtrDispToX86RegHalf(x86_EBP, 0, x86_EAX);
|
|
|
|
MoveSxX86RegPtrDispToX86RegHalf(x86_EBP, 2, x86_ECX);
|
|
|
|
MoveSxX86RegPtrDispToX86RegHalf(x86_EBP, 4, x86_EDI);
|
|
|
|
MoveSxX86RegPtrDispToX86RegHalf(x86_EBP, 6, x86_ESI);
|
|
|
|
|
|
|
|
ImulX86RegToX86Reg(x86_EAX, x86_EBX);
|
|
|
|
ImulX86RegToX86Reg(x86_ECX, x86_EBX);
|
|
|
|
ImulX86RegToX86Reg(x86_EDI, x86_EBX);
|
|
|
|
ImulX86RegToX86Reg(x86_ESI, x86_EBX);
|
|
|
|
XorX86RegToX86Reg(x86_EDX, x86_EDX);
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveOffsetToX86reg((size_t)&m_ACCUM[0].W[0], "m_ACCUM[0].W[0]", x86_EBP);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
MoveX86RegToX86regPointerDisp(x86_EDX, x86_EBP, 0);
|
|
|
|
MoveX86RegToX86regPointerDisp(x86_EAX, x86_EBP, 4);
|
|
|
|
MoveX86RegToX86regPointerDisp(x86_EDX, x86_EBP, 8);
|
|
|
|
MoveX86RegToX86regPointerDisp(x86_ECX, x86_EBP, 12);
|
|
|
|
MoveX86RegToX86regPointerDisp(x86_EDX, x86_EBP, 16);
|
|
|
|
MoveX86RegToX86regPointerDisp(x86_EDI, x86_EBP, 20);
|
|
|
|
MoveX86RegToX86regPointerDisp(x86_EDX, x86_EBP, 24);
|
|
|
|
MoveX86RegToX86regPointerDisp(x86_ESI, x86_EBP, 28);
|
|
|
|
|
|
|
|
// Pipe lined segment 1
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rd);
|
|
|
|
MoveOffsetToX86reg((size_t)&m_Vect[m_OpCode.vs].s16(0), Reg, x86_EBP);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
MoveSxX86RegPtrDispToX86RegHalf(x86_EBP, 8, x86_EAX);
|
|
|
|
MoveSxX86RegPtrDispToX86RegHalf(x86_EBP, 10, x86_ECX);
|
|
|
|
MoveSxX86RegPtrDispToX86RegHalf(x86_EBP, 12, x86_EDI);
|
|
|
|
MoveSxX86RegPtrDispToX86RegHalf(x86_EBP, 14, x86_ESI);
|
|
|
|
|
|
|
|
ImulX86RegToX86Reg(x86_EAX, x86_EBX);
|
|
|
|
ImulX86RegToX86Reg(x86_ECX, x86_EBX);
|
|
|
|
ImulX86RegToX86Reg(x86_EDI, x86_EBX);
|
|
|
|
ImulX86RegToX86Reg(x86_ESI, x86_EBX);
|
|
|
|
XorX86RegToX86Reg(x86_EDX, x86_EDX);
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveOffsetToX86reg((size_t)&m_ACCUM[0].W[0], "m_ACCUM[0].W[0]", x86_EBP);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
MoveX86RegToX86regPointerDisp(x86_EDX, x86_EBP, 32);
|
|
|
|
MoveX86RegToX86regPointerDisp(x86_EAX, x86_EBP, 36);
|
|
|
|
MoveX86RegToX86regPointerDisp(x86_EDX, x86_EBP, 40);
|
|
|
|
MoveX86RegToX86regPointerDisp(x86_ECX, x86_EBP, 44);
|
|
|
|
MoveX86RegToX86regPointerDisp(x86_EDX, x86_EBP, 48);
|
|
|
|
MoveX86RegToX86regPointerDisp(x86_EDI, x86_EBP, 52);
|
|
|
|
MoveX86RegToX86regPointerDisp(x86_EDX, x86_EBP, 56);
|
|
|
|
MoveX86RegToX86regPointerDisp(x86_ESI, x86_EBP, 60);
|
|
|
|
|
|
|
|
Pop(x86_EBP);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bOptimize)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
del = (m_OpCode.rs & 0x07) ^ 7;
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
// Prepare for conditional moves
|
|
|
|
|
|
|
|
MoveConstToX86reg(0x00007fff, x86_ESI);
|
|
|
|
MoveConstToX86reg(0xFFFF8000, x86_EDI);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
|
|
|
CPU_Message(" Iteration: %i", count);
|
2024-08-08 03:25:54 +00:00
|
|
|
el = Indx[m_OpCode.e].B[count];
|
|
|
|
del = EleSpec[m_OpCode.e].B[el];
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rd, el);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vs].s16(el), Reg, x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bOptimize)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
imulX86reg(x86_EBX);
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &m_ACCUM[el].W[1], "m_ACCUM[el].W[1]");
|
|
|
|
MoveConstToVariable(0, &m_ACCUM[el].W[0], "m_ACCUM[el].W[0]");
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
CompX86RegToX86Reg(x86_EAX, x86_ESI);
|
|
|
|
CondMoveGreater(x86_EAX, x86_ESI);
|
|
|
|
CompX86RegToX86Reg(x86_EAX, x86_EDI);
|
|
|
|
CondMoveLess(x86_EAX, x86_EDI);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_Vect[m_OpCode.vd].s16(el), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VMACF(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVmacf
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VMACF, "&RSPOp::Vector_VMACF");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t count, el, del;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bOptimize = (m_OpCode.rs & 8) ? true : false;
|
|
|
|
bool bWriteToDest = WriteToVectorDest(m_OpCode.sa, CompilePC);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Prepare for conditional moves
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveConstToX86reg(0x00007fff, x86_ESI);
|
|
|
|
MoveConstToX86reg(0xFFFF8000, x86_EDI);
|
|
|
|
}
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bOptimize)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
del = (m_OpCode.rs & 0x07) ^ 7;
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
el = Indx[m_OpCode.e].B[count];
|
|
|
|
del = EleSpec[m_OpCode.e].B[el];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
CPU_Message(" Iteration: %i", count);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rd, el);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vs].s16(el), Reg, x86_EAX);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bOptimize)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
imulX86reg(x86_EBX);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86RegToX86Reg(x86_EAX, x86_EDX);
|
|
|
|
ShiftRightSignImmed(x86_EDX, 15);
|
|
|
|
ShiftLeftSignImmed(x86_EAX, 17);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
AddX86regToVariable(x86_EAX, &m_ACCUM[el].W[0], "m_ACCUM[el].W[0]");
|
|
|
|
AdcX86regToVariable(x86_EDX, &m_ACCUM[el].W[1], "m_ACCUM[el].W[1]");
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveVariableToX86reg(&m_ACCUM[el].W[1], "m_ACCUM[el].W[1]", x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
CompX86RegToX86Reg(x86_EAX, x86_ESI);
|
|
|
|
CondMoveGreater(x86_EAX, x86_ESI);
|
|
|
|
CompX86RegToX86Reg(x86_EAX, x86_EDI);
|
|
|
|
CondMoveLess(x86_EAX, x86_EDI);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_Vect[m_OpCode.vd].s16(el), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VMACU(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VMACU, "&RSPOp::Vector_VMACU");
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VMACQ(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VMACQ, "RSPOp::Vector_VMACQ");
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VMADL(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVmadl
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VMADL, "&RSPOp::Vector_VMADL");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t count, el, del;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bOptimize = (m_OpCode.rs & 8) ? true : false;
|
|
|
|
bool bWriteToDest = WriteToVectorDest(m_OpCode.sa, CompilePC);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bOptimize)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
del = (m_OpCode.rs & 0x07) ^ 7;
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveZxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Prepare for conditional moves
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveConstToX86reg(0x00007FFF, x86_ESI);
|
|
|
|
MoveConstToX86reg(0xFFFF8000, x86_EDI);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
Push(x86_EBP);
|
|
|
|
MoveConstToX86reg(0x0000FFFF, x86_EBP);
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
|
|
|
CPU_Message(" Iteration: %i", count);
|
2024-08-08 03:25:54 +00:00
|
|
|
el = Indx[m_OpCode.e].B[count];
|
|
|
|
del = EleSpec[m_OpCode.e].B[el];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rd, el);
|
|
|
|
MoveZxVariableToX86regHalf(&m_Vect[m_OpCode.vs].s16(el), Reg, x86_EAX);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bOptimize)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveZxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
imulX86reg(x86_EBX);
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].W[0]", el);
|
|
|
|
AddX86regToVariable(x86_EAX, &m_ACCUM[el].W[0], Reg);
|
|
|
|
sprintf(Reg, "m_ACCUM[%i].W[1]", el);
|
|
|
|
AdcConstToVariable(&m_ACCUM[el].W[1], Reg, 0);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest != false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
XorX86RegToX86Reg(x86_EDX, x86_EDX);
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveVariableToX86reg(&m_ACCUM[el].W[1], "m_ACCUM[el].W[1]", x86_EAX);
|
|
|
|
MoveZxVariableToX86regHalf(&m_ACCUM[el].HW[1], "m_ACCUM[el].hW[1]", x86_ECX);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
CompX86RegToX86Reg(x86_EAX, x86_ESI);
|
|
|
|
CondMoveGreater(x86_ECX, x86_EBP);
|
|
|
|
CompX86RegToX86Reg(x86_EAX, x86_EDI);
|
|
|
|
CondMoveLess(x86_ECX, x86_EDX);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_Vect[m_OpCode.vd].s16(el), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
Pop(x86_EBP);
|
|
|
|
}
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VMADM(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVmadm
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VMADM, "&RSPOp::Vector_VMADM");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t count, el, del;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bOptimize = (m_OpCode.rs & 8) ? true : false;
|
|
|
|
bool bWriteToDest = WriteToVectorDest(m_OpCode.sa, CompilePC);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bOptimize)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
del = (m_OpCode.rs & 0x07) ^ 7;
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveZxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
// Prepare for conditional moves
|
|
|
|
|
|
|
|
MoveConstToX86reg(0x00007fff, x86_ESI);
|
|
|
|
MoveConstToX86reg(0xFFFF8000, x86_EDI);
|
|
|
|
}
|
|
|
|
|
|
|
|
Push(x86_EBP);
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rd);
|
|
|
|
MoveOffsetToX86reg((size_t)&m_Vect[m_OpCode.vs].s16(0), Reg, x86_EBP);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
if (bWriteToDest)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.sa);
|
|
|
|
MoveOffsetToX86reg((size_t)&m_Vect[m_OpCode.vd].s16(0), Reg, x86_ECX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else if (!bOptimize)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rt);
|
|
|
|
MoveOffsetToX86reg((size_t)&m_Vect[m_OpCode.vt].s16(0), Reg, x86_ECX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
|
|
|
CPU_Message(" Iteration: %i", count);
|
2024-08-08 03:25:54 +00:00
|
|
|
el = Indx[m_OpCode.e].B[count];
|
|
|
|
del = EleSpec[m_OpCode.e].B[el];
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
/*sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rd, el);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vs].s16(el), Reg, x86_EAX);*/
|
2023-08-16 23:29:22 +00:00
|
|
|
MoveSxX86RegPtrDispToX86RegHalf(x86_EBP, (uint8_t)(el * 2), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bOptimize)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveZxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), "m_Vect[m_OpCode.vt].s16(del)", x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-16 23:29:22 +00:00
|
|
|
MoveZxX86RegPtrDispToX86RegHalf(x86_ECX, (uint8_t)(del * 2), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
imulX86reg(x86_EBX);
|
|
|
|
|
|
|
|
MoveX86RegToX86Reg(x86_EAX, x86_EDX);
|
|
|
|
ShiftRightSignImmed(x86_EDX, 16);
|
|
|
|
ShiftLeftSignImmed(x86_EAX, 16);
|
2024-08-07 21:56:15 +00:00
|
|
|
AddX86regToVariable(x86_EAX, &m_ACCUM[el].W[0], "m_ACCUM[el].W[0]");
|
|
|
|
AdcX86regToVariable(x86_EDX, &m_ACCUM[el].W[1], "m_ACCUM[el].W[1]");
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
// For compare
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].W[1]", el);
|
|
|
|
MoveVariableToX86reg(&m_ACCUM[el].W[1], "m_ACCUM[el].W[1]", x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
CompX86RegToX86Reg(x86_EAX, x86_ESI);
|
|
|
|
CondMoveGreater(x86_EAX, x86_ESI);
|
|
|
|
CompX86RegToX86Reg(x86_EAX, x86_EDI);
|
|
|
|
CondMoveLess(x86_EAX, x86_EDI);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
/*sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_Vect[m_OpCode.vd].s16(el), Reg);*/
|
2023-08-16 23:29:22 +00:00
|
|
|
MoveX86regHalfToX86regPointerDisp(x86_EAX, x86_ECX, (uint8_t)(el * 2));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
Pop(x86_EBP);
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VMADN(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVmadn
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VMADN, "RSPOp::Vector_VMADN");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t count, el, del;
|
2016-02-14 18:49:47 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bOptimize = (m_OpCode.rs & 8) ? true : false;
|
|
|
|
bool bWriteToDest = WriteToVectorDest(m_OpCode.sa, CompilePC);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bOptimize)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
del = (m_OpCode.rs & 0x07) ^ 7;
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Prepare for conditional moves
|
|
|
|
|
|
|
|
MoveConstToX86reg(0x0000ffff, x86_ESI);
|
|
|
|
MoveConstToX86reg(0x00000000, x86_EDI);
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
Push(x86_EBP);
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rd);
|
|
|
|
MoveOffsetToX86reg((size_t)&m_Vect[m_OpCode.vs].s16(0), Reg, x86_EBP);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
|
|
|
CPU_Message(" Iteration: %i", count);
|
2024-08-08 03:25:54 +00:00
|
|
|
el = Indx[m_OpCode.e].B[count];
|
|
|
|
del = EleSpec[m_OpCode.e].B[el];
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
/*sprintf(Reg, "m_Vect[%i].UHW[%i]", m_OpCode.rd, el);
|
|
|
|
MoveZxVariableToX86regHalf(&m_Vect[m_OpCode.vs].u16(el), Reg, x86_EAX);*/
|
2023-08-16 23:29:22 +00:00
|
|
|
MoveZxX86RegPtrDispToX86RegHalf(x86_EBP, (uint8_t)(el * 2), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bOptimize)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
imulX86reg(x86_EBX);
|
|
|
|
|
|
|
|
MoveX86RegToX86Reg(x86_EAX, x86_EDX);
|
|
|
|
ShiftRightSignImmed(x86_EDX, 16);
|
|
|
|
ShiftLeftSignImmed(x86_EAX, 16);
|
2024-08-07 21:56:15 +00:00
|
|
|
AddX86regToVariable(x86_EAX, &m_ACCUM[el].W[0], "m_ACCUM[el].W[0]");
|
|
|
|
AdcX86regToVariable(x86_EDX, &m_ACCUM[el].W[1], "m_ACCUM[el].W[1]");
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
// For compare
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].W[1]", el);
|
|
|
|
MoveVariableToX86reg(&m_ACCUM[el].W[1], Reg, x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
// For vector
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el);
|
|
|
|
MoveVariableToX86regHalf(&m_ACCUM[el].HW[1], Reg, x86_ECX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
// TODO: Weird eh?
|
|
|
|
CompConstToX86reg(x86_EAX, 0x7fff);
|
|
|
|
CondMoveGreater(x86_ECX, x86_ESI);
|
2023-08-10 04:46:57 +00:00
|
|
|
CompConstToX86reg(x86_EAX, (uint32_t)(-0x8000));
|
2023-06-01 11:46:23 +00:00
|
|
|
CondMoveLess(x86_ECX, x86_EDI);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_Vect[m_OpCode.vd].s16(el), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Pop(x86_EBP);
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VMADH(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVmadh
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VMADH, "RSPOp::Vector_VMADH");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t count, el, del;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bOptimize = (m_OpCode.rs & 8) ? true : false;
|
|
|
|
bool bWriteToDest = WriteToVectorDest(m_OpCode.sa, CompilePC);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bOptimize)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
del = (m_OpCode.rs & 0x07) ^ 7;
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
// Prepare for conditional moves
|
|
|
|
|
|
|
|
MoveConstToX86reg(0x00007fff, x86_ESI);
|
|
|
|
MoveConstToX86reg(0xFFFF8000, x86_EDI);
|
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest == false && bOptimize == true)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
Push(x86_EBP);
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rd);
|
|
|
|
MoveOffsetToX86reg((size_t)&m_Vect[m_OpCode.vs].s16(0), Reg, x86_EBP);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
// Pipe lined segment 0
|
|
|
|
|
|
|
|
MoveSxX86RegPtrDispToX86RegHalf(x86_EBP, 0, x86_EAX);
|
|
|
|
MoveSxX86RegPtrDispToX86RegHalf(x86_EBP, 2, x86_ECX);
|
|
|
|
MoveSxX86RegPtrDispToX86RegHalf(x86_EBP, 4, x86_EDI);
|
|
|
|
MoveSxX86RegPtrDispToX86RegHalf(x86_EBP, 6, x86_ESI);
|
|
|
|
|
|
|
|
ImulX86RegToX86Reg(x86_EAX, x86_EBX);
|
|
|
|
ImulX86RegToX86Reg(x86_ECX, x86_EBX);
|
|
|
|
ImulX86RegToX86Reg(x86_EDI, x86_EBX);
|
|
|
|
ImulX86RegToX86Reg(x86_ESI, x86_EBX);
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].W[1]", 0);
|
|
|
|
AddX86regToVariable(x86_EAX, &m_ACCUM[0].W[1], Reg);
|
|
|
|
sprintf(Reg, "m_ACCUM[%i].W[1]", 1);
|
|
|
|
AddX86regToVariable(x86_ECX, &m_ACCUM[1].W[1], Reg);
|
|
|
|
sprintf(Reg, "m_ACCUM[%i].W[1]", 2);
|
|
|
|
AddX86regToVariable(x86_EDI, &m_ACCUM[2].W[1], Reg);
|
|
|
|
sprintf(Reg, "m_ACCUM[%i].W[1]", 3);
|
|
|
|
AddX86regToVariable(x86_ESI, &m_ACCUM[3].W[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
// Pipe lined segment 1
|
|
|
|
|
|
|
|
MoveSxX86RegPtrDispToX86RegHalf(x86_EBP, 8, x86_EAX);
|
|
|
|
MoveSxX86RegPtrDispToX86RegHalf(x86_EBP, 10, x86_ECX);
|
|
|
|
MoveSxX86RegPtrDispToX86RegHalf(x86_EBP, 12, x86_EDI);
|
|
|
|
MoveSxX86RegPtrDispToX86RegHalf(x86_EBP, 14, x86_ESI);
|
|
|
|
|
|
|
|
ImulX86RegToX86Reg(x86_EAX, x86_EBX);
|
|
|
|
ImulX86RegToX86Reg(x86_ECX, x86_EBX);
|
|
|
|
ImulX86RegToX86Reg(x86_EDI, x86_EBX);
|
|
|
|
ImulX86RegToX86Reg(x86_ESI, x86_EBX);
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].W[1]", 4);
|
|
|
|
AddX86regToVariable(x86_EAX, &m_ACCUM[4].W[1], Reg);
|
|
|
|
sprintf(Reg, "m_ACCUM[%i].W[1]", 5);
|
|
|
|
AddX86regToVariable(x86_ECX, &m_ACCUM[5].W[1], Reg);
|
|
|
|
sprintf(Reg, "m_ACCUM[%i].W[1]", 6);
|
|
|
|
AddX86regToVariable(x86_EDI, &m_ACCUM[6].W[1], Reg);
|
|
|
|
sprintf(Reg, "m_ACCUM[%i].W[1]", 7);
|
|
|
|
AddX86regToVariable(x86_ESI, &m_ACCUM[7].W[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
Pop(x86_EBP);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Push(x86_EBP);
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rd);
|
|
|
|
MoveOffsetToX86reg((size_t)&m_Vect[m_OpCode.vs].s16(0), Reg, x86_EBP);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
if (bWriteToDest)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.sa);
|
|
|
|
MoveOffsetToX86reg((size_t)&m_Vect[m_OpCode.vd].s16(0), Reg, x86_ECX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else if (!bOptimize)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rt);
|
|
|
|
MoveOffsetToX86reg((size_t)&m_Vect[m_OpCode.vt].s16(0), Reg, x86_ECX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
|
|
|
CPU_Message(" Iteration: %i", count);
|
2024-08-08 03:25:54 +00:00
|
|
|
el = Indx[m_OpCode.e].B[count];
|
|
|
|
del = EleSpec[m_OpCode.e].B[el];
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
/*sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rd, el);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vs].s16(el), Reg, x86_EAX);*/
|
2023-08-16 23:29:22 +00:00
|
|
|
MoveSxX86RegPtrDispToX86RegHalf(x86_EBP, (uint8_t)(el * 2), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bOptimize)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-16 23:29:22 +00:00
|
|
|
MoveSxX86RegPtrDispToX86RegHalf(x86_ECX, (uint8_t)(del * 2), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
imulX86reg(x86_EBX);
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].W[1]", el);
|
|
|
|
AddX86regToVariable(x86_EAX, &m_ACCUM[el].W[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveVariableToX86reg(&m_ACCUM[el].W[1], "m_ACCUM[el].W[1]", x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
CompX86RegToX86Reg(x86_EAX, x86_ESI);
|
|
|
|
CondMoveGreater(x86_EAX, x86_ESI);
|
|
|
|
CompX86RegToX86Reg(x86_EAX, x86_EDI);
|
|
|
|
CondMoveLess(x86_EAX, x86_EDI);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
/*sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_Vect[m_OpCode.vd].s16(el), Reg);*/
|
2023-08-16 23:29:22 +00:00
|
|
|
MoveX86regHalfToX86regPointerDisp(x86_EAX, x86_ECX, (uint8_t)(el * 2));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Pop(x86_EBP);
|
|
|
|
}
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
bool CRSPRecompilerOps::Compile_Vector_VADD_MMX(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Do our MMX checks here
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsMmxEnabled)
|
|
|
|
return false;
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.rs & 0x0f) >= 2 && !(m_OpCode.rs & 8) && IsMmx2Enabled == false)
|
2023-06-29 02:59:07 +00:00
|
|
|
return false;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM0, &m_Vect[m_OpCode.vs].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM1, &m_Vect[m_OpCode.vs].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rs & 8)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
RSP_Element2Mmx(x86_MM2);
|
|
|
|
MmxPaddswRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPaddswRegToReg(x86_MM1, x86_MM2);
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if ((m_OpCode.rs & 15) < 2)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == m_OpCode.rt)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
MmxPaddswRegToReg(x86_MM0, x86_MM0);
|
|
|
|
MmxPaddswRegToReg(x86_MM1, x86_MM1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rt);
|
|
|
|
MmxPaddswVariableToReg(x86_MM0, &m_Vect[m_OpCode.vt].s16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[4]", m_OpCode.rt);
|
|
|
|
MmxPaddswVariableToReg(x86_MM1, &m_Vect[m_OpCode.vt].s16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RSP_MultiElement2Mmx(x86_MM2, x86_MM3);
|
|
|
|
MmxPaddswRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPaddswRegToReg(x86_MM1, x86_MM3);
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM0, &m_Vect[m_OpCode.vd].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM1, &m_Vect[m_OpCode.vd].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (IsNextInstructionMmx(CompilePC) != true)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
MmxEmptyMultimediaState();
|
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
return true;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VADD(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVadd
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VADD, "RSPOp::Vector_VADD");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t count, el, del;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bWriteToDest = WriteToVectorDest(m_OpCode.sa, CompilePC);
|
|
|
|
bool bElement = (m_OpCode.rs & 8) ? true : false;
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(Low16BitAccum, CompilePC);
|
|
|
|
bool bFlagUseage = UseRspFlags(CompilePC);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum == false && bFlagUseage == false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
if (true == Compile_Vector_VADD_MMX())
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bElement == true)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
del = (m_OpCode.rs & 0x07) ^ 7;
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
// Prepare for conditional moves
|
|
|
|
|
|
|
|
MoveConstToX86reg(0x00007fff, x86_ESI);
|
|
|
|
MoveConstToX86reg(0xffff8000, x86_EDI);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Used for invoking x86 carry flag
|
|
|
|
XorX86RegToX86Reg(x86_ECX, x86_ECX);
|
|
|
|
Push(x86_EBP);
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveVariableToX86reg(&m_Flags[0].UW, "m_Flags[0].UW", x86_EBP);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
|
|
|
CPU_Message(" Iteration: %i", count);
|
2024-08-08 03:25:54 +00:00
|
|
|
el = Indx[m_OpCode.e].B[count];
|
|
|
|
del = EleSpec[m_OpCode.e].B[el];
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rd, el);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vs].s16(el), Reg, x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bElement == false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MoveX86RegToX86Reg(x86_EBP, x86_EDX);
|
|
|
|
AndConstToX86Reg(x86_EDX, 1 << (7 - el));
|
|
|
|
CompX86RegToX86Reg(x86_ECX, x86_EDX);
|
|
|
|
|
|
|
|
AdcX86RegToX86Reg(x86_EAX, x86_EBX);
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum != false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_ACCUM[el].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest != false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
CompX86RegToX86Reg(x86_EAX, x86_ESI);
|
|
|
|
CondMoveGreater(x86_EAX, x86_ESI);
|
|
|
|
CompX86RegToX86Reg(x86_EAX, x86_EDI);
|
|
|
|
CondMoveLess(x86_EAX, x86_EDI);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_Vect[m_OpCode.vd].s16(el), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveConstToVariable(0, &m_Flags[0].UW, "m_Flags[0].UW");
|
2023-06-01 11:46:23 +00:00
|
|
|
Pop(x86_EBP);
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
bool CRSPRecompilerOps::Compile_Vector_VSUB_MMX(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Do our MMX checks here
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsMmxEnabled)
|
|
|
|
return false;
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.rs & 0x0f) >= 2 && !(m_OpCode.rs & 8) && IsMmx2Enabled == false)
|
2023-06-29 02:59:07 +00:00
|
|
|
return false;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM0, &m_Vect[m_OpCode.vs].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM1, &m_Vect[m_OpCode.vs].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.rs & 15) >= 8)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
RSP_Element2Mmx(x86_MM2);
|
|
|
|
MmxPsubswRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPsubswRegToReg(x86_MM1, x86_MM2);
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if ((m_OpCode.rs & 15) < 2)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == m_OpCode.rt)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
MmxPsubswRegToReg(x86_MM0, x86_MM0);
|
|
|
|
MmxPsubswRegToReg(x86_MM1, x86_MM1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rt);
|
|
|
|
MmxPsubswVariableToReg(x86_MM0, &m_Vect[m_OpCode.vt].s16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[4]", m_OpCode.rt);
|
|
|
|
MmxPsubswVariableToReg(x86_MM1, &m_Vect[m_OpCode.vt].s16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RSP_MultiElement2Mmx(x86_MM2, x86_MM3);
|
|
|
|
MmxPsubswRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPsubswRegToReg(x86_MM1, x86_MM3);
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM0, &m_Vect[m_OpCode.vd].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM1, &m_Vect[m_OpCode.vd].u16(4), Reg);
|
2023-06-29 02:59:07 +00:00
|
|
|
if (IsNextInstructionMmx(CompilePC) != true)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
MmxEmptyMultimediaState();
|
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
return true;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VSUB(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVsub
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VSUB, "&RSPOp::Vector_VSUB");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t count, el, del;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bWriteToDest = WriteToVectorDest(m_OpCode.sa, CompilePC);
|
|
|
|
bool bOptimize = (m_OpCode.rs & 8) ? true : false;
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(Low16BitAccum, CompilePC);
|
|
|
|
bool bFlagUseage = UseRspFlags(CompilePC);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum == false && bFlagUseage == false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
if (true == Compile_Vector_VSUB_MMX())
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
Push(x86_EBP);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Used for invoking the x86 carry flag
|
|
|
|
XorX86RegToX86Reg(x86_ECX, x86_ECX);
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveVariableToX86reg(&m_Flags[0].UW, "m_Flags[0].UW", x86_EBP);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bOptimize)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
del = (m_OpCode.rs & 0x07) ^ 7;
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Prepare for conditional moves
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveConstToX86reg(0x00007fff, x86_ESI);
|
|
|
|
MoveConstToX86reg(0xffff8000, x86_EDI);
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
|
|
|
CPU_Message(" Iteration: %i", count);
|
2024-08-08 03:25:54 +00:00
|
|
|
el = Indx[m_OpCode.e].B[count];
|
|
|
|
del = EleSpec[m_OpCode.e].B[el];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vs].s16(el), "m_Vect[m_OpCode.vs].s16(el)", x86_EAX);
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bOptimize)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86RegToX86Reg(x86_EBP, x86_EDX);
|
|
|
|
AndConstToX86Reg(x86_EDX, 1 << (7 - el));
|
|
|
|
CompX86RegToX86Reg(x86_ECX, x86_EDX);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
SbbX86RegToX86Reg(x86_EAX, x86_EBX);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum != false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_ACCUM[el].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest != false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
CompX86RegToX86Reg(x86_EAX, x86_ESI);
|
|
|
|
CondMoveGreater(x86_EAX, x86_ESI);
|
|
|
|
CompX86RegToX86Reg(x86_EAX, x86_EDI);
|
|
|
|
CondMoveLess(x86_EAX, x86_EDI);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_Vect[m_OpCode.vd].s16(el), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveConstToVariable(0, &m_Flags[0].UW, "m_Flags[0].UW");
|
2023-06-01 11:46:23 +00:00
|
|
|
Pop(x86_EBP);
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
bool CRSPRecompilerOps::Compile_Vector_VABS_MMX(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
char Reg[256];
|
|
|
|
|
|
|
|
// Do our MMX checks here
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsMmxEnabled)
|
|
|
|
return false;
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.rs & 0x0f) >= 2 && !(m_OpCode.rs & 8) && IsMmx2Enabled == false)
|
2023-06-29 02:59:07 +00:00
|
|
|
return false;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM0, &m_Vect[m_OpCode.vs].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM1, &m_Vect[m_OpCode.vs].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.rs & 15) >= 8)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
RSP_Element2Mmx(x86_MM2);
|
|
|
|
MmxMoveRegToReg(x86_MM3, x86_MM2);
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if ((m_OpCode.rs & 15) < 2)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd != m_OpCode.rt)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rt);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM2, &m_Vect[m_OpCode.vt].s16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[4]", m_OpCode.rt);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM3, &m_Vect[m_OpCode.vt].s16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rt);
|
2023-06-01 11:46:23 +00:00
|
|
|
MmxMoveRegToReg(x86_MM2, x86_MM0);
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[4]", m_OpCode.rt);
|
2023-06-01 11:46:23 +00:00
|
|
|
MmxMoveRegToReg(x86_MM3, x86_MM1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RSP_MultiElement2Mmx(x86_MM2, x86_MM3);
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == m_OpCode.rt)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
MmxPsrawImmed(x86_MM2, 15);
|
|
|
|
MmxPsrawImmed(x86_MM3, 15);
|
|
|
|
|
|
|
|
MmxXorRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxXorRegToReg(x86_MM1, x86_MM3);
|
|
|
|
|
|
|
|
MmxPsubswRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPsubswRegToReg(x86_MM1, x86_MM3);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MmxXorRegToReg(x86_MM7, x86_MM7);
|
|
|
|
|
|
|
|
MmxMoveRegToReg(x86_MM4, x86_MM0);
|
|
|
|
MmxMoveRegToReg(x86_MM5, x86_MM1);
|
|
|
|
|
|
|
|
MmxPsrawImmed(x86_MM4, 15);
|
|
|
|
MmxPsrawImmed(x86_MM5, 15);
|
|
|
|
|
|
|
|
MmxPcmpeqwRegToReg(x86_MM0, x86_MM7);
|
|
|
|
MmxPcmpeqwRegToReg(x86_MM1, x86_MM7);
|
|
|
|
|
|
|
|
MmxXorRegToReg(x86_MM2, x86_MM4);
|
|
|
|
MmxXorRegToReg(x86_MM3, x86_MM5);
|
|
|
|
|
|
|
|
MmxPsubswRegToReg(x86_MM2, x86_MM4);
|
|
|
|
MmxPsubswRegToReg(x86_MM3, x86_MM5);
|
|
|
|
|
|
|
|
MmxPandnRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPandnRegToReg(x86_MM1, x86_MM3);
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM0, &m_Vect[m_OpCode.vd].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM1, &m_Vect[m_OpCode.vd].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (IsNextInstructionMmx(CompilePC) != true)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
MmxEmptyMultimediaState();
|
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
return true;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VABS(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVabs
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VABS, "RSPOp::Vector_VABS");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t count, el, del;
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2016-02-14 18:49:47 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bWriteToDest = WriteToVectorDest(m_OpCode.sa, CompilePC);
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(Low16BitAccum, CompilePC);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bWriteToAccum)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
if (true == Compile_Vector_VABS_MMX())
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
|
|
|
CPU_Message(" Iteration: %i", count);
|
2024-08-08 03:25:54 +00:00
|
|
|
el = Indx[m_OpCode.e].B[count];
|
|
|
|
del = EleSpec[m_OpCode.e].B[el];
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rd == m_OpCode.rt && (m_OpCode.rs & 0xF) < 2)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
// Optimize: EDI/ESI unused, and ECX is CONST etc.
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rd, el);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vs].s16(el), Reg, x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
// Obtain the negative of the source
|
|
|
|
MoveX86RegToX86Reg(x86_EAX, x86_EBX);
|
|
|
|
NegateX86reg(x86_EBX);
|
|
|
|
|
|
|
|
// Determine negative value,
|
|
|
|
// Note: negate(FFFF8000h) == 00008000h
|
|
|
|
|
|
|
|
MoveConstToX86reg(0x7fff, x86_ECX);
|
|
|
|
CompConstToX86reg(x86_EBX, 0x00008000);
|
|
|
|
CondMoveEqual(x86_EBX, x86_ECX);
|
|
|
|
|
|
|
|
// sign clamp, dest = (eax >= 0) ? eax : ebx
|
|
|
|
CompConstToX86reg(x86_EAX, 0);
|
|
|
|
CondMoveLess(x86_EAX, x86_EBX);
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_Vect[m_OpCode.vd].s16(el), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_ACCUM[el].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
|
|
|
// Optimize: ESI unused, and EDX is CONST etc.
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rd, el);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vs].s16(el), Reg, x86_EAX);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
// Obtain the negative of the source
|
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_ECX);
|
|
|
|
NegateX86reg(x86_EBX);
|
|
|
|
|
|
|
|
// Determine negative value,
|
|
|
|
// Note: negate(FFFF8000h) == 00008000h
|
|
|
|
|
|
|
|
MoveConstToX86reg(0x7fff, x86_EDX);
|
|
|
|
CompConstToX86reg(x86_EBX, 0x00008000);
|
|
|
|
CondMoveEqual(x86_EBX, x86_EDX);
|
|
|
|
|
|
|
|
// sign clamp, dest = (eax >= 0) ? ecx : ebx
|
|
|
|
CompConstToX86reg(x86_EAX, 0);
|
|
|
|
CondMoveGreaterEqual(x86_EDI, x86_ECX);
|
|
|
|
CondMoveLess(x86_EDI, x86_EBX);
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_EDI, &m_Vect[m_OpCode.vd].s16(el), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el);
|
|
|
|
MoveX86regHalfToVariable(x86_EDI, &m_ACCUM[el].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VADDC(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVaddc
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VADDC, "&RSPOp::Vector_VADDC");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t count, el, del;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bWriteToDest = WriteToVectorDest(m_OpCode.sa, CompilePC);
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(Low16BitAccum, CompilePC);
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bElement = (m_OpCode.rs & 8) ? true : false;
|
2016-02-14 18:49:47 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bElement == true)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
del = (m_OpCode.rs & 0x07) ^ 7;
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveZxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Initialize flag register
|
|
|
|
XorX86RegToX86Reg(x86_ECX, x86_ECX);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
Push(x86_EBP);
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rd);
|
|
|
|
MoveOffsetToX86reg((size_t)&m_Vect[m_OpCode.vs].s16(0), Reg, x86_EBP);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
|
|
|
CPU_Message(" Iteration: %i", count);
|
2024-08-08 03:25:54 +00:00
|
|
|
el = Indx[m_OpCode.e].B[count];
|
|
|
|
del = EleSpec[m_OpCode.e].B[el];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
/*sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rd, el);
|
|
|
|
MoveZxVariableToX86regHalf(&m_Vect[m_OpCode.vs].s16(el), Reg, x86_EAX);*/
|
2023-08-16 23:29:22 +00:00
|
|
|
MoveZxX86RegPtrDispToX86RegHalf(x86_EBP, (uint8_t)(el * 2), x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bElement == false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveZxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AddX86RegToX86Reg(x86_EAX, x86_EBX);
|
|
|
|
|
|
|
|
XorX86RegToX86Reg(x86_EDX, x86_EDX);
|
|
|
|
TestConstToX86Reg(0xFFFF0000, x86_EAX);
|
|
|
|
Setnz(x86_EDX);
|
|
|
|
if ((7 - el) != 0)
|
|
|
|
{
|
2023-08-16 23:29:22 +00:00
|
|
|
ShiftLeftSignImmed(x86_EDX, (uint8_t)(7 - el));
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
OrX86RegToX86Reg(x86_ECX, x86_EDX);
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum != false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_ACCUM[el].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest != false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_Vect[m_OpCode.vd].s16(el), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveX86regToVariable(x86_ECX, &m_Flags[0].UW, "m_Flags[0].UW");
|
2023-06-01 11:46:23 +00:00
|
|
|
Pop(x86_EBP);
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VSUBC(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVsubc
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VSUBC, "&RSPOp::Vector_VSUBC");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t count, el, del;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bWriteToDest = WriteToVectorDest(m_OpCode.sa, CompilePC);
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(Low16BitAccum, CompilePC);
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bElement = (m_OpCode.rs & 8) ? true : false;
|
2016-02-14 18:49:47 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bElement == true)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
del = (m_OpCode.rs & 0x07) ^ 7;
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveZxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize flag register
|
|
|
|
XorX86RegToX86Reg(x86_ECX, x86_ECX);
|
|
|
|
|
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
|
|
|
CPU_Message(" Iteration: %i", count);
|
2024-08-08 03:25:54 +00:00
|
|
|
el = Indx[m_OpCode.e].B[count];
|
|
|
|
del = EleSpec[m_OpCode.e].B[el];
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rd, el);
|
|
|
|
MoveZxVariableToX86regHalf(&m_Vect[m_OpCode.vs].s16(el), Reg, x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bElement == false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveZxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SubX86RegToX86Reg(x86_EAX, x86_EBX);
|
|
|
|
|
|
|
|
XorX86RegToX86Reg(x86_EDX, x86_EDX);
|
|
|
|
TestConstToX86Reg(0x0000FFFF, x86_EAX);
|
|
|
|
Setnz(x86_EDX);
|
2023-08-16 23:29:22 +00:00
|
|
|
ShiftLeftSignImmed(x86_EDX, (uint8_t)(15 - el));
|
2023-06-01 11:46:23 +00:00
|
|
|
OrX86RegToX86Reg(x86_ECX, x86_EDX);
|
|
|
|
|
|
|
|
XorX86RegToX86Reg(x86_EDX, x86_EDX);
|
|
|
|
TestConstToX86Reg(0xFFFF0000, x86_EAX);
|
|
|
|
Setnz(x86_EDX);
|
2023-08-16 23:29:22 +00:00
|
|
|
ShiftLeftSignImmed(x86_EDX, (uint8_t)(7 - el));
|
2023-06-01 11:46:23 +00:00
|
|
|
OrX86RegToX86Reg(x86_ECX, x86_EDX);
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum != false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_ACCUM[el].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest != false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_Vect[m_OpCode.vd].s16(el), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveX86regToVariable(x86_ECX, &m_Flags[0].UW, "m_Flags[0].UW");
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VSAW(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
#ifndef CompileVsaw
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VSAW, "RSPOp::Vector_VSAW");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
|
|
|
char Reg[256];
|
|
|
|
uint32_t Word;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
switch ((m_OpCode.rs & 0xF))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
case 8: Word = 3; break;
|
|
|
|
case 9: Word = 2; break;
|
|
|
|
case 10: Word = 1; break;
|
|
|
|
default:
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveConstToVariable(0, &m_Vect[m_OpCode.vd].u64(1), "m_Vect[m_OpCode.vd].s64(1)");
|
|
|
|
MoveConstToVariable(0, &m_Vect[m_OpCode.vd].u64(0), "m_Vect[m_OpCode.vd].s64(0)");
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[1].HW[%i]", Word);
|
|
|
|
MoveVariableToX86regHalf(&m_ACCUM[1].HW[Word], Reg, x86_EAX);
|
|
|
|
sprintf(Reg, "m_ACCUM[3].HW[%i]", Word);
|
|
|
|
MoveVariableToX86regHalf(&m_ACCUM[3].HW[Word], Reg, x86_EBX);
|
|
|
|
sprintf(Reg, "m_ACCUM[5].HW[%i]", Word);
|
|
|
|
MoveVariableToX86regHalf(&m_ACCUM[5].HW[Word], Reg, x86_ECX);
|
|
|
|
sprintf(Reg, "m_ACCUM[7].HW[%i]", Word);
|
|
|
|
MoveVariableToX86regHalf(&m_ACCUM[7].HW[Word], Reg, x86_EDX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
ShiftLeftSignImmed(x86_EAX, 16);
|
|
|
|
ShiftLeftSignImmed(x86_EBX, 16);
|
|
|
|
ShiftLeftSignImmed(x86_ECX, 16);
|
|
|
|
ShiftLeftSignImmed(x86_EDX, 16);
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[0].HW[%i]", Word);
|
|
|
|
MoveVariableToX86regHalf(&m_ACCUM[0].HW[Word], Reg, x86_EAX);
|
|
|
|
sprintf(Reg, "m_ACCUM[2].HW[%i]", Word);
|
|
|
|
MoveVariableToX86regHalf(&m_ACCUM[2].HW[Word], Reg, x86_EBX);
|
|
|
|
sprintf(Reg, "m_ACCUM[4].HW[%i]", Word);
|
|
|
|
MoveVariableToX86regHalf(&m_ACCUM[4].HW[Word], Reg, x86_ECX);
|
|
|
|
sprintf(Reg, "m_ACCUM[6].HW[%i]", Word);
|
|
|
|
MoveVariableToX86regHalf(&m_ACCUM[6].HW[Word], Reg, x86_EDX);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.sa);
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_Vect[m_OpCode.vd].s16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[2]", m_OpCode.sa);
|
|
|
|
MoveX86regToVariable(x86_EBX, &m_Vect[m_OpCode.vd].s16(2), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[4]", m_OpCode.sa);
|
|
|
|
MoveX86regToVariable(x86_ECX, &m_Vect[m_OpCode.vd].s16(4), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[6]", m_OpCode.sa);
|
|
|
|
MoveX86regToVariable(x86_EDX, &m_Vect[m_OpCode.vd].s16(6), Reg);
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VLT(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVlt
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VLT, "&RSPOp::Vector_VLT");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bWriteToDest = WriteToVectorDest(m_OpCode.sa, CompilePC);
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(Low16BitAccum, CompilePC);
|
2023-08-16 23:29:22 +00:00
|
|
|
uint8_t * jump[3];
|
2023-08-10 04:46:57 +00:00
|
|
|
uint32_t flag;
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t el, del, last;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-07-13 11:39:18 +00:00
|
|
|
last = (uint8_t)-1;
|
2023-06-01 11:46:23 +00:00
|
|
|
XorX86RegToX86Reg(x86_EBX, x86_EBX);
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveVariableToX86reg(&m_Flags[0].UW, "&m_Flags[0].UW", x86_ESI);
|
2023-06-01 11:46:23 +00:00
|
|
|
for (el = 0; el < 8; el++)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
del = EleSpec[m_OpCode.e].B[el];
|
2023-06-01 11:46:23 +00:00
|
|
|
flag = 0x101 << (7 - el);
|
2024-08-08 03:25:54 +00:00
|
|
|
if (del != el || m_OpCode.rt != m_OpCode.rd)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
if (del != last)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_ECX);
|
2023-06-01 11:46:23 +00:00
|
|
|
last = del;
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rd, el);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vs].s16(el), Reg, x86_EDX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
CompX86RegToX86Reg(x86_EDX, x86_ECX);
|
|
|
|
JgeLabel8("jge", 0);
|
2023-08-16 23:29:22 +00:00
|
|
|
jump[0] = (uint8_t *)(RecompPos - 1);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
if (bWriteToAccum || bWriteToDest)
|
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el);
|
|
|
|
MoveX86regHalfToVariable(x86_EDX, &m_ACCUM[el].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
OrConstToX86Reg((flag & 0xFF), x86_EBX);
|
|
|
|
|
|
|
|
JmpLabel8("jmp", 0);
|
2023-08-16 23:29:22 +00:00
|
|
|
jump[1] = (uint8_t *)(RecompPos - 1);
|
2023-06-01 11:46:23 +00:00
|
|
|
x86_SetBranch8b(jump[0], RecompPos);
|
|
|
|
|
|
|
|
if (bWriteToAccum || bWriteToDest)
|
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_ACCUM[el].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
JneLabel8("jne", 0);
|
2023-08-16 23:29:22 +00:00
|
|
|
jump[2] = (uint8_t *)(RecompPos - 1);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
MoveX86RegToX86Reg(x86_ESI, x86_EDI);
|
|
|
|
AndConstToX86Reg(x86_EDI, flag);
|
|
|
|
ShiftRightUnsignImmed(x86_EDI, 8);
|
|
|
|
AndX86RegToX86Reg(x86_EDI, x86_ESI);
|
|
|
|
OrX86RegToX86Reg(x86_EBX, x86_EDI);
|
|
|
|
|
|
|
|
x86_SetBranch8b(jump[2], RecompPos);
|
|
|
|
x86_SetBranch8b(jump[1], RecompPos);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MoveX86RegToX86Reg(x86_ESI, x86_EDI);
|
|
|
|
if (bWriteToAccum || bWriteToDest)
|
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_ACCUM[el].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
AndConstToX86Reg(x86_EDI, flag);
|
|
|
|
ShiftRightUnsignImmed(x86_EDI, 8);
|
|
|
|
AndX86RegToX86Reg(x86_EDI, x86_ESI);
|
|
|
|
OrX86RegToX86Reg(x86_EBX, x86_EDI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveConstToVariable(0, &m_Flags[0].UW, "m_Flags[0].UW");
|
|
|
|
MoveX86regToVariable(x86_EBX, &m_Flags[1].UW, "m_Flags[1].UW");
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest != false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
for (el = 0; el < 8; el += 2)
|
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el);
|
|
|
|
MoveVariableToX86regHalf(&m_ACCUM[el].HW[1], Reg, x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el + 1);
|
|
|
|
MoveVariableToX86regHalf(&m_ACCUM[el + 1].HW[1], Reg, x86_ECX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_Vect[m_OpCode.vd].s16(el), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el + 1);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_Vect[m_OpCode.vd].s16(el + 1), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VEQ(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVeq
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VEQ, "&RSPOp::Vector_VEQ");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bWriteToDest = WriteToVectorDest(m_OpCode.sa, CompilePC);
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(Low16BitAccum, CompilePC);
|
2023-08-10 04:46:57 +00:00
|
|
|
uint32_t flag;
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t count, el, del, last = (uint8_t)-1;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveZxVariableToX86regHalf(&m_Flags[0].UHW[1], "&m_Flags[0].UHW[1]", x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
XorConstToX86Reg(x86_EBX, 0xFFFF);
|
|
|
|
for (el = 0; el < 8; el++)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
del = EleSpec[m_OpCode.e].B[el];
|
2023-06-01 11:46:23 +00:00
|
|
|
flag = (0x101 << (7 - el)) ^ 0xFFFF;
|
2024-08-08 03:25:54 +00:00
|
|
|
if (del != el || m_OpCode.rt != m_OpCode.rd)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
if (del != last)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveZxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_ECX);
|
2023-06-01 11:46:23 +00:00
|
|
|
last = del;
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rd, el);
|
|
|
|
MoveZxVariableToX86regHalf(&m_Vect[m_OpCode.vs].s16(el), Reg, x86_EDX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
if (bWriteToAccum)
|
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_ACCUM[el].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SubX86RegToX86Reg(x86_EDX, x86_ECX);
|
|
|
|
CompConstToX86reg(x86_EDX, 1);
|
|
|
|
SbbX86RegToX86Reg(x86_EDX, x86_EDX);
|
|
|
|
OrConstToX86Reg(flag, x86_EDX);
|
|
|
|
AndX86RegToX86Reg(x86_EBX, x86_EDX);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (bWriteToAccum)
|
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_ACCUM[el].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveConstToVariable(0, &m_Flags[0].UW, "m_Flags[0].UW");
|
|
|
|
MoveX86regToVariable(x86_EBX, &m_Flags[1].UW, "m_Flags[1].UW");
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest != false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
el = EleSpec[m_OpCode.e].B[count];
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
if (el != last)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[%i]", m_OpCode.rt, el);
|
|
|
|
MoveVariableToX86regHalf(&m_Vect[m_OpCode.vt].u16(el), Reg, x86_EDX);
|
2023-06-01 11:46:23 +00:00
|
|
|
last = el;
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, count);
|
|
|
|
MoveX86regHalfToVariable(x86_EDX, &m_Vect[m_OpCode.vd].s16(count), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VNE(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVne
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VNE, "&RSPOp::Vector_VNE");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bWriteToDest = WriteToVectorDest(m_OpCode.sa, CompilePC);
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(Low16BitAccum, CompilePC);
|
2023-08-10 04:46:57 +00:00
|
|
|
uint32_t flag;
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t el, del, last = (uint8_t)-1;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveZxVariableToX86regHalf(&m_Flags[0].UHW[1], "&m_Flags[0].UHW[1]", x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
for (el = 0; el < 8; el++)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
del = EleSpec[m_OpCode.e].B[el];
|
2023-06-01 11:46:23 +00:00
|
|
|
flag = 0x101 << (7 - el);
|
2024-08-08 03:25:54 +00:00
|
|
|
if (del != el || m_OpCode.rt != m_OpCode.rd)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rd, el);
|
|
|
|
MoveZxVariableToX86regHalf(&m_Vect[m_OpCode.vs].s16(el), Reg, x86_EDX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
if (del != last)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveZxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_ECX);
|
2023-06-01 11:46:23 +00:00
|
|
|
last = del;
|
|
|
|
}
|
|
|
|
if (bWriteToAccum)
|
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el);
|
|
|
|
MoveX86regHalfToVariable(x86_EDX, &m_ACCUM[el].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SubX86RegToX86Reg(x86_EDX, x86_ECX);
|
|
|
|
NegateX86reg(x86_EDX);
|
|
|
|
SbbX86RegToX86Reg(x86_EDX, x86_EDX);
|
|
|
|
AndConstToX86Reg(x86_EDX, flag);
|
|
|
|
OrX86RegToX86Reg(x86_EBX, x86_EDX);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (bWriteToAccum)
|
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el);
|
|
|
|
MoveX86regHalfToVariable(x86_EDX, &m_ACCUM[el].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveConstToVariable(0, &m_Flags[0].UW, "m_Flags[0].UW");
|
|
|
|
MoveX86regToVariable(x86_EBX, &m_Flags[1].UW, "m_Flags[1].UW");
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest != false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
for (el = 0; el < 4; el++)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].W[%i]", m_OpCode.rd, el);
|
|
|
|
MoveVariableToX86reg(&m_Vect[m_OpCode.vs].s32(el), Reg, x86_EDX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].W[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regToVariable(x86_EDX, &m_Vect[m_OpCode.vd].s32(el), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
bool CRSPRecompilerOps::Compile_Vector_VGE_MMX(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.rs & 0xF) >= 2 && !(m_OpCode.rs & 8) && IsMmx2Enabled == false)
|
2023-06-29 02:59:07 +00:00
|
|
|
return false;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveConstToVariable(0, &m_Flags[1].UW, "m_Flags[1].UW");
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM0, &m_Vect[m_OpCode.vs].s16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[4]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM1, &m_Vect[m_OpCode.vs].s16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
MmxMoveRegToReg(x86_MM2, x86_MM0);
|
|
|
|
MmxMoveRegToReg(x86_MM3, x86_MM1);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.rs & 0x0f) < 2)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rt);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM4, &m_Vect[m_OpCode.vt].s16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[4]", m_OpCode.rt);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM5, &m_Vect[m_OpCode.vt].s16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs & 8)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
RSP_Element2Mmx(x86_MM4);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RSP_MultiElement2Mmx(x86_MM4, x86_MM5);
|
|
|
|
}
|
|
|
|
|
|
|
|
MmxCompareGreaterWordRegToReg(x86_MM2, x86_MM4);
|
2024-08-08 03:25:54 +00:00
|
|
|
MmxCompareGreaterWordRegToReg(x86_MM3, (m_OpCode.rs & 8) ? x86_MM4 : x86_MM5);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
MmxPandRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPandRegToReg(x86_MM1, x86_MM3);
|
|
|
|
MmxPandnRegToReg(x86_MM2, x86_MM4);
|
2024-08-08 03:25:54 +00:00
|
|
|
MmxPandnRegToReg(x86_MM3, (m_OpCode.rs & 8) ? x86_MM4 : x86_MM5);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
MmxPorRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPorRegToReg(x86_MM1, x86_MM3);
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveConstToVariable(0, &m_Flags[0].UW, "m_Flags[0].UW");
|
2023-06-29 02:59:07 +00:00
|
|
|
return true;
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VGE(void)
|
2024-07-06 09:34:50 +00:00
|
|
|
{
|
|
|
|
#ifndef CompileVge
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VGE, "&RSPOp::Vector_VGE");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
|
|
|
/*
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(Low16BitAccum, CompilePC);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-11-09 01:23:06 +00:00
|
|
|
TODO: works ok, but needs careful flag analysis */
|
2023-06-01 11:46:23 +00:00
|
|
|
/* #if defined (DLIST)
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum == false && true == Compile_Vector_VGE_MMX()) {
|
2016-01-27 09:39:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
*/
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bWriteToDest = WriteToVectorDest(m_OpCode.sa, CompilePC);
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(Low16BitAccum, CompilePC);
|
2023-08-16 23:29:22 +00:00
|
|
|
uint8_t * jump[3];
|
2023-08-10 04:46:57 +00:00
|
|
|
uint32_t flag;
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t el, del, last = (uint8_t)-1;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
XorX86RegToX86Reg(x86_EBX, x86_EBX);
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveVariableToX86reg(&m_Flags[0].UW, "&m_Flags[0].UW", x86_ESI);
|
2023-06-01 11:46:23 +00:00
|
|
|
for (el = 0; el < 8; el++)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
del = EleSpec[m_OpCode.e].B[el];
|
2023-06-01 11:46:23 +00:00
|
|
|
flag = 0x101 << (7 - el);
|
2024-08-08 03:25:54 +00:00
|
|
|
if (del != el || m_OpCode.rt != m_OpCode.rd)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
if (del != last)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_ECX);
|
2023-06-01 11:46:23 +00:00
|
|
|
last = del;
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rd, el);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vs].s16(el), Reg, x86_EDX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
CompX86RegToX86Reg(x86_EDX, x86_ECX);
|
|
|
|
JleLabel8("jle", 0);
|
2023-08-16 23:29:22 +00:00
|
|
|
jump[0] = (uint8_t *)(RecompPos - 1);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
if (bWriteToAccum || bWriteToDest)
|
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el);
|
|
|
|
MoveX86regHalfToVariable(x86_EDX, &m_ACCUM[el].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
OrConstToX86Reg((flag & 0xFF), x86_EBX);
|
|
|
|
|
|
|
|
JmpLabel8("jmp", 0);
|
2023-08-16 23:29:22 +00:00
|
|
|
jump[1] = (uint8_t *)(RecompPos - 1);
|
2023-06-01 11:46:23 +00:00
|
|
|
x86_SetBranch8b(jump[0], RecompPos);
|
|
|
|
|
|
|
|
if (bWriteToAccum || bWriteToDest)
|
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_ACCUM[el].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
JneLabel8("jne", 0);
|
2023-08-16 23:29:22 +00:00
|
|
|
jump[2] = (uint8_t *)(RecompPos - 1);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
MoveX86RegToX86Reg(x86_ESI, x86_EDI);
|
|
|
|
AndConstToX86Reg(x86_EDI, flag);
|
|
|
|
SubConstFromX86Reg(x86_EDI, flag);
|
|
|
|
ShiftRightSignImmed(x86_EDI, 31);
|
|
|
|
AndConstToX86Reg(x86_EDI, (flag & 0xFF));
|
|
|
|
OrX86RegToX86Reg(x86_EBX, x86_EDI);
|
|
|
|
|
|
|
|
x86_SetBranch8b(jump[1], RecompPos);
|
|
|
|
x86_SetBranch8b(jump[2], RecompPos);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MoveX86RegToX86Reg(x86_ESI, x86_EDI);
|
|
|
|
if (bWriteToAccum || bWriteToDest)
|
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_ACCUM[el].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
AndConstToX86Reg(x86_EDI, flag);
|
|
|
|
SubConstFromX86Reg(x86_EDI, flag);
|
|
|
|
ShiftRightSignImmed(x86_EDI, 31);
|
|
|
|
AndConstToX86Reg(x86_EDI, (flag & 0xFF));
|
|
|
|
OrX86RegToX86Reg(x86_EBX, x86_EDI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveConstToVariable(0, &m_Flags[0].UW, "m_Flags[0].UW");
|
|
|
|
MoveX86regToVariable(x86_EBX, &m_Flags[1].UW, "m_Flags[1].UW");
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest != false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
for (el = 0; el < 8; el += 2)
|
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el + 0);
|
|
|
|
MoveVariableToX86regHalf(&m_ACCUM[el].HW[1], Reg, x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el + 1);
|
|
|
|
MoveVariableToX86regHalf(&m_ACCUM[el + 1].HW[1], Reg, x86_ECX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el + 0);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_Vect[m_OpCode.vd].s16(el + 0), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el + 1);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_Vect[m_OpCode.vd].s16(el + 1), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VCL(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VCL, "RSPOp::Vector_VCL");
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VCH(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VCH, "RSPOp::Vector_VCH");
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VCR(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VCR, "RSPOp::Vector_VCR");
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VMRG(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVmrg
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VMRG, "&RSPOp::Vector_VMRG");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t count, el, del;
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(Low16BitAccum, CompilePC);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-08-07 21:56:15 +00:00
|
|
|
MoveVariableToX86reg(&m_Flags[1].UW, "m_Flags[1].UW", x86_EDX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
el = Indx[m_OpCode.e].UB[count];
|
|
|
|
del = EleSpec[m_OpCode.e].UB[el];
|
2023-06-01 11:46:23 +00:00
|
|
|
CPU_Message(" Iteration: %i", count);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rd, el);
|
|
|
|
MoveZxVariableToX86regHalf(&m_Vect[m_OpCode.vs].s16(el), Reg, x86_EAX);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveZxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
TestConstToX86Reg(1 << (7 - el), x86_EDX);
|
|
|
|
CondMoveNotEqual(x86_ECX, x86_EAX);
|
|
|
|
CondMoveEqual(x86_ECX, x86_EBX);
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_ACCUM[el].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_Vect[m_OpCode.vd].s16(el), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
bool CRSPRecompilerOps::Compile_Vector_VAND_MMX(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Do our MMX checks here
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsMmxEnabled)
|
|
|
|
return false;
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.rs & 0x0f) >= 2 && !(m_OpCode.rs & 8) && IsMmx2Enabled == false)
|
2023-06-29 02:59:07 +00:00
|
|
|
return false;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM0, &m_Vect[m_OpCode.vs].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM1, &m_Vect[m_OpCode.vs].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rs & 8)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
RSP_Element2Mmx(x86_MM2);
|
|
|
|
MmxPandRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPandRegToReg(x86_MM1, x86_MM2);
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if ((m_OpCode.rs & 0xF) < 2)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rt);
|
|
|
|
MmxPandVariableToReg(&m_Vect[m_OpCode.vt].s16(0), Reg, x86_MM0);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[4]", m_OpCode.rt);
|
|
|
|
MmxPandVariableToReg(&m_Vect[m_OpCode.vt].s16(4), Reg, x86_MM1);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RSP_MultiElement2Mmx(x86_MM2, x86_MM3);
|
|
|
|
MmxPandRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPandRegToReg(x86_MM1, x86_MM3);
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM0, &m_Vect[m_OpCode.vd].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM1, &m_Vect[m_OpCode.vd].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsNextInstructionMmx(CompilePC))
|
2023-06-01 11:46:23 +00:00
|
|
|
MmxEmptyMultimediaState();
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
return true;
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VAND(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVand
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VAND, "RSPOp::Vector_VAND");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t el, del, count;
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bWriteToDest = WriteToVectorDest(m_OpCode.sa, CompilePC);
|
|
|
|
bool bElement = (m_OpCode.rs & 8) ? true : false;
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(Low16BitAccum, CompilePC);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bWriteToAccum)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
if (true == Compile_Vector_VAND_MMX())
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bElement == true)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
del = (m_OpCode.rs & 0x07) ^ 7;
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
el = Indx[m_OpCode.e].B[count];
|
|
|
|
del = EleSpec[m_OpCode.e].B[el];
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
CPU_Message(" Iteration: %i", count);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rd, el);
|
|
|
|
MoveVariableToX86regHalf(&m_Vect[m_OpCode.vs].s16(el), Reg, x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bElement == false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
AndVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
AndX86RegHalfToX86RegHalf(x86_EAX, x86_EBX);
|
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest != false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_Vect[m_OpCode.vd].s16(el), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum != false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_ACCUM[el].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
bool CRSPRecompilerOps::Compile_Vector_VNAND_MMX(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Do our MMX checks here
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsMmxEnabled)
|
|
|
|
return false;
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.rs & 0x0f) >= 2 && !(m_OpCode.rs & 8) && IsMmx2Enabled == false)
|
2023-06-29 02:59:07 +00:00
|
|
|
return false;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM0, &m_Vect[m_OpCode.vs].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM1, &m_Vect[m_OpCode.vs].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
MmxPcmpeqwRegToReg(x86_MM7, x86_MM7);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rs & 8)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
RSP_Element2Mmx(x86_MM2);
|
|
|
|
MmxPandRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPandRegToReg(x86_MM1, x86_MM2);
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if ((m_OpCode.rs & 0xF) < 2)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rt);
|
|
|
|
MmxPandVariableToReg(&m_Vect[m_OpCode.vt].s16(0), Reg, x86_MM0);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[4]", m_OpCode.rt);
|
|
|
|
MmxPandVariableToReg(&m_Vect[m_OpCode.vt].s16(4), Reg, x86_MM1);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RSP_MultiElement2Mmx(x86_MM2, x86_MM3);
|
|
|
|
MmxPandRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPandRegToReg(x86_MM1, x86_MM3);
|
|
|
|
}
|
|
|
|
|
|
|
|
MmxXorRegToReg(x86_MM0, x86_MM7);
|
|
|
|
MmxXorRegToReg(x86_MM1, x86_MM7);
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM0, &m_Vect[m_OpCode.vd].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM1, &m_Vect[m_OpCode.vd].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsNextInstructionMmx(CompilePC))
|
2023-06-01 11:46:23 +00:00
|
|
|
MmxEmptyMultimediaState();
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
return true;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VNAND(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVnand
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VNAND, "&RSPOp::Vector_VNAND");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t el, del, count;
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bWriteToDest = WriteToVectorDest(m_OpCode.sa, CompilePC);
|
|
|
|
bool bElement = (m_OpCode.rs & 8) ? true : false;
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(Low16BitAccum, CompilePC);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bWriteToAccum)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
if (true == Compile_Vector_VNAND_MMX())
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bElement == true)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
del = (m_OpCode.rs & 0x07) ^ 7;
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
el = Indx[m_OpCode.e].B[count];
|
|
|
|
del = EleSpec[m_OpCode.e].B[el];
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
CPU_Message(" Iteration: %i", count);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rd, el);
|
|
|
|
MoveVariableToX86regHalf(&m_Vect[m_OpCode.vs].s16(el), Reg, x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bElement == false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
AndVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
AndX86RegHalfToX86RegHalf(x86_EAX, x86_EBX);
|
|
|
|
}
|
|
|
|
|
|
|
|
NotX86reg(x86_EAX);
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToDest != false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_Vect[m_OpCode.vd].s16(el), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum != false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_ACCUM[el].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
bool CRSPRecompilerOps::Compile_Vector_VOR_MMX(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Do our MMX checks here
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsMmxEnabled)
|
|
|
|
return false;
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.rs & 0x0f) >= 2 && !(m_OpCode.rs & 8) && IsMmx2Enabled == false)
|
2023-06-29 02:59:07 +00:00
|
|
|
return false;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM0, &m_Vect[m_OpCode.vs].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM1, &m_Vect[m_OpCode.vs].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.rs & 0xF) < 2 && (m_OpCode.rd == m_OpCode.rt))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if (m_OpCode.rs & 8)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
RSP_Element2Mmx(x86_MM2);
|
|
|
|
MmxPorRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPorRegToReg(x86_MM1, x86_MM2);
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if ((m_OpCode.rs & 0xF) < 2)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rt);
|
|
|
|
MmxPorVariableToReg(&m_Vect[m_OpCode.vt].s16(0), Reg, x86_MM0);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[4]", m_OpCode.rt);
|
|
|
|
MmxPorVariableToReg(&m_Vect[m_OpCode.vt].s16(4), Reg, x86_MM1);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RSP_MultiElement2Mmx(x86_MM2, x86_MM3);
|
|
|
|
MmxPorRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPorRegToReg(x86_MM1, x86_MM3);
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM0, &m_Vect[m_OpCode.vd].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM1, &m_Vect[m_OpCode.vd].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsNextInstructionMmx(CompilePC))
|
2023-06-01 11:46:23 +00:00
|
|
|
MmxEmptyMultimediaState();
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
return true;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VOR(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVor
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VOR, "RSPOp::Vector_VOR");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t el, del, count;
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bElement = (m_OpCode.rs & 8) ? true : false;
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(Low16BitAccum, CompilePC);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bWriteToAccum)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
if (true == Compile_Vector_VOR_MMX())
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bElement == true)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
del = (m_OpCode.rs & 0x07) ^ 7;
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
el = Indx[m_OpCode.e].B[count];
|
|
|
|
del = EleSpec[m_OpCode.e].B[el];
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
CPU_Message(" Iteration: %i", count);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rd, el);
|
|
|
|
MoveVariableToX86regHalf(&m_Vect[m_OpCode.vs].s16(el), Reg, x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bElement == false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
OrVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OrX86RegToX86Reg(x86_EAX, x86_EBX);
|
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum != false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_ACCUM[el].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_Vect[m_OpCode.vd].s16(el), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
bool CRSPRecompilerOps::Compile_Vector_VNOR_MMX(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Do our MMX checks here
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsMmxEnabled)
|
|
|
|
return false;
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.rs & 0x0f) >= 2 && !(m_OpCode.rs & 8) && IsMmx2Enabled == false)
|
2023-06-29 02:59:07 +00:00
|
|
|
return false;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM0, &m_Vect[m_OpCode.vs].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM1, &m_Vect[m_OpCode.vs].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
MmxPcmpeqwRegToReg(x86_MM7, x86_MM7);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rs & 8)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
RSP_Element2Mmx(x86_MM2);
|
|
|
|
MmxPorRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPorRegToReg(x86_MM1, x86_MM2);
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if ((m_OpCode.rs & 0xF) < 2)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rt);
|
|
|
|
MmxPorVariableToReg(&m_Vect[m_OpCode.vt].s16(0), Reg, x86_MM0);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[4]", m_OpCode.rt);
|
|
|
|
MmxPorVariableToReg(&m_Vect[m_OpCode.vt].s16(4), Reg, x86_MM1);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RSP_MultiElement2Mmx(x86_MM2, x86_MM3);
|
|
|
|
MmxPorRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxPorRegToReg(x86_MM1, x86_MM3);
|
|
|
|
}
|
|
|
|
|
|
|
|
MmxXorRegToReg(x86_MM0, x86_MM7);
|
|
|
|
MmxXorRegToReg(x86_MM1, x86_MM7);
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM0, &m_Vect[m_OpCode.vd].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM1, &m_Vect[m_OpCode.vd].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsNextInstructionMmx(CompilePC))
|
2023-06-01 11:46:23 +00:00
|
|
|
MmxEmptyMultimediaState();
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
return true;
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VNOR(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVnor
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VNOR, "&RSPOp::Vector_VNOR");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t el, del, count;
|
2024-08-08 03:25:54 +00:00
|
|
|
bool bElement = (m_OpCode.rs & 8) ? true : false;
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(Low16BitAccum, CompilePC);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!bWriteToAccum)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
if (true == Compile_Vector_VNOR_MMX())
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bElement == true)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
del = (m_OpCode.rs & 0x07) ^ 7;
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
MoveVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
el = Indx[m_OpCode.e].B[count];
|
|
|
|
del = EleSpec[m_OpCode.e].B[el];
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
CPU_Message(" Iteration: %i", count);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rd, el);
|
|
|
|
MoveVariableToX86regHalf(&m_Vect[m_OpCode.vs].s16(el), Reg, x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bElement == false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.rt, del);
|
|
|
|
OrVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(del), Reg, x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OrX86RegToX86Reg(x86_EAX, x86_EBX);
|
|
|
|
}
|
|
|
|
|
|
|
|
NotX86reg(x86_EAX);
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum != false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_ACCUM[el].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_Vect[m_OpCode.vd].s16(el), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
bool CRSPRecompilerOps::Compile_Vector_VXOR_MMX(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Do our MMX checks here
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsMmxEnabled)
|
|
|
|
return false;
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.rs & 0x0f) >= 2 && !(m_OpCode.rs & 8) && IsMmx2Enabled == false)
|
2023-06-29 02:59:07 +00:00
|
|
|
return false;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.rs & 0xF) < 2 && (m_OpCode.rd == m_OpCode.rt))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-08-10 04:46:57 +00:00
|
|
|
static uint32_t VXOR_DynaRegCount = 0;
|
2023-06-01 11:46:23 +00:00
|
|
|
MmxXorRegToReg(VXOR_DynaRegCount, VXOR_DynaRegCount);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(VXOR_DynaRegCount, &m_Vect[m_OpCode.vd].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(VXOR_DynaRegCount, &m_Vect[m_OpCode.vd].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
VXOR_DynaRegCount = (VXOR_DynaRegCount + 1) & 7;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM0, &m_Vect[m_OpCode.vs].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM1, &m_Vect[m_OpCode.vs].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rs & 8)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
RSP_Element2Mmx(x86_MM2);
|
|
|
|
MmxXorRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxXorRegToReg(x86_MM1, x86_MM2);
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if ((m_OpCode.rs & 0xF) < 2)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rt);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM2, &m_Vect[m_OpCode.vt].s16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[4]", m_OpCode.rt);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM3, &m_Vect[m_OpCode.vt].s16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
MmxXorRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxXorRegToReg(x86_MM1, x86_MM3);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RSP_MultiElement2Mmx(x86_MM2, x86_MM3);
|
|
|
|
MmxXorRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxXorRegToReg(x86_MM1, x86_MM3);
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM0, &m_Vect[m_OpCode.vd].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM1, &m_Vect[m_OpCode.vd].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsNextInstructionMmx(CompilePC))
|
2023-06-01 11:46:23 +00:00
|
|
|
MmxEmptyMultimediaState();
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
return true;
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VXOR(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
|
|
|
#ifdef CompileVxor
|
|
|
|
char Reg[256];
|
2023-08-10 04:46:57 +00:00
|
|
|
uint32_t count;
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(Low16BitAccum, CompilePC);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (!bWriteToAccum || ((m_OpCode.rs & 0xF) < 2 && m_OpCode.rd == m_OpCode.rt))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
if (true == Compile_Vector_VXOR_MMX())
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
XorX86RegToX86Reg(x86_EAX, x86_EAX);
|
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", count);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_ACCUM[count].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::Vector_VXOR, "RSPOp::Vector_VXOR");
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
bool CRSPRecompilerOps::Compile_Vector_VNXOR_MMX(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Do our MMX checks here
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsMmxEnabled)
|
|
|
|
return false;
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.rs & 0x0f) >= 2 && !(m_OpCode.rs & 8) && IsMmx2Enabled == false)
|
2023-06-29 02:59:07 +00:00
|
|
|
return false;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.rs & 0xF) < 2 && (m_OpCode.rd == m_OpCode.rt))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-08-10 04:46:57 +00:00
|
|
|
static uint32_t VNXOR_DynaRegCount = 0;
|
2023-06-01 11:46:23 +00:00
|
|
|
MmxPcmpeqwRegToReg(VNXOR_DynaRegCount, VNXOR_DynaRegCount);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(VNXOR_DynaRegCount, &m_Vect[m_OpCode.vd].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(VNXOR_DynaRegCount, &m_Vect[m_OpCode.vd].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
VNXOR_DynaRegCount = (VNXOR_DynaRegCount + 1) & 7;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM0, &m_Vect[m_OpCode.vs].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.rd);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM1, &m_Vect[m_OpCode.vs].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
MmxPcmpeqwRegToReg(x86_MM7, x86_MM7);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.rs & 8)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
RSP_Element2Mmx(x86_MM2);
|
|
|
|
MmxXorRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxXorRegToReg(x86_MM1, x86_MM2);
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
else if ((m_OpCode.rs & 0xF) < 2)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rt);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM2, &m_Vect[m_OpCode.vt].s16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[4]", m_OpCode.rt);
|
|
|
|
MmxMoveQwordVariableToReg(x86_MM3, &m_Vect[m_OpCode.vt].s16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
MmxXorRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxXorRegToReg(x86_MM1, x86_MM3);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RSP_MultiElement2Mmx(x86_MM2, x86_MM3);
|
|
|
|
MmxXorRegToReg(x86_MM0, x86_MM2);
|
|
|
|
MmxXorRegToReg(x86_MM1, x86_MM3);
|
|
|
|
}
|
|
|
|
|
|
|
|
MmxXorRegToReg(x86_MM0, x86_MM7);
|
|
|
|
MmxXorRegToReg(x86_MM1, x86_MM7);
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[0]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM0, &m_Vect[m_OpCode.vd].u16(0), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[4]", m_OpCode.sa);
|
|
|
|
MmxMoveQwordRegToVariable(x86_MM1, &m_Vect[m_OpCode.vd].u16(4), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (!IsNextInstructionMmx(CompilePC))
|
2023-06-01 11:46:23 +00:00
|
|
|
MmxEmptyMultimediaState();
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
return true;
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VNXOR(void)
|
2016-02-14 18:49:47 +00:00
|
|
|
{
|
|
|
|
#ifdef CompileVnxor
|
|
|
|
char Reg[256];
|
2023-08-10 04:46:57 +00:00
|
|
|
uint32_t count;
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(Low16BitAccum, CompilePC);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (!bWriteToAccum || ((m_OpCode.rs & 0xF) < 2 && m_OpCode.rd == m_OpCode.rt))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
if (true == Compile_Vector_VNXOR_MMX())
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
OrConstToX86Reg(0xFFFFFFFF, x86_EAX);
|
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", count);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_ACCUM[count].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VNXOR, "RSPOp::Vector_VNXOR");
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VRCP(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVrcp
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VRCP, "&RSPOp::Vector_VRCP");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t count, el, last;
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(Low16BitAccum, CompilePC);
|
2023-08-10 04:46:57 +00:00
|
|
|
uint32_t * end = NULL;
|
2016-02-14 18:49:47 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
el = EleSpec[m_OpCode.e].B[(m_OpCode.rd & 0x7)];
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[%i]", m_OpCode.rt, el);
|
|
|
|
MoveSxVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(el), Reg, x86_ESI);
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveConstToX86reg(0x7FFFFFFF, x86_EAX);
|
|
|
|
TestX86RegToX86Reg(x86_ESI, x86_ESI);
|
|
|
|
MoveX86RegToX86Reg(x86_ESI, x86_EDI);
|
|
|
|
JeLabel32("Done", 0);
|
2023-08-10 04:46:57 +00:00
|
|
|
end = (uint32_t *)(RecompPos - 4);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
MoveConstToX86reg(0xFFC0, x86_EBX);
|
|
|
|
ShiftRightSignImmed(x86_ESI, 31);
|
|
|
|
XorX86RegToX86Reg(x86_EDX, x86_EDX);
|
|
|
|
XorX86RegToX86Reg(x86_EDI, x86_ESI);
|
|
|
|
SubX86RegToX86Reg(x86_EDI, x86_ESI);
|
|
|
|
|
|
|
|
BsrX86RegToX86Reg(x86_ECX, x86_EDI);
|
|
|
|
XorConstToX86Reg(x86_ECX, 15);
|
|
|
|
ShiftRightUnsign(x86_EBX);
|
|
|
|
AndX86RegToX86Reg(x86_EDI, x86_EBX);
|
|
|
|
|
|
|
|
idivX86reg(x86_EDI);
|
|
|
|
|
|
|
|
MoveConstToX86reg(0xFFFF8000, x86_EBX);
|
|
|
|
BsrX86RegToX86Reg(x86_ECX, x86_EAX);
|
|
|
|
XorConstToX86Reg(x86_ECX, 31);
|
|
|
|
ShiftRightUnsign(x86_EBX);
|
|
|
|
AndX86RegToX86Reg(x86_EAX, x86_EBX);
|
|
|
|
XorX86RegToX86Reg(x86_EAX, x86_ESI);
|
|
|
|
|
|
|
|
x86_SetBranch32b(end, RecompPos);
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum != false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-07-13 11:39:18 +00:00
|
|
|
last = (uint8_t)-1;
|
2023-06-01 11:46:23 +00:00
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
el = EleSpec[m_OpCode.e].B[count];
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
if (el != last)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[%i]", m_OpCode.rt, el);
|
|
|
|
MoveVariableToX86regHalf(&m_Vect[m_OpCode.vt].u16(el), Reg, x86_ECX);
|
2023-06-01 11:46:23 +00:00
|
|
|
last = el;
|
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", count);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_ACCUM[count].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
el = 7 - (m_OpCode.rd & 0x7);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_Vect[m_OpCode.vd].s16(el), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &RecpResult.W, "RecpResult.W");
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VRCPL(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVrcpl
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VRCPL, "RSPOp::Vector_VRCPL");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t count, el, last;
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(Low16BitAccum, CompilePC);
|
2023-08-10 04:46:57 +00:00
|
|
|
uint32_t * end = NULL;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
el = EleSpec[m_OpCode.e].B[(m_OpCode.rd & 0x7)];
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[%i]", m_OpCode.rt, el);
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveVariableToX86reg(&Recp.W, "Recp.W", x86_ESI);
|
2024-08-08 03:25:54 +00:00
|
|
|
OrVariableToX86regHalf(&m_Vect[m_OpCode.vt].s16(el), Reg, x86_ESI);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
MoveConstToX86reg(0x7FFFFFFF, x86_EAX);
|
|
|
|
TestX86RegToX86Reg(x86_ESI, x86_ESI);
|
|
|
|
MoveX86RegToX86Reg(x86_ESI, x86_EDI);
|
|
|
|
JeLabel32("Done", 0);
|
2023-08-10 04:46:57 +00:00
|
|
|
end = (uint32_t *)(RecompPos - 4);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
MoveConstToX86reg(0xFFC00000, x86_EBX);
|
|
|
|
ShiftRightSignImmed(x86_ESI, 31);
|
|
|
|
MoveX86RegToX86Reg(x86_EDI, x86_ECX);
|
|
|
|
MoveZxX86RegHalfToX86Reg(x86_EDI, x86_EDX);
|
|
|
|
OrConstToX86Reg(0xFFFF, x86_ECX);
|
|
|
|
ShiftRightUnsignImmed(x86_EDX, 15);
|
|
|
|
|
|
|
|
XorX86RegToX86Reg(x86_EDI, x86_ESI);
|
|
|
|
AddX86RegToX86Reg(x86_ECX, x86_EDX);
|
|
|
|
AdcConstToX86reg(0, x86_EDI);
|
|
|
|
XorX86RegToX86Reg(x86_EDX, x86_EDX);
|
|
|
|
|
|
|
|
BsrX86RegToX86Reg(x86_ECX, x86_EDI);
|
|
|
|
XorConstToX86Reg(x86_ECX, 31);
|
|
|
|
ShiftRightUnsign(x86_EBX);
|
|
|
|
AndX86RegToX86Reg(x86_EDI, x86_EBX);
|
|
|
|
|
|
|
|
idivX86reg(x86_EDI);
|
|
|
|
MoveConstToX86reg(0xFFFF8000, x86_EBX);
|
|
|
|
BsrX86RegToX86Reg(x86_ECX, x86_EAX);
|
|
|
|
XorConstToX86Reg(x86_ECX, 31);
|
|
|
|
ShiftRightUnsign(x86_EBX);
|
|
|
|
AndX86RegToX86Reg(x86_EAX, x86_EBX);
|
|
|
|
XorX86RegToX86Reg(x86_EAX, x86_ESI);
|
|
|
|
|
|
|
|
x86_SetBranch32b(end, RecompPos);
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum != false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-07-13 11:39:18 +00:00
|
|
|
last = (uint8_t)-1;
|
2023-06-01 11:46:23 +00:00
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
el = EleSpec[m_OpCode.e].B[count];
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
if (el != last)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[%i]", m_OpCode.rt, el);
|
|
|
|
MoveVariableToX86regHalf(&m_Vect[m_OpCode.vt].u16(el), Reg, x86_ECX);
|
2023-06-01 11:46:23 +00:00
|
|
|
last = el;
|
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", count);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_ACCUM[count].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
el = 7 - (m_OpCode.rd & 0x7);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_Vect[m_OpCode.vd].s16(el), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86regToVariable(x86_EAX, &RecpResult.W, "RecpResult.W");
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VRCPH(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVrcph
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VRCPH, "&RSPOp::Vector_VRCPH");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t count, el, last;
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(Low16BitAccum, CompilePC);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
el = EleSpec[m_OpCode.e].B[(m_OpCode.rd & 0x7)];
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[%i]", m_OpCode.rt, el);
|
|
|
|
MoveVariableToX86regHalf(&m_Vect[m_OpCode.vt].u16(el), Reg, x86_EDX);
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86regHalfToVariable(x86_EDX, &Recp.UHW[1], "Recp.UHW[1]");
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveVariableToX86regHalf(&RecpResult.UHW[1], "RecpResult.UHW[1]", x86_ECX);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum != false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-07-13 11:39:18 +00:00
|
|
|
last = (uint8_t)-1;
|
2023-06-01 11:46:23 +00:00
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
el = EleSpec[m_OpCode.e].B[count];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
if (el != last)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[%i]", m_OpCode.rt, el);
|
|
|
|
MoveVariableToX86regHalf(&m_Vect[m_OpCode.vt].u16(el), Reg, x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
last = el;
|
|
|
|
}
|
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", count);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_ACCUM[count].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
el = 7 - (m_OpCode.rd & 0x7);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_Vect[m_OpCode.vd].u16(el), Reg);
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VMOV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVmov
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VMOV, "&RSPOp::Vector_VMOV");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t el, count;
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(Low16BitAccum, CompilePC);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
if (bWriteToAccum)
|
|
|
|
{
|
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[%i]", m_OpCode.rt, EleSpec[m_OpCode.e].B[count]);
|
|
|
|
MoveVariableToX86regHalf(&m_Vect[m_OpCode.vt].u16(EleSpec[m_OpCode.e].B[count]), Reg, x86_EAX);
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", count);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_ACCUM[count].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
el = EleSpec[m_OpCode.e].B[(m_OpCode.rd & 0x7)];
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[%i]", m_OpCode.rt, el);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86regHalf(&m_Vect[m_OpCode.vt].u16(el), Reg, x86_ECX);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
el = 7 - (m_OpCode.rd & 0x7);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[%i]", m_OpCode.sa, el);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_Vect[m_OpCode.vd].u16(el), Reg);
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VRSQ(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::Vector_VRSQ, "RSPOp::Vector_VRSQ");
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VRSQL(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::Vector_VRSQL, "RSPOp::Vector_VRSQL");
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VRSQH(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileVrsqh
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_VRSQH, "RSPOp::Vector_VRSQH");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2023-07-13 11:39:18 +00:00
|
|
|
uint8_t count, el, last;
|
2023-06-29 02:59:07 +00:00
|
|
|
bool bWriteToAccum = WriteToAccum(Low16BitAccum, CompilePC);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
el = EleSpec[m_OpCode.e].B[(m_OpCode.rd & 0x7)];
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[%i]", m_OpCode.rt, el);
|
|
|
|
MoveVariableToX86regHalf(&m_Vect[m_OpCode.vt].u16(el), Reg, x86_EDX);
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86regHalfToVariable(x86_EDX, &SQroot.UHW[1], "SQroot.UHW[1]");
|
|
|
|
|
|
|
|
MoveVariableToX86regHalf(&SQrootResult.UHW[1], "SQrootResult.UHW[1]", x86_ECX);
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (bWriteToAccum != false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2023-07-13 11:39:18 +00:00
|
|
|
last = (uint8_t)-1;
|
2023-06-01 11:46:23 +00:00
|
|
|
for (count = 0; count < 8; count++)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
el = EleSpec[m_OpCode.e].B[count];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
if (el != last)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[%i]", m_OpCode.rt, el);
|
|
|
|
MoveVariableToX86regHalf(&m_Vect[m_OpCode.vt].u16(el), Reg, x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
last = el;
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-07 21:56:15 +00:00
|
|
|
sprintf(Reg, "m_ACCUM[%i].HW[1]", count);
|
|
|
|
MoveX86regHalfToVariable(x86_EAX, &m_ACCUM[count].HW[1], Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
el = 7 - (m_OpCode.rd & 0x7);
|
|
|
|
sprintf(Reg, "m_Vect[%i].UHW[%i]", m_OpCode.sa, el);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_Vect[m_OpCode.vd].u16(el), Reg);
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_VNOOP(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Vector_Reserved(void)
|
2024-06-20 08:04:37 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::Vector_Reserved, "&RSPOp::Vector_Reserved");
|
2024-06-20 08:04:37 +00:00
|
|
|
}
|
|
|
|
|
2021-03-19 07:13:35 +00:00
|
|
|
// LC2 functions
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Opcode_LBV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
#ifndef CompileLbv
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::LBV, "RSPOp::LBV");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
|
|
|
char Reg[256];
|
2024-08-08 03:25:54 +00:00
|
|
|
int offset = m_OpCode.voffset << 0;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.base].UW, GPR_Name(m_OpCode.base), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
if (offset != 0)
|
|
|
|
AddConstToX86Reg(x86_EBX, offset);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
AndConstToX86Reg(x86_EBX, 0x0FFF);
|
|
|
|
XorConstToX86Reg(x86_EBX, 3);
|
|
|
|
MoveN64MemToX86regByte(x86_ECX, x86_EBX);
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, 15 - m_OpCode.del);
|
|
|
|
MoveX86regByteToVariable(x86_ECX, &m_Vect[m_OpCode.vt].s8((uint8_t)(15 - m_OpCode.del)), Reg);
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Opcode_LSV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
#ifndef CompileLsv
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::LSV, "RSPOp::LSV");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.del > 14)
|
2024-07-20 07:39:41 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::LSV, "RSPOp::LSV");
|
2024-07-20 07:39:41 +00:00
|
|
|
return;
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-07-06 09:34:50 +00:00
|
|
|
char Reg[256];
|
2024-08-08 03:25:54 +00:00
|
|
|
int offset = (m_OpCode.voffset << 1);
|
|
|
|
if (IsRegConst(m_OpCode.base))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Addr = (MipsRegConst(m_OpCode.base) + offset) & 0xfff;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
if ((Addr & 1) != 0)
|
|
|
|
{
|
|
|
|
sprintf(Reg, "DMEM + %Xh", (Addr + 0) ^ 3);
|
|
|
|
MoveVariableToX86regByte(RSPInfo.DMEM + ((Addr + 0) ^ 3), Reg, x86_ECX);
|
|
|
|
sprintf(Reg, "DMEM + %Xh", (Addr + 1) ^ 3);
|
|
|
|
MoveVariableToX86regByte(RSPInfo.DMEM + ((Addr + 1) ^ 3), Reg, x86_EDX);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, 15 - (m_OpCode.del + 0));
|
|
|
|
MoveX86regByteToVariable(x86_ECX, &m_Vect[m_OpCode.vt].s8((uint8_t)(15 - (m_OpCode.del + 0))), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, 15 - (m_OpCode.del + 1));
|
|
|
|
MoveX86regByteToVariable(x86_EDX, &m_Vect[m_OpCode.vt].s8((uint8_t)(15 - (m_OpCode.del + 1))), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprintf(Reg, "DMEM + %Xh", Addr ^ 2);
|
|
|
|
MoveVariableToX86regHalf(RSPInfo.DMEM + (Addr ^ 2), Reg, x86_EDX);
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, 15 - (m_OpCode.del + 1));
|
|
|
|
MoveX86regHalfToVariable(x86_EDX, &m_Vect[m_OpCode.vt].s8((uint8_t)(15 - (m_OpCode.del + 1))), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.base].UW, GPR_Name(m_OpCode.base), x86_EBX);
|
2024-07-20 07:39:41 +00:00
|
|
|
if (offset != 0)
|
|
|
|
{
|
|
|
|
AddConstToX86Reg(x86_EBX, offset);
|
|
|
|
}
|
2023-06-01 11:46:23 +00:00
|
|
|
AndConstToX86Reg(x86_EBX, 0x0FFF);
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (Compiler.bAlignVector == true)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
XorConstToX86Reg(x86_EBX, 2);
|
|
|
|
MoveN64MemToX86regHalf(x86_ECX, x86_EBX);
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, 15 - (m_OpCode.del + 1));
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_Vect[m_OpCode.vt].s8((uint8_t)(15 - (m_OpCode.del + 1))), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LeaSourceAndOffset(x86_EAX, x86_EBX, 1);
|
2024-07-20 07:39:41 +00:00
|
|
|
AndConstToX86Reg(x86_EAX, 0x0FFF);
|
2023-06-01 11:46:23 +00:00
|
|
|
XorConstToX86Reg(x86_EBX, 3);
|
|
|
|
XorConstToX86Reg(x86_EAX, 3);
|
|
|
|
|
|
|
|
MoveN64MemToX86regByte(x86_ECX, x86_EBX);
|
|
|
|
MoveN64MemToX86regByte(x86_EDX, x86_EAX);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, 15 - (m_OpCode.del + 0));
|
|
|
|
MoveX86regByteToVariable(x86_ECX, &m_Vect[m_OpCode.vt].s8((uint8_t)(15 - (m_OpCode.del + 0))), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, 15 - (m_OpCode.del + 1));
|
|
|
|
MoveX86regByteToVariable(x86_EDX, &m_Vect[m_OpCode.vt].s8((uint8_t)(15 - (m_OpCode.del + 1))), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Opcode_LLV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileLlv
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::LLV, "RSPOp::LLV");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2024-08-08 03:25:54 +00:00
|
|
|
int offset = (m_OpCode.voffset << 2);
|
2023-08-16 23:29:22 +00:00
|
|
|
uint8_t * Jump[2];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.del & 0x3) != 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::LLV, "RSPOp::LLV");
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (IsRegConst(m_OpCode.base))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Addr = (MipsRegConst(m_OpCode.base) + offset) & 0xfff;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
if ((Addr & 3) != 0)
|
|
|
|
{
|
|
|
|
CompilerWarning("Unaligned LLV at constant address");
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::LLV, "RSPOp::LLV");
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
sprintf(Reg, "DMEM + %Xh", Addr);
|
|
|
|
MoveVariableToX86reg(RSPInfo.DMEM + Addr, Reg, x86_EAX);
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, 16 - m_OpCode.del - 4);
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_Vect[m_OpCode.vt].s8((uint8_t)(16 - m_OpCode.del - 4)), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.base].UW, GPR_Name(m_OpCode.base), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
if (offset != 0) AddConstToX86Reg(x86_EBX, offset);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
TestConstToX86Reg(3, x86_EBX);
|
|
|
|
JneLabel32("Unaligned", 0);
|
|
|
|
Jump[0] = RecompPos - 4;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Unaligned
|
|
|
|
|
|
|
|
CompilerToggleBuffer();
|
|
|
|
|
|
|
|
CPU_Message(" Unaligned:");
|
2023-08-10 04:46:57 +00:00
|
|
|
*((uint32_t *)(Jump[0])) = (uint32_t)(RecompPos - Jump[0] - 4);
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::LLV, "RSPOp::LLV");
|
2023-06-01 11:46:23 +00:00
|
|
|
JmpLabel32("Done", 0);
|
|
|
|
Jump[1] = RecompPos - 4;
|
|
|
|
|
|
|
|
CompilerToggleBuffer();
|
|
|
|
|
|
|
|
// Aligned
|
|
|
|
|
|
|
|
AndConstToX86Reg(x86_EBX, 0x0fff);
|
|
|
|
MoveN64MemToX86reg(x86_EAX, x86_EBX);
|
|
|
|
// Because of byte swapping this swizzle works nicely
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, 16 - m_OpCode.del - 4);
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_Vect[m_OpCode.vt].s8((uint8_t)(16 - m_OpCode.del - 4)), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
CPU_Message(" Done:");
|
2023-08-10 04:46:57 +00:00
|
|
|
*((uint32_t *)(Jump[1])) = (uint32_t)(RecompPos - Jump[1] - 4);
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Opcode_LDV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileLdv
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::LDV, "RSPOp::LDV");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2024-08-08 03:25:54 +00:00
|
|
|
int offset = (m_OpCode.voffset << 3);
|
|
|
|
uint8_t * Jump[2];
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
//if ((m_OpCode.del & 0x7) != 0) {
|
2023-06-01 11:46:23 +00:00
|
|
|
// rsp_UnknownOpcode();
|
|
|
|
// return;
|
|
|
|
//}
|
2024-08-08 03:25:54 +00:00
|
|
|
if ((m_OpCode.del & 0x3) != 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CompilerWarning(stdstr_f("LDV's element = %X, PC = %04X", m_OpCode.del, CompilePC).c_str());
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::LDV, "RSPOp::LDV");
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (IsRegConst(m_OpCode.base))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Addr = (MipsRegConst(m_OpCode.base) + offset) & 0xfff;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
if ((Addr & 3) != 0)
|
|
|
|
{
|
2023-08-16 23:29:22 +00:00
|
|
|
CompilerWarning(stdstr_f("Unaligned LDV at constant address PC = %04X", CompilePC).c_str());
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::LDV, "RSPOp::LDV");
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(Reg, "DMEM + %Xh", Addr);
|
|
|
|
MoveVariableToX86reg(RSPInfo.DMEM + Addr + 0, Reg, x86_EAX);
|
2024-07-20 09:40:36 +00:00
|
|
|
sprintf(Reg, "DMEM + %Xh", ((Addr + 4) & 0xFFF));
|
|
|
|
MoveVariableToX86reg(RSPInfo.DMEM + ((Addr + 4) & 0xFFF), Reg, x86_ECX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, 16 - m_OpCode.del - 4);
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_Vect[m_OpCode.vt].s8((uint8_t)(16 - m_OpCode.del - 4)), Reg);
|
|
|
|
if (m_OpCode.del != 12)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, 16 - m_OpCode.del - 8);
|
|
|
|
MoveX86regToVariable(x86_ECX, &m_Vect[m_OpCode.vt].s8((uint8_t)(16 - m_OpCode.del - 8)), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.base].UW, GPR_Name(m_OpCode.base), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
if (offset != 0)
|
|
|
|
{
|
|
|
|
AddConstToX86Reg(x86_EBX, offset);
|
|
|
|
}
|
|
|
|
AndConstToX86Reg(x86_EBX, 0x0fff);
|
2024-07-20 09:40:36 +00:00
|
|
|
TestConstToX86Reg(7, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
JneLabel32("Unaligned", 0);
|
|
|
|
Jump[0] = RecompPos - 4;
|
|
|
|
|
|
|
|
CompilerToggleBuffer();
|
|
|
|
CPU_Message(" Unaligned:");
|
|
|
|
x86_SetBranch32b(Jump[0], RecompPos);
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::LDV, "RSPOp::LDV");
|
2023-06-01 11:46:23 +00:00
|
|
|
JmpLabel32("Done", 0);
|
|
|
|
Jump[1] = RecompPos - 4;
|
|
|
|
CompilerToggleBuffer();
|
|
|
|
|
|
|
|
MoveN64MemToX86reg(x86_EAX, x86_EBX);
|
|
|
|
MoveN64MemDispToX86reg(x86_ECX, x86_EBX, 4);
|
|
|
|
|
|
|
|
// Because of byte swapping this swizzle works nicely
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, 16 - m_OpCode.del - 4);
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_Vect[m_OpCode.vt].s8((uint8_t)(16 - m_OpCode.del - 4)), Reg);
|
|
|
|
if (m_OpCode.del != 12)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, 16 - m_OpCode.del - 8);
|
|
|
|
MoveX86regToVariable(x86_ECX, &m_Vect[m_OpCode.vt].s8((uint8_t)(16 - m_OpCode.del - 8)), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
CPU_Message(" Done:");
|
|
|
|
x86_SetBranch32b(Jump[1], RecompPos);
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Opcode_LQV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileLqv
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::LQV, "RSPOp::LQV");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2024-08-08 03:25:54 +00:00
|
|
|
int offset = (m_OpCode.voffset << 4);
|
2023-08-16 23:29:22 +00:00
|
|
|
uint8_t * Jump[2];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.del != 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::LQV, "RSPOp::LQV");
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (IsRegConst(m_OpCode.base))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Addr = (MipsRegConst(m_OpCode.base) + offset) & 0xfff;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
if (Addr & 15)
|
|
|
|
{
|
2023-08-16 23:29:22 +00:00
|
|
|
CompilerWarning(stdstr_f("Unaligned LQV at constant address PC = %04X", CompilePC).c_str());
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::LQV, "RSPOp::LQV");
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Aligned store
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (IsSseEnabled == false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
sprintf(Reg, "DMEM+%Xh+0", Addr);
|
|
|
|
MoveVariableToX86reg(RSPInfo.DMEM + Addr + 0, Reg, x86_EAX);
|
|
|
|
sprintf(Reg, "DMEM+%Xh+4", Addr);
|
|
|
|
MoveVariableToX86reg(RSPInfo.DMEM + Addr + 4, Reg, x86_EBX);
|
|
|
|
sprintf(Reg, "DMEM+%Xh+8", Addr);
|
|
|
|
MoveVariableToX86reg(RSPInfo.DMEM + Addr + 8, Reg, x86_ECX);
|
|
|
|
sprintf(Reg, "DMEM+%Xh+C", Addr);
|
|
|
|
MoveVariableToX86reg(RSPInfo.DMEM + Addr + 12, Reg, x86_EDX);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[12]", m_OpCode.rt);
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_Vect[m_OpCode.vt].s8(12), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].B[8]", m_OpCode.rt);
|
|
|
|
MoveX86regToVariable(x86_EBX, &m_Vect[m_OpCode.vt].s8(8), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].B[4]", m_OpCode.rt);
|
|
|
|
MoveX86regToVariable(x86_ECX, &m_Vect[m_OpCode.vt].s8(4), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].B[0]", m_OpCode.rt);
|
|
|
|
MoveX86regToVariable(x86_EDX, &m_Vect[m_OpCode.vt].s8(0), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprintf(Reg, "DMEM+%Xh", Addr);
|
|
|
|
SseMoveUnalignedVariableToReg(RSPInfo.DMEM + Addr, Reg, x86_XMM0);
|
|
|
|
SseShuffleReg(x86_XMM0, x86_MM0, 0x1b);
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[0]", m_OpCode.rt);
|
|
|
|
SseMoveAlignedRegToVariable(x86_XMM0, &m_Vect[m_OpCode.vt].s8(0), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.base].UW, GPR_Name(m_OpCode.base), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
if (offset != 0)
|
|
|
|
{
|
|
|
|
AddConstToX86Reg(x86_EBX, offset);
|
|
|
|
}
|
|
|
|
TestConstToX86Reg(15, x86_EBX);
|
|
|
|
JneLabel32("Unaligned", 0);
|
|
|
|
Jump[0] = RecompPos - 4;
|
|
|
|
|
|
|
|
CompilerToggleBuffer();
|
|
|
|
CPU_Message(" Unaligned:");
|
|
|
|
x86_SetBranch32b(Jump[0], RecompPos);
|
|
|
|
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::LQV, "RSPOp::LQV");
|
2023-06-01 11:46:23 +00:00
|
|
|
JmpLabel32("Done", 0);
|
|
|
|
Jump[1] = RecompPos - 4;
|
|
|
|
CompilerToggleBuffer();
|
|
|
|
|
|
|
|
AndConstToX86Reg(x86_EBX, 0x0fff);
|
2023-06-29 02:59:07 +00:00
|
|
|
if (IsSseEnabled == false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
MoveN64MemDispToX86reg(x86_EAX, x86_EBX, 0);
|
|
|
|
MoveN64MemDispToX86reg(x86_ECX, x86_EBX, 4);
|
|
|
|
MoveN64MemDispToX86reg(x86_EDX, x86_EBX, 8);
|
|
|
|
MoveN64MemDispToX86reg(x86_EDI, x86_EBX, 12);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[12]", m_OpCode.rt);
|
|
|
|
MoveX86regToVariable(x86_EAX, &m_Vect[m_OpCode.vt].s8(12), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].B[8]", m_OpCode.rt);
|
|
|
|
MoveX86regToVariable(x86_ECX, &m_Vect[m_OpCode.vt].s8(8), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].B[4]", m_OpCode.rt);
|
|
|
|
MoveX86regToVariable(x86_EDX, &m_Vect[m_OpCode.vt].s8(4), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].B[0]", m_OpCode.rt);
|
|
|
|
MoveX86regToVariable(x86_EDI, &m_Vect[m_OpCode.vt].s8(0), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SseMoveUnalignedN64MemToReg(x86_XMM0, x86_EBX);
|
|
|
|
SseShuffleReg(x86_XMM0, x86_MM0, 0x1b);
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[0]", m_OpCode.rt);
|
|
|
|
SseMoveAlignedRegToVariable(x86_XMM0, &m_Vect[m_OpCode.vt].s8(0), Reg);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
CPU_Message(" Done:");
|
2023-08-10 04:46:57 +00:00
|
|
|
x86_SetBranch32b((uint32_t *)Jump[1], (uint32_t *)RecompPos);
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Opcode_LRV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
#ifndef CompileLrv
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::LRV, "RSPOp::LRV");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
int offset = (m_OpCode.voffset << 4);
|
2024-07-06 09:34:50 +00:00
|
|
|
uint8_t *Loop, *Jump[2];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.del != 0)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::LRV, "RSPOp::LRV");
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.base].UW, GPR_Name(m_OpCode.base), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
if (offset != 0) AddConstToX86Reg(x86_EBX, offset);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (Compiler.bAlignVector == false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
TestConstToX86Reg(1, x86_EBX);
|
|
|
|
JneLabel32("Unaligned", 0);
|
|
|
|
Jump[0] = RecompPos - 4;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Unaligned
|
|
|
|
CompilerToggleBuffer();
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
CPU_Message(" Unaligned:");
|
|
|
|
x86_SetBranch32b(Jump[0], RecompPos);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::LRV, "RSPOp::LRV");
|
2023-06-01 11:46:23 +00:00
|
|
|
JmpLabel32("Done", 0);
|
|
|
|
Jump[1] = RecompPos - 4;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
CompilerToggleBuffer();
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Aligned
|
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_EAX);
|
|
|
|
AndConstToX86Reg(x86_EAX, 0x0F);
|
|
|
|
AndConstToX86Reg(x86_EBX, 0x0ff0);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86RegToX86Reg(x86_EAX, x86_ECX);
|
|
|
|
ShiftRightUnsignImmed(x86_ECX, 1);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
JeLabel8("Done", 0);
|
|
|
|
Jump[0] = RecompPos - 1;
|
|
|
|
/*
|
2016-01-27 09:39:06 +00:00
|
|
|
DecX86reg(x86_EAX);
|
2024-08-08 03:25:54 +00:00
|
|
|
LeaSourceAndOffset(x86_EAX, x86_EAX, (size_t)&m_Vect[m_OpCode.vt].s8(0));
|
2016-01-27 09:39:06 +00:00
|
|
|
DecX86reg(x86_EAX);
|
|
|
|
*/
|
2024-08-08 03:25:54 +00:00
|
|
|
AddConstToX86Reg(x86_EAX, ((size_t)&m_Vect[m_OpCode.vt].u8(0)) - 2);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
CPU_Message(" Loop:");
|
|
|
|
Loop = RecompPos;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_ESI);
|
|
|
|
XorConstToX86Reg(x86_ESI, 2);
|
|
|
|
MoveN64MemToX86regHalf(x86_EDX, x86_ESI);
|
|
|
|
MoveX86regHalfToX86regPointer(x86_EDX, x86_EAX);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
AddConstToX86Reg(x86_EBX, 2); // DMEM pointer
|
|
|
|
SubConstFromX86Reg(x86_EAX, 2); // Vector pointer
|
|
|
|
DecX86reg(x86_ECX); // Loop counter
|
|
|
|
JneLabel8("Loop", 0);
|
|
|
|
x86_SetBranch8b(RecompPos - 1, Loop);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (Compiler.bAlignVector == false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
CPU_Message(" Done:");
|
2023-08-10 04:46:57 +00:00
|
|
|
x86_SetBranch32b((uint32_t *)Jump[1], (uint32_t *)RecompPos);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
x86_SetBranch8b(Jump[0], RecompPos);
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Opcode_LPV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
#ifndef CompileLpv
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::LPV, "RSPOp::LPV");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
|
|
|
char Reg[256];
|
2024-08-08 03:25:54 +00:00
|
|
|
int offset = (m_OpCode.voffset << 3);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.base].UW, GPR_Name(m_OpCode.base), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
if (offset != 0)
|
|
|
|
{
|
|
|
|
AddConstToX86Reg(x86_EBX, offset);
|
|
|
|
}
|
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_ESI);
|
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_EDI);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
AddConstToX86Reg(x86_ESI, (0x10 - m_OpCode.del + 0) & 0xF);
|
|
|
|
AddConstToX86Reg(x86_EDI, (0x10 - m_OpCode.del + 1) & 0xF);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
XorConstToX86Reg(x86_ESI, 3);
|
|
|
|
XorConstToX86Reg(x86_EDI, 3);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
AndConstToX86Reg(x86_ESI, 0x0fff);
|
|
|
|
AndConstToX86Reg(x86_EDI, 0x0fff);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveZxN64MemToX86regByte(x86_ECX, x86_ESI);
|
|
|
|
MoveZxN64MemToX86regByte(x86_EDX, x86_EDI);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
ShiftLeftSignImmed(x86_ECX, 8);
|
|
|
|
ShiftLeftSignImmed(x86_EDX, 8);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[7]", m_OpCode.rt);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_Vect[m_OpCode.vt].s16(7), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[6]", m_OpCode.rt);
|
|
|
|
MoveX86regHalfToVariable(x86_EDX, &m_Vect[m_OpCode.vt].s16(6), Reg);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_ESI);
|
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_EDI);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
AddConstToX86Reg(x86_ESI, (0x10 - m_OpCode.del + 2) & 0xF);
|
|
|
|
AddConstToX86Reg(x86_EDI, (0x10 - m_OpCode.del + 3) & 0xF);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
XorConstToX86Reg(x86_ESI, 3);
|
|
|
|
XorConstToX86Reg(x86_EDI, 3);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
AndConstToX86Reg(x86_ESI, 0x0fff);
|
|
|
|
AndConstToX86Reg(x86_EDI, 0x0fff);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveZxN64MemToX86regByte(x86_ECX, x86_ESI);
|
|
|
|
MoveZxN64MemToX86regByte(x86_EDX, x86_EDI);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
ShiftLeftSignImmed(x86_ECX, 8);
|
|
|
|
ShiftLeftSignImmed(x86_EDX, 8);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[5]", m_OpCode.rt);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_Vect[m_OpCode.vt].s16(5), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[4]", m_OpCode.rt);
|
|
|
|
MoveX86regHalfToVariable(x86_EDX, &m_Vect[m_OpCode.vt].s16(4), Reg);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_ESI);
|
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_EDI);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
AddConstToX86Reg(x86_ESI, (0x10 - m_OpCode.del + 4) & 0xF);
|
|
|
|
AddConstToX86Reg(x86_EDI, (0x10 - m_OpCode.del + 5) & 0xF);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
XorConstToX86Reg(x86_ESI, 3);
|
|
|
|
XorConstToX86Reg(x86_EDI, 3);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
AndConstToX86Reg(x86_ESI, 0x0fff);
|
|
|
|
AndConstToX86Reg(x86_EDI, 0x0fff);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveZxN64MemToX86regByte(x86_ECX, x86_ESI);
|
|
|
|
MoveZxN64MemToX86regByte(x86_EDX, x86_EDI);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
ShiftLeftSignImmed(x86_ECX, 8);
|
|
|
|
ShiftLeftSignImmed(x86_EDX, 8);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[3]", m_OpCode.rt);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_Vect[m_OpCode.vt].s16(3), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[2]", m_OpCode.rt);
|
|
|
|
MoveX86regHalfToVariable(x86_EDX, &m_Vect[m_OpCode.vt].s16(2), Reg);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_ESI);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
AddConstToX86Reg(x86_ESI, (0x10 - m_OpCode.del + 6) & 0xF);
|
|
|
|
AddConstToX86Reg(x86_EBX, (0x10 - m_OpCode.del + 7) & 0xF);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
XorConstToX86Reg(x86_ESI, 3);
|
|
|
|
XorConstToX86Reg(x86_EBX, 3);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
AndConstToX86Reg(x86_ESI, 0x0fff);
|
|
|
|
AndConstToX86Reg(x86_EBX, 0x0fff);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveZxN64MemToX86regByte(x86_ECX, x86_ESI);
|
|
|
|
MoveZxN64MemToX86regByte(x86_EDX, x86_EBX);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
ShiftLeftSignImmed(x86_ECX, 8);
|
|
|
|
ShiftLeftSignImmed(x86_EDX, 8);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[1]", m_OpCode.rt);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_Vect[m_OpCode.vt].s16(1), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rt);
|
|
|
|
MoveX86regHalfToVariable(x86_EDX, &m_Vect[m_OpCode.vt].s16(0), Reg);
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Opcode_LUV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
#ifndef CompileLuv
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::LUV, "RSPOp::LUV");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
|
|
|
char Reg[256];
|
2024-08-08 03:25:54 +00:00
|
|
|
int offset = (m_OpCode.voffset << 3);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.base].UW, GPR_Name(m_OpCode.base), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
if (offset != 0)
|
|
|
|
{
|
|
|
|
AddConstToX86Reg(x86_EBX, offset);
|
|
|
|
}
|
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_ESI);
|
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_EDI);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
AddConstToX86Reg(x86_ESI, (0x10 - m_OpCode.del + 0) & 0xF);
|
|
|
|
AddConstToX86Reg(x86_EDI, (0x10 - m_OpCode.del + 1) & 0xF);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
XorConstToX86Reg(x86_ESI, 3);
|
|
|
|
XorConstToX86Reg(x86_EDI, 3);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
AndConstToX86Reg(x86_ESI, 0x0fff);
|
|
|
|
AndConstToX86Reg(x86_EDI, 0x0fff);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveZxN64MemToX86regByte(x86_ECX, x86_ESI);
|
|
|
|
MoveZxN64MemToX86regByte(x86_EDX, x86_EDI);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
ShiftLeftSignImmed(x86_ECX, 7);
|
|
|
|
ShiftLeftSignImmed(x86_EDX, 7);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[7]", m_OpCode.rt);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_Vect[m_OpCode.vt].s16(7), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[6]", m_OpCode.rt);
|
|
|
|
MoveX86regHalfToVariable(x86_EDX, &m_Vect[m_OpCode.vt].s16(6), Reg);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_ESI);
|
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_EDI);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
AddConstToX86Reg(x86_ESI, (0x10 - m_OpCode.del + 2) & 0xF);
|
|
|
|
AddConstToX86Reg(x86_EDI, (0x10 - m_OpCode.del + 3) & 0xF);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
XorConstToX86Reg(x86_ESI, 3);
|
|
|
|
XorConstToX86Reg(x86_EDI, 3);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
AndConstToX86Reg(x86_ESI, 0x0fff);
|
|
|
|
AndConstToX86Reg(x86_EDI, 0x0fff);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveZxN64MemToX86regByte(x86_ECX, x86_ESI);
|
|
|
|
MoveZxN64MemToX86regByte(x86_EDX, x86_EDI);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
ShiftLeftSignImmed(x86_ECX, 7);
|
|
|
|
ShiftLeftSignImmed(x86_EDX, 7);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[5]", m_OpCode.rt);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_Vect[m_OpCode.vt].s16(5), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[4]", m_OpCode.rt);
|
|
|
|
MoveX86regHalfToVariable(x86_EDX, &m_Vect[m_OpCode.vt].s16(4), Reg);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_ESI);
|
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_EDI);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
AddConstToX86Reg(x86_ESI, (0x10 - m_OpCode.del + 4) & 0xF);
|
|
|
|
AddConstToX86Reg(x86_EDI, (0x10 - m_OpCode.del + 5) & 0xF);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
XorConstToX86Reg(x86_ESI, 3);
|
|
|
|
XorConstToX86Reg(x86_EDI, 3);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
AndConstToX86Reg(x86_ESI, 0x0fff);
|
|
|
|
AndConstToX86Reg(x86_EDI, 0x0fff);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveZxN64MemToX86regByte(x86_ECX, x86_ESI);
|
|
|
|
MoveZxN64MemToX86regByte(x86_EDX, x86_EDI);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
ShiftLeftSignImmed(x86_ECX, 7);
|
|
|
|
ShiftLeftSignImmed(x86_EDX, 7);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[3]", m_OpCode.rt);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_Vect[m_OpCode.vt].s16(3), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[2]", m_OpCode.rt);
|
|
|
|
MoveX86regHalfToVariable(x86_EDX, &m_Vect[m_OpCode.vt].s16(2), Reg);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_ESI);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
AddConstToX86Reg(x86_ESI, (0x10 - m_OpCode.del + 6) & 0xF);
|
|
|
|
AddConstToX86Reg(x86_EBX, (0x10 - m_OpCode.del + 7) & 0xF);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
XorConstToX86Reg(x86_ESI, 3);
|
|
|
|
XorConstToX86Reg(x86_EBX, 3);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
AndConstToX86Reg(x86_ESI, 0x0fff);
|
|
|
|
AndConstToX86Reg(x86_EBX, 0x0fff);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveZxN64MemToX86regByte(x86_ECX, x86_ESI);
|
|
|
|
MoveZxN64MemToX86regByte(x86_EDX, x86_EBX);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
ShiftLeftSignImmed(x86_ECX, 7);
|
|
|
|
ShiftLeftSignImmed(x86_EDX, 7);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[1]", m_OpCode.rt);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_Vect[m_OpCode.vt].s16(1), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rt);
|
|
|
|
MoveX86regHalfToVariable(x86_EDX, &m_Vect[m_OpCode.vt].s16(0), Reg);
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Opcode_LHV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
#ifndef CompileLhv
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::LHV, "RSPOp::LHV");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
|
|
|
char Reg[256];
|
2024-08-08 03:25:54 +00:00
|
|
|
int offset = (m_OpCode.voffset << 4);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.base].UW, GPR_Name(m_OpCode.base), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
if (offset != 0)
|
|
|
|
{
|
|
|
|
AddConstToX86Reg(x86_EBX, offset);
|
|
|
|
}
|
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_ESI);
|
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_EDI);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
AddConstToX86Reg(x86_ESI, (0x10 - m_OpCode.del + 0) & 0xF);
|
|
|
|
AddConstToX86Reg(x86_EDI, (0x10 - m_OpCode.del + 2) & 0xF);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
XorConstToX86Reg(x86_ESI, 3);
|
|
|
|
XorConstToX86Reg(x86_EDI, 3);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
AndConstToX86Reg(x86_ESI, 0x0fff);
|
|
|
|
AndConstToX86Reg(x86_EDI, 0x0fff);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveZxN64MemToX86regByte(x86_ECX, x86_ESI);
|
|
|
|
MoveZxN64MemToX86regByte(x86_EDX, x86_EDI);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
ShiftLeftSignImmed(x86_ECX, 7);
|
|
|
|
ShiftLeftSignImmed(x86_EDX, 7);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[7]", m_OpCode.rt);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_Vect[m_OpCode.vt].s16(7), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[6]", m_OpCode.rt);
|
|
|
|
MoveX86regHalfToVariable(x86_EDX, &m_Vect[m_OpCode.vt].s16(6), Reg);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_ESI);
|
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_EDI);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
AddConstToX86Reg(x86_ESI, (0x10 - m_OpCode.del + 4) & 0xF);
|
|
|
|
AddConstToX86Reg(x86_EDI, (0x10 - m_OpCode.del + 6) & 0xF);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
XorConstToX86Reg(x86_ESI, 3);
|
|
|
|
XorConstToX86Reg(x86_EDI, 3);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
AndConstToX86Reg(x86_ESI, 0x0fff);
|
|
|
|
AndConstToX86Reg(x86_EDI, 0x0fff);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveZxN64MemToX86regByte(x86_ECX, x86_ESI);
|
|
|
|
MoveZxN64MemToX86regByte(x86_EDX, x86_EDI);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
ShiftLeftSignImmed(x86_ECX, 7);
|
|
|
|
ShiftLeftSignImmed(x86_EDX, 7);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[5]", m_OpCode.rt);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_Vect[m_OpCode.vt].s16(5), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[4]", m_OpCode.rt);
|
|
|
|
MoveX86regHalfToVariable(x86_EDX, &m_Vect[m_OpCode.vt].s16(4), Reg);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_ESI);
|
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_EDI);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
AddConstToX86Reg(x86_ESI, (0x10 - m_OpCode.del + 8) & 0xF);
|
|
|
|
AddConstToX86Reg(x86_EDI, (0x10 - m_OpCode.del + 10) & 0xF);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
XorConstToX86Reg(x86_ESI, 3);
|
|
|
|
XorConstToX86Reg(x86_EDI, 3);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
AndConstToX86Reg(x86_ESI, 0x0fff);
|
|
|
|
AndConstToX86Reg(x86_EDI, 0x0fff);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveZxN64MemToX86regByte(x86_ECX, x86_ESI);
|
|
|
|
MoveZxN64MemToX86regByte(x86_EDX, x86_EDI);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
ShiftLeftSignImmed(x86_ECX, 7);
|
|
|
|
ShiftLeftSignImmed(x86_EDX, 7);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[3]", m_OpCode.rt);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_Vect[m_OpCode.vt].s16(3), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[2]", m_OpCode.rt);
|
|
|
|
MoveX86regHalfToVariable(x86_EDX, &m_Vect[m_OpCode.vt].s16(2), Reg);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_ESI);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
AddConstToX86Reg(x86_ESI, (0x10 - m_OpCode.del + 12) & 0xF);
|
|
|
|
AddConstToX86Reg(x86_EBX, (0x10 - m_OpCode.del + 14) & 0xF);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
XorConstToX86Reg(x86_ESI, 3);
|
|
|
|
XorConstToX86Reg(x86_EBX, 3);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
AndConstToX86Reg(x86_ESI, 0x0fff);
|
|
|
|
AndConstToX86Reg(x86_EBX, 0x0fff);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveZxN64MemToX86regByte(x86_ECX, x86_ESI);
|
|
|
|
MoveZxN64MemToX86regByte(x86_EDX, x86_EBX);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
ShiftLeftSignImmed(x86_ECX, 7);
|
|
|
|
ShiftLeftSignImmed(x86_EDX, 7);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].HW[1]", m_OpCode.rt);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, &m_Vect[m_OpCode.vt].s16(1), Reg);
|
|
|
|
sprintf(Reg, "m_Vect[%i].HW[0]", m_OpCode.rt);
|
|
|
|
MoveX86regHalfToVariable(x86_EDX, &m_Vect[m_OpCode.vt].s16(0), Reg);
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Opcode_LFV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::LFV, "RSPOp::LFV");
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Opcode_LWV(void)
|
2024-06-20 09:52:57 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::LWV, "RSPOp::LWV");
|
2024-06-20 09:52:57 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Opcode_LTV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::LTV, "RSPOp::LTV");
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2021-03-19 07:13:35 +00:00
|
|
|
// SC2 functions
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Opcode_SBV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::SBV, "RSPOp::SBV");
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Opcode_SSV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-06-20 07:58:51 +00:00
|
|
|
#ifndef CompileSsv
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::SSV, "RSPOp::SSV");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2024-08-08 03:25:54 +00:00
|
|
|
int offset = (m_OpCode.voffset << 1);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.del > 14)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::SSV, "RSPOp::SSV");
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (IsRegConst(m_OpCode.base))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Addr = (MipsRegConst(m_OpCode.base) + offset) & 0xfff;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
if ((Addr & 1) != 0)
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, 15 - (m_OpCode.del + 0));
|
|
|
|
MoveVariableToX86regByte(&m_Vect[m_OpCode.vt].s8((uint8_t)(15 - (m_OpCode.del + 0))), Reg, x86_ECX);
|
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, 15 - (m_OpCode.del + 1));
|
|
|
|
MoveVariableToX86regByte(&m_Vect[m_OpCode.vt].s8((uint8_t)(15 - (m_OpCode.del + 1))), Reg, x86_EDX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
sprintf(Reg, "DMEM + %Xh", (Addr + 0) ^ 3);
|
|
|
|
MoveX86regByteToVariable(x86_ECX, RSPInfo.DMEM + ((Addr + 0) ^ 3), Reg);
|
|
|
|
sprintf(Reg, "DMEM + %Xh", (Addr + 1) ^ 3);
|
|
|
|
MoveX86regByteToVariable(x86_EDX, RSPInfo.DMEM + ((Addr + 1) ^ 3), Reg);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, 15 - (m_OpCode.del + 1));
|
|
|
|
MoveVariableToX86regHalf(&m_Vect[m_OpCode.vt].s8((uint8_t)(15 - (m_OpCode.del + 1))), Reg, x86_ECX);
|
2023-06-01 11:46:23 +00:00
|
|
|
sprintf(Reg, "DMEM + %Xh", Addr ^ 2);
|
|
|
|
MoveX86regHalfToVariable(x86_ECX, RSPInfo.DMEM + (Addr ^ 2), Reg);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.base].UW, GPR_Name(m_OpCode.base), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
if (offset != 0) AddConstToX86Reg(x86_EBX, offset);
|
|
|
|
AndConstToX86Reg(x86_EBX, 0x0FFF);
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (Compiler.bAlignVector == true)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, 15 - (m_OpCode.del + 1));
|
|
|
|
MoveVariableToX86regHalf(&m_Vect[m_OpCode.vt].s8((uint8_t)(15 - (m_OpCode.del + 1))), Reg, x86_ECX);
|
2023-06-01 11:46:23 +00:00
|
|
|
XorConstToX86Reg(x86_EBX, 2);
|
|
|
|
MoveX86regHalfToN64Mem(x86_ECX, x86_EBX);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LeaSourceAndOffset(x86_EAX, x86_EBX, 1);
|
|
|
|
XorConstToX86Reg(x86_EBX, 3);
|
|
|
|
XorConstToX86Reg(x86_EAX, 3);
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, 15 - (m_OpCode.del + 0));
|
|
|
|
MoveVariableToX86regByte(&m_Vect[m_OpCode.vt].s8((uint8_t)(15 - (m_OpCode.del + 0))), Reg, x86_ECX);
|
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, 15 - (m_OpCode.del + 1));
|
|
|
|
MoveVariableToX86regByte(&m_Vect[m_OpCode.vt].s8((uint8_t)(15 - (m_OpCode.del + 1))), Reg, x86_EDX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
MoveX86regByteToN64Mem(x86_ECX, x86_EBX);
|
|
|
|
MoveX86regByteToN64Mem(x86_EDX, x86_EAX);
|
|
|
|
}
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Opcode_SLV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-07-06 09:34:50 +00:00
|
|
|
#ifndef CompileSlv
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::SLV, "RSPOp::SLV");
|
2024-07-06 09:34:50 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.del > 12)
|
2024-07-20 09:40:36 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::SLV, "RSPOp::SLV");
|
2024-07-20 09:40:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2024-08-08 03:25:54 +00:00
|
|
|
int offset = (m_OpCode.voffset << 2);
|
2023-08-16 23:29:22 +00:00
|
|
|
uint8_t * Jump[2];
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
|
|
|
if (IsRegConst(m_OpCode.base))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Addr = (MipsRegConst(m_OpCode.base) + offset) & 0xfff;
|
|
|
|
if ((Addr & 3) != 0 || m_OpCode.del > 12)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::SLV, "RSPOp::SLV");
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, 16 - m_OpCode.del - 4);
|
|
|
|
MoveVariableToX86reg(&m_Vect[m_OpCode.vt].s8((uint8_t)(16 - m_OpCode.del - 4)), Reg, x86_EAX);
|
2023-06-01 11:46:23 +00:00
|
|
|
sprintf(Reg, "DMEM + %Xh", Addr);
|
|
|
|
MoveX86regToVariable(x86_EAX, RSPInfo.DMEM + Addr, Reg);
|
|
|
|
return;
|
|
|
|
}
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.base].UW, GPR_Name(m_OpCode.base), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
if (offset != 0) AddConstToX86Reg(x86_EBX, offset);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
TestConstToX86Reg(3, x86_EBX);
|
|
|
|
JneLabel32("Unaligned", 0);
|
|
|
|
Jump[0] = RecompPos - 4;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Unaligned
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
CompilerToggleBuffer();
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
CPU_Message(" Unaligned:");
|
2023-08-10 04:46:57 +00:00
|
|
|
*((uint32_t *)(Jump[0])) = (uint32_t)(RecompPos - Jump[0] - 4);
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::SLV, "RSPOp::SLV");
|
2023-06-01 11:46:23 +00:00
|
|
|
JmpLabel32("Done", 0);
|
|
|
|
Jump[1] = RecompPos - 4;
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
CompilerToggleBuffer();
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Aligned
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
// Because of byte swapping this swizzle works nicely
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, 16 - m_OpCode.del - 4);
|
|
|
|
MoveVariableToX86reg(&m_Vect[m_OpCode.vt].s8((uint8_t)(16 - m_OpCode.del - 4)), Reg, x86_EAX);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
AndConstToX86Reg(x86_EBX, 0x0fff);
|
|
|
|
MoveX86regToN64Mem(x86_EAX, x86_EBX);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
CPU_Message(" Done:");
|
2023-08-10 04:46:57 +00:00
|
|
|
*((uint32_t *)(Jump[1])) = (uint32_t)(RecompPos - Jump[1] - 4);
|
2024-07-06 09:34:50 +00:00
|
|
|
#endif
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Opcode_SDV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-06-20 07:58:51 +00:00
|
|
|
#ifndef CompileSdv
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::SDV, "RSPOp::SDV");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.del > 8)
|
2024-07-20 09:40:36 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::SDV, "RSPOp::SDV");
|
2024-07-20 09:40:36 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2024-08-08 03:25:54 +00:00
|
|
|
int offset = (m_OpCode.voffset << 3);
|
2023-08-16 23:29:22 +00:00
|
|
|
uint8_t *Jump[2], *LoopEntry;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
//if ((m_OpCode.del & 0x7) != 0) {
|
2023-06-01 11:46:23 +00:00
|
|
|
// rsp_UnknownOpcode();
|
|
|
|
// return;
|
|
|
|
//}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (IsRegConst(m_OpCode.base))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Addr = (MipsRegConst(m_OpCode.base) + offset) & 0xfff;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
if ((Addr & 3) != 0)
|
|
|
|
{
|
2023-08-16 23:29:22 +00:00
|
|
|
CompilerWarning(stdstr_f("Unaligned SDV at constant address PC = %04X", CompilePC).c_str());
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::SDV, "RSPOp::SDV");
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, (16 - m_OpCode.del - 4) & 0xF);
|
|
|
|
MoveVariableToX86reg(&m_Vect[m_OpCode.vt].s8((16 - m_OpCode.del - 4) & 0xF), Reg, x86_EAX);
|
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, (16 - m_OpCode.del - 8) & 0xF);
|
|
|
|
MoveVariableToX86reg(&m_Vect[m_OpCode.vt].s8((16 - m_OpCode.del - 8) & 0xF), Reg, x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
sprintf(Reg, "DMEM + %Xh", Addr);
|
|
|
|
MoveX86regToVariable(x86_EAX, RSPInfo.DMEM + Addr, Reg);
|
|
|
|
sprintf(Reg, "DMEM + %Xh", Addr + 4);
|
|
|
|
MoveX86regToVariable(x86_EBX, RSPInfo.DMEM + Addr + 4, Reg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.base].UW, GPR_Name(m_OpCode.base), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
if (offset != 0)
|
|
|
|
{
|
|
|
|
AddConstToX86Reg(x86_EBX, offset);
|
|
|
|
}
|
|
|
|
AndConstToX86Reg(x86_EBX, 0x0fff);
|
|
|
|
TestConstToX86Reg(3, x86_EBX);
|
|
|
|
JneLabel32("Unaligned", 0);
|
|
|
|
Jump[0] = RecompPos - 4;
|
|
|
|
|
|
|
|
CompilerToggleBuffer();
|
|
|
|
CPU_Message(" Unaligned:");
|
2023-08-10 04:46:57 +00:00
|
|
|
x86_SetBranch32b((uint32_t *)Jump[0], (uint32_t *)RecompPos);
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].UB[%i]", m_OpCode.rt, 15 - m_OpCode.del);
|
|
|
|
MoveOffsetToX86reg((size_t)&m_Vect[m_OpCode.vt].u8((uint8_t)(15 - m_OpCode.del)), Reg, x86_EDI);
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveConstToX86reg(8, x86_ECX);
|
|
|
|
|
|
|
|
CPU_Message(" Loop:");
|
|
|
|
LoopEntry = RecompPos;
|
|
|
|
MoveX86RegToX86Reg(x86_EBX, x86_EAX);
|
|
|
|
XorConstToX86Reg(x86_EAX, 3);
|
|
|
|
MoveX86regPointerToX86regByte(x86_EDX, x86_EDI);
|
|
|
|
MoveX86regByteToN64Mem(x86_EDX, x86_EAX);
|
|
|
|
IncX86reg(x86_EBX); // Address constant
|
|
|
|
DecX86reg(x86_EDI); // Vector pointer
|
|
|
|
DecX86reg(x86_ECX); // Counter
|
|
|
|
JneLabel8("Loop", 0);
|
|
|
|
x86_SetBranch8b(RecompPos - 1, LoopEntry);
|
|
|
|
|
|
|
|
JmpLabel32("Done", 0);
|
|
|
|
Jump[1] = RecompPos - 4;
|
|
|
|
CompilerToggleBuffer();
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, (16 - m_OpCode.del - 4) & 0xF);
|
|
|
|
MoveVariableToX86reg(&m_Vect[m_OpCode.vt].s8((16 - m_OpCode.del - 4) & 0xF), Reg, x86_EAX);
|
|
|
|
sprintf(Reg, "m_Vect[%i].B[%i]", m_OpCode.rt, (16 - m_OpCode.del - 8) & 0xF);
|
|
|
|
MoveVariableToX86reg(&m_Vect[m_OpCode.vt].s8((16 - m_OpCode.del - 8) & 0xF), Reg, x86_ECX);
|
2023-06-01 11:46:23 +00:00
|
|
|
MoveX86regToN64Mem(x86_EAX, x86_EBX);
|
|
|
|
MoveX86regToN64MemDisp(x86_ECX, x86_EBX, 4);
|
|
|
|
|
|
|
|
CPU_Message(" Done:");
|
2023-08-10 04:46:57 +00:00
|
|
|
x86_SetBranch32b((uint32_t *)Jump[1], (uint32_t *)RecompPos);
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Opcode_SQV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-06-20 07:58:51 +00:00
|
|
|
#ifndef CompileSqv
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::SQV, "RSPOp::SQV");
|
2024-06-20 07:58:51 +00:00
|
|
|
#else
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.del != 0 && m_OpCode.del != 12)
|
2024-07-12 05:53:59 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::SQV, "RSPOp::SQV");
|
2024-07-12 05:53:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-06-01 11:46:23 +00:00
|
|
|
char Reg[256];
|
2024-08-08 03:25:54 +00:00
|
|
|
int offset = (m_OpCode.voffset << 4);
|
2023-08-16 23:29:22 +00:00
|
|
|
uint8_t * Jump[2];
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2023-06-01 11:46:23 +00:00
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
if (IsRegConst(m_OpCode.base))
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
uint32_t Addr = (MipsRegConst(m_OpCode.base) + offset) & 0xfff;
|
2023-06-01 11:46:23 +00:00
|
|
|
|
|
|
|
if (Addr & 15)
|
|
|
|
{
|
2023-08-16 23:29:22 +00:00
|
|
|
CompilerWarning(stdstr_f("Unaligned SQV at constant address %04X", CompilePC).c_str());
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::SQV, "RSPOp::SQV");
|
2023-06-01 11:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Aligned store
|
|
|
|
|
2023-06-29 02:59:07 +00:00
|
|
|
if (IsSseEnabled == false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.del == 12)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[0]", m_OpCode.rt);
|
|
|
|
MoveVariableToX86reg(&m_Vect[m_OpCode.vt].s8(0), Reg, x86_EAX);
|
|
|
|
sprintf(Reg, "m_Vect[%i].B[12]", m_OpCode.rt);
|
|
|
|
MoveVariableToX86reg(&m_Vect[m_OpCode.vt].s8(12), Reg, x86_EBX);
|
|
|
|
sprintf(Reg, "m_Vect[%i].B[8]", m_OpCode.rt);
|
|
|
|
MoveVariableToX86reg(&m_Vect[m_OpCode.vt].s8(8), Reg, x86_ECX);
|
|
|
|
sprintf(Reg, "m_Vect[%i].B[4]", m_OpCode.rt);
|
|
|
|
MoveVariableToX86reg(&m_Vect[m_OpCode.vt].s8(4), Reg, x86_EDX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[12]", m_OpCode.rt);
|
|
|
|
MoveVariableToX86reg(&m_Vect[m_OpCode.vt].s8(12), Reg, x86_EAX);
|
|
|
|
sprintf(Reg, "m_Vect[%i].B[8]", m_OpCode.rt);
|
|
|
|
MoveVariableToX86reg(&m_Vect[m_OpCode.vt].s8(8), Reg, x86_EBX);
|
|
|
|
sprintf(Reg, "m_Vect[%i].B[4]", m_OpCode.rt);
|
|
|
|
MoveVariableToX86reg(&m_Vect[m_OpCode.vt].s8(4), Reg, x86_ECX);
|
|
|
|
sprintf(Reg, "m_Vect[%i].B[0]", m_OpCode.rt);
|
|
|
|
MoveVariableToX86reg(&m_Vect[m_OpCode.vt].s8(0), Reg, x86_EDX);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(Reg, "DMEM+%Xh+0", Addr);
|
|
|
|
MoveX86regToVariable(x86_EAX, RSPInfo.DMEM + Addr + 0, Reg);
|
|
|
|
sprintf(Reg, "DMEM+%Xh+4", Addr);
|
|
|
|
MoveX86regToVariable(x86_EBX, RSPInfo.DMEM + Addr + 4, Reg);
|
|
|
|
sprintf(Reg, "DMEM+%Xh+8", Addr);
|
|
|
|
MoveX86regToVariable(x86_ECX, RSPInfo.DMEM + Addr + 8, Reg);
|
|
|
|
sprintf(Reg, "DMEM+%Xh+C", Addr);
|
|
|
|
MoveX86regToVariable(x86_EDX, RSPInfo.DMEM + Addr + 12, Reg);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[0]", m_OpCode.rt);
|
|
|
|
SseMoveAlignedVariableToReg(&m_Vect[m_OpCode.vt].s8(0), Reg, x86_XMM0);
|
|
|
|
if (m_OpCode.del == 12)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
SseShuffleReg(x86_XMM0, x86_MM0, 0x6c);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SseShuffleReg(x86_XMM0, x86_MM0, 0x1b);
|
|
|
|
}
|
|
|
|
sprintf(Reg, "DMEM+%Xh", Addr);
|
|
|
|
SseMoveUnalignedRegToVariable(x86_XMM0, RSPInfo.DMEM + Addr, Reg);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveVariableToX86reg(&m_GPR[m_OpCode.base].UW, GPR_Name(m_OpCode.base), x86_EBX);
|
2023-06-01 11:46:23 +00:00
|
|
|
if (offset != 0)
|
|
|
|
{
|
|
|
|
AddConstToX86Reg(x86_EBX, offset);
|
|
|
|
}
|
|
|
|
TestConstToX86Reg(15, x86_EBX);
|
|
|
|
JneLabel32("Unaligned", 0);
|
|
|
|
Jump[0] = RecompPos - 4;
|
|
|
|
|
|
|
|
CompilerToggleBuffer();
|
|
|
|
CPU_Message(" Unaligned:");
|
2023-08-10 04:46:57 +00:00
|
|
|
x86_SetBranch32b((uint32_t *)Jump[0], (uint32_t *)RecompPos);
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcodeNoMessage(&RSPOp::SQV, "RSPOp::SQV");
|
2023-06-01 11:46:23 +00:00
|
|
|
JmpLabel32("Done", 0);
|
|
|
|
Jump[1] = RecompPos - 4;
|
|
|
|
CompilerToggleBuffer();
|
|
|
|
|
|
|
|
AndConstToX86Reg(x86_EBX, 0x0fff);
|
2023-06-29 02:59:07 +00:00
|
|
|
if (IsSseEnabled == false)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
if (m_OpCode.del == 12)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[0]", m_OpCode.rt);
|
|
|
|
MoveVariableToX86reg(&m_Vect[m_OpCode.vt].s8(0), Reg, x86_EAX);
|
|
|
|
sprintf(Reg, "m_Vect[%i].B[12]", m_OpCode.rt);
|
|
|
|
MoveVariableToX86reg(&m_Vect[m_OpCode.vt].s8(12), Reg, x86_ECX);
|
|
|
|
sprintf(Reg, "m_Vect[%i].B[8]", m_OpCode.rt);
|
|
|
|
MoveVariableToX86reg(&m_Vect[m_OpCode.vt].s8(8), Reg, x86_EDX);
|
|
|
|
sprintf(Reg, "m_Vect[%i].B[4]", m_OpCode.rt);
|
|
|
|
MoveVariableToX86reg(&m_Vect[m_OpCode.vt].s8(4), Reg, x86_EDI);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[12]", m_OpCode.rt);
|
|
|
|
MoveVariableToX86reg(&m_Vect[m_OpCode.vt].s8(12), Reg, x86_EAX);
|
|
|
|
sprintf(Reg, "m_Vect[%i].B[8]", m_OpCode.rt);
|
|
|
|
MoveVariableToX86reg(&m_Vect[m_OpCode.vt].s8(8), Reg, x86_ECX);
|
|
|
|
sprintf(Reg, "m_Vect[%i].B[4]", m_OpCode.rt);
|
|
|
|
MoveVariableToX86reg(&m_Vect[m_OpCode.vt].s8(4), Reg, x86_EDX);
|
|
|
|
sprintf(Reg, "m_Vect[%i].B[0]", m_OpCode.rt);
|
|
|
|
MoveVariableToX86reg(&m_Vect[m_OpCode.vt].s8(0), Reg, x86_EDI);
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MoveX86regToN64MemDisp(x86_EAX, x86_EBX, 0);
|
|
|
|
MoveX86regToN64MemDisp(x86_ECX, x86_EBX, 4);
|
|
|
|
MoveX86regToN64MemDisp(x86_EDX, x86_EBX, 8);
|
|
|
|
MoveX86regToN64MemDisp(x86_EDI, x86_EBX, 12);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
sprintf(Reg, "m_Vect[%i].B[0]", m_OpCode.rt);
|
|
|
|
SseMoveAlignedVariableToReg(&m_Vect[m_OpCode.vt].s8(0), Reg, x86_XMM0);
|
|
|
|
if (m_OpCode.del == 12)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
|
|
|
SseShuffleReg(x86_XMM0, x86_MM0, 0x6c);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SseShuffleReg(x86_XMM0, x86_MM0, 0x1b);
|
|
|
|
}
|
|
|
|
SseMoveUnalignedRegToN64Mem(x86_XMM0, x86_EBX);
|
|
|
|
}
|
|
|
|
CPU_Message(" Done:");
|
2023-08-10 04:46:57 +00:00
|
|
|
x86_SetBranch32b((uint32_t *)Jump[1], (uint32_t *)RecompPos);
|
2024-06-20 07:58:51 +00:00
|
|
|
#endif
|
2023-06-01 11:46:23 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Opcode_SRV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::SRV, "RSPOp::SRV");
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Opcode_SPV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::SPV, "RSPOp::SPV");
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Opcode_SUV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::SUV, "RSPOp::SUV");
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Opcode_SHV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::SHV, "RSPOp::SHV");
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Opcode_SFV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::SFV, "RSPOp::SFV");
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Opcode_STV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::STV, "RSPOp::STV");
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::Opcode_SWV(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-01 23:30:38 +00:00
|
|
|
Cheat_r4300iOpcode(&RSPOp::SWV, "&RSPOp::SWV");
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|
|
|
|
|
2021-03-19 07:13:35 +00:00
|
|
|
// Other functions
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2024-08-02 12:30:01 +00:00
|
|
|
void CRSPRecompilerOps::UnknownOpcode(void)
|
2023-06-01 11:46:23 +00:00
|
|
|
{
|
2024-08-08 03:25:54 +00:00
|
|
|
CPU_Message(" %X Unhandled Opcode: %s", CompilePC, RSPInstruction(CompilePC, m_OpCode.Value).NameAndParam().c_str());
|
2024-08-22 10:14:07 +00:00
|
|
|
m_NextInstruction = RSPPIPELINE_FINISH_BLOCK;
|
2024-08-22 08:02:05 +00:00
|
|
|
MoveConstToVariable(CompilePC, m_System.m_SP_PC_REG, "RSP PC");
|
2024-08-08 03:25:54 +00:00
|
|
|
MoveConstToVariable(m_OpCode.Value, &m_OpCode.Value, "m_OpCode.Value");
|
|
|
|
MoveConstToX86reg((uint32_t) & (RSPSystem.m_Op), x86_ECX);
|
2024-08-01 23:30:38 +00:00
|
|
|
Call_Direct(AddressOf(&RSPOp::UnknownOpcode), "&RSPOp::UnknownOpcode");
|
2023-06-01 11:46:23 +00:00
|
|
|
Ret();
|
2016-01-27 09:39:06 +00:00
|
|
|
}
|