[Project64] Clean up Interpreter CPU

This commit is contained in:
zilmar 2015-11-15 09:08:30 +11:00
parent 46fea05262
commit 89b197be43
5 changed files with 118 additions and 117 deletions

View File

@ -271,8 +271,8 @@ void CInterpreterCPU::ExecuteCPU()
const int32_t & bDoSomething = g_SystemEvents->DoSomething(); const int32_t & bDoSomething = g_SystemEvents->DoSomething();
uint32_t CountPerOp = g_System->CountPerOp(); uint32_t CountPerOp = g_System->CountPerOp();
int32_t & NextTimer = *g_NextTimer; int32_t & NextTimer = *g_NextTimer;
__try __try
{ {
while (!Done) while (!Done)
{ {
@ -301,24 +301,24 @@ void CInterpreterCPU::ExecuteCPU()
PROGRAM_COUNTER += 4; PROGRAM_COUNTER += 4;
break; break;
case JUMP: case JUMP:
{
bool CheckTimer = (JumpToLocation < PROGRAM_COUNTER || TestTimer);
PROGRAM_COUNTER = JumpToLocation;
R4300iOp::m_NextInstruction = NORMAL;
if (CheckTimer)
{ {
bool CheckTimer = (JumpToLocation < PROGRAM_COUNTER || TestTimer); TestTimer = false;
PROGRAM_COUNTER = JumpToLocation; if (NextTimer < 0)
R4300iOp::m_NextInstruction = NORMAL;
if (CheckTimer)
{ {
TestTimer = false; g_SystemTimer->TimerDone();
if (NextTimer < 0) }
{ if (bDoSomething)
g_SystemTimer->TimerDone(); {
} g_SystemEvents->ExecuteEvents();
if (bDoSomething)
{
g_SystemEvents->ExecuteEvents();
}
} }
} }
break; }
break;
case PERMLOOP_DELAY_DONE: case PERMLOOP_DELAY_DONE:
PROGRAM_COUNTER = JumpToLocation; PROGRAM_COUNTER = JumpToLocation;
R4300iOp::m_NextInstruction = NORMAL; R4300iOp::m_NextInstruction = NORMAL;
@ -339,7 +339,8 @@ void CInterpreterCPU::ExecuteCPU()
R4300iOp::m_NextInstruction = NORMAL; R4300iOp::m_NextInstruction = NORMAL;
} }
} }
} __except( g_MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation()) ) }
__except (g_MMU->MemoryFilter(GetExceptionCode(), GetExceptionInformation()))
{ {
g_Notify->FatalError(GS(MSG_UNKNOWN_MEM_ACTION)); g_Notify->FatalError(GS(MSG_UNKNOWN_MEM_ACTION));
} }
@ -355,7 +356,7 @@ void CInterpreterCPU::ExecuteOps(int32_t Cycles)
const int32_t & DoSomething = g_SystemEvents->DoSomething(); const int32_t & DoSomething = g_SystemEvents->DoSomething();
uint32_t CountPerOp = g_System->CountPerOp(); uint32_t CountPerOp = g_System->CountPerOp();
__try __try
{ {
while (!Done) while (!Done)
{ {
@ -409,24 +410,24 @@ void CInterpreterCPU::ExecuteOps(int32_t Cycles)
PROGRAM_COUNTER += 4; PROGRAM_COUNTER += 4;
break; break;
case JUMP: case JUMP:
{
bool CheckTimer = (JumpToLocation < PROGRAM_COUNTER || TestTimer);
PROGRAM_COUNTER = JumpToLocation;
R4300iOp::m_NextInstruction = NORMAL;
if (CheckTimer)
{ {
bool CheckTimer = (JumpToLocation < PROGRAM_COUNTER || TestTimer); TestTimer = false;
PROGRAM_COUNTER = JumpToLocation; if (*g_NextTimer < 0)
R4300iOp::m_NextInstruction = NORMAL;
if (CheckTimer)
{ {
TestTimer = false; g_SystemTimer->TimerDone();
if (*g_NextTimer < 0) }
{ if (DoSomething)
g_SystemTimer->TimerDone(); {
} g_SystemEvents->ExecuteEvents();
if (DoSomething)
{
g_SystemEvents->ExecuteEvents();
}
} }
} }
break; }
break;
case PERMLOOP_DELAY_DONE: case PERMLOOP_DELAY_DONE:
PROGRAM_COUNTER = JumpToLocation; PROGRAM_COUNTER = JumpToLocation;
R4300iOp::m_NextInstruction = NORMAL; R4300iOp::m_NextInstruction = NORMAL;
@ -448,8 +449,8 @@ void CInterpreterCPU::ExecuteOps(int32_t Cycles)
} }
} }
} }
__except( g_MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation()) ) __except (g_MMU->MemoryFilter(GetExceptionCode(), GetExceptionInformation()))
{ {
g_Notify->FatalError(GS(MSG_UNKNOWN_MEM_ACTION)); g_Notify->FatalError(GS(MSG_UNKNOWN_MEM_ACTION));
} }
} }

View File

@ -11,18 +11,18 @@
#pragma once #pragma once
class CInterpreterCPU : class CInterpreterCPU :
private R4300iOp private R4300iOp
{ {
public: public:
static void BuildCPU(); static void BuildCPU();
static void ExecuteCPU(); static void ExecuteCPU();
static void ExecuteOps(int Cycles); static void ExecuteOps(int Cycles);
static void InPermLoop(); static void InPermLoop();
private: private:
CInterpreterCPU(); // Disable default constructor CInterpreterCPU(); // Disable default constructor
CInterpreterCPU(const CInterpreterCPU&); // Disable copy constructor CInterpreterCPU(const CInterpreterCPU&); // Disable copy constructor
CInterpreterCPU& operator=(const CInterpreterCPU&); // Disable assignment CInterpreterCPU& operator=(const CInterpreterCPU&); // Disable assignment
static R4300iOp::Func * m_R4300i_Opcode; static R4300iOp::Func * m_R4300i_Opcode;
}; };

View File

@ -26,7 +26,7 @@ bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2);
m_NextInstruction = JUMP;\ m_NextInstruction = JUMP;\
m_JumpToLocation = (*_PROGRAM_COUNTER);\ m_JumpToLocation = (*_PROGRAM_COUNTER);\
return;\ return;\
} }
#define TLB_READ_EXCEPTION(Address) \ #define TLB_READ_EXCEPTION(Address) \
g_Reg->DoTLBReadMiss(m_NextInstruction == JUMP,Address);\ g_Reg->DoTLBReadMiss(m_NextInstruction == JUMP,Address);\

View File

@ -11,74 +11,74 @@
#pragma once #pragma once
class R4300iOp32 : class R4300iOp32 :
public R4300iOp public R4300iOp
{ {
public: public:
/************************* OpCode functions *************************/ /************************* OpCode functions *************************/
static void JAL(); static void JAL();
static void BEQ(); static void BEQ();
static void BNE(); static void BNE();
static void BLEZ(); static void BLEZ();
static void BGTZ(); static void BGTZ();
static void ADDI(); static void ADDI();
static void ADDIU(); static void ADDIU();
static void SLTI(); static void SLTI();
static void SLTIU(); static void SLTIU();
static void ANDI(); static void ANDI();
static void ORI(); static void ORI();
static void XORI(); static void XORI();
static void LUI(); static void LUI();
static void BEQL(); static void BEQL();
static void BNEL(); static void BNEL();
static void BLEZL(); static void BLEZL();
static void BGTZL(); static void BGTZL();
static void LB(); static void LB();
static void LH(); static void LH();
static void LWL(); static void LWL();
static void LW(); static void LW();
static void LBU(); static void LBU();
static void LHU(); static void LHU();
static void LWR(); static void LWR();
static void LWU(); static void LWU();
static void LL(); static void LL();
/********************** R4300i OpCodes: Special **********************/ /********************** R4300i OpCodes: Special **********************/
static void SPECIAL_SLL(); static void SPECIAL_SLL();
static void SPECIAL_SRL(); static void SPECIAL_SRL();
static void SPECIAL_SRA(); static void SPECIAL_SRA();
static void SPECIAL_SLLV(); static void SPECIAL_SLLV();
static void SPECIAL_SRLV(); static void SPECIAL_SRLV();
static void SPECIAL_SRAV(); static void SPECIAL_SRAV();
static void SPECIAL_JALR(); static void SPECIAL_JALR();
static void SPECIAL_ADD(); static void SPECIAL_ADD();
static void SPECIAL_ADDU(); static void SPECIAL_ADDU();
static void SPECIAL_SUB(); static void SPECIAL_SUB();
static void SPECIAL_SUBU(); static void SPECIAL_SUBU();
static void SPECIAL_AND(); static void SPECIAL_AND();
static void SPECIAL_OR(); static void SPECIAL_OR();
static void SPECIAL_NOR(); static void SPECIAL_NOR();
static void SPECIAL_SLT(); static void SPECIAL_SLT();
static void SPECIAL_SLTU(); static void SPECIAL_SLTU();
static void SPECIAL_TEQ(); static void SPECIAL_TEQ();
static void SPECIAL_DSRL32(); static void SPECIAL_DSRL32();
static void SPECIAL_DSRA32(); static void SPECIAL_DSRA32();
/********************** R4300i OpCodes: RegImm **********************/ /********************** R4300i OpCodes: RegImm **********************/
static void REGIMM_BLTZ(); static void REGIMM_BLTZ();
static void REGIMM_BGEZ(); static void REGIMM_BGEZ();
static void REGIMM_BLTZL(); static void REGIMM_BLTZL();
static void REGIMM_BGEZL(); static void REGIMM_BGEZL();
static void REGIMM_BLTZAL(); static void REGIMM_BLTZAL();
static void REGIMM_BGEZAL(); static void REGIMM_BGEZAL();
/************************** COP0 functions **************************/ /************************** COP0 functions **************************/
static void COP0_MF(); static void COP0_MF();
static void COP0_MT(); static void COP0_MT();
/************************** COP1 functions **************************/ /************************** COP1 functions **************************/
static void COP1_MF(); static void COP1_MF();
static void COP1_CF(); static void COP1_CF();
static void COP1_DMT(); static void COP1_DMT();
static Func* BuildInterpreter(); static Func* BuildInterpreter();
}; };

View File

@ -54,7 +54,7 @@ const int32_t R4300iOp::LWR_SHIFT[4] = { 24, 16, 8, 0 };
m_NextInstruction = JUMP;\ m_NextInstruction = JUMP;\
m_JumpToLocation = (*_PROGRAM_COUNTER);\ m_JumpToLocation = (*_PROGRAM_COUNTER);\
return;\ return;\
} }
#define TLB_READ_EXCEPTION(Address) \ #define TLB_READ_EXCEPTION(Address) \
g_Reg->DoTLBReadMiss(m_NextInstruction == JUMP,Address);\ g_Reg->DoTLBReadMiss(m_NextInstruction == JUMP,Address);\
@ -902,7 +902,7 @@ void R4300iOp::LUI()
if (m_Opcode.rt == 29) if (m_Opcode.rt == 29)
{ {
StackValue = _GPR[m_Opcode.rt].W[0]; StackValue = _GPR[m_Opcode.rt].W[0];
} }
#endif #endif
} }
@ -1866,7 +1866,7 @@ void R4300iOp::SPECIAL_OR()
if (m_Opcode.rd == 29) if (m_Opcode.rd == 29)
{ {
StackValue = _GPR[m_Opcode.rd].W[0]; StackValue = _GPR[m_Opcode.rd].W[0];
} }
#endif #endif
} }
@ -2363,7 +2363,7 @@ __inline void Float_RoundToInteger32(int32_t * Dest, float * Source)
xmm = _mm_load_ss(Source); xmm = _mm_load_ss(Source);
*(Dest) = _mm_cvt_ss2si(xmm); *(Dest) = _mm_cvt_ss2si(xmm);
#endif #endif
} }
__inline void Float_RoundToInteger64(int64_t * Dest, float * Source) __inline void Float_RoundToInteger64(int64_t * Dest, float * Source)
{ {
@ -2381,7 +2381,7 @@ __inline void Float_RoundToInteger64(int64_t * Dest, float * Source)
xmm = _mm_load_ss(Source); xmm = _mm_load_ss(Source);
*(Dest) = _mm_cvtss_si64(xmm); *(Dest) = _mm_cvtss_si64(xmm);
#endif #endif
} }
void R4300iOp::COP1_S_ADD() void R4300iOp::COP1_S_ADD()
{ {
@ -2436,7 +2436,7 @@ void R4300iOp::COP1_S_SQRT()
xmm = _mm_sqrt_ss(xmm); xmm = _mm_sqrt_ss(xmm);
*(Dest) = _mm_cvtss_f32(xmm); *(Dest) = _mm_cvtss_f32(xmm);
#endif #endif
} }
void R4300iOp::COP1_S_ABS() void R4300iOp::COP1_S_ABS()
{ {
@ -2594,7 +2594,7 @@ __inline void Double_RoundToInteger32(uint32_t * Dest, double * Source)
xmm = _mm_load_sd(Source); xmm = _mm_load_sd(Source);
*(Dest) = _mm_cvtsd_si32(xmm); *(Dest) = _mm_cvtsd_si32(xmm);
#endif #endif
} }
__inline void Double_RoundToInteger64(uint64_t * Dest, double * Source) __inline void Double_RoundToInteger64(uint64_t * Dest, double * Source)
{ {
@ -2612,7 +2612,7 @@ __inline void Double_RoundToInteger64(uint64_t * Dest, double * Source)
xmm = _mm_load_sd(Source); xmm = _mm_load_sd(Source);
*(Dest) = _mm_cvtsd_si64(xmm); *(Dest) = _mm_cvtsd_si64(xmm);
#endif #endif
} }
void R4300iOp::COP1_D_ADD() void R4300iOp::COP1_D_ADD()
{ {
@ -2825,7 +2825,7 @@ void R4300iOp::UnknownOpcode()
R4300iOpcodeName(m_Opcode.Hex, (*_PROGRAM_COUNTER))).ToUTF16().c_str()); R4300iOpcodeName(m_Opcode.Hex, (*_PROGRAM_COUNTER))).ToUTF16().c_str());
g_System->m_EndEmulation = true; g_System->m_EndEmulation = true;
g_Notify->BreakPoint(__FILEW__,__LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
#ifdef tofix #ifdef tofix
if (HaveDebugger && !inFullScreen) if (HaveDebugger && !inFullScreen)
{ {
@ -2839,6 +2839,6 @@ void R4300iOp::UnknownOpcode()
Enter_R4300i_Commands_Window (); Enter_R4300i_Commands_Window ();
} }
ExitThread(0); ExitThread(0);
} }
#endif #endif
} }