[Project64] Get Interpreter Ops to use standard types

This commit is contained in:
zilmar 2015-11-09 07:55:32 +11:00
parent 1ace31216d
commit e85c1665b1
8 changed files with 3791 additions and 3809 deletions

View File

@ -12,12 +12,12 @@
R4300iOp::Func * CInterpreterCPU::m_R4300i_Opcode = NULL; R4300iOp::Func * CInterpreterCPU::m_R4300i_Opcode = NULL;
void ExecuteInterpreterOps (DWORD /*Cycles*/) void ExecuteInterpreterOps(uint32_t /*Cycles*/)
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
bool DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2) bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2)
{ {
OPCODE Command; OPCODE Command;
@ -266,11 +266,11 @@ void CInterpreterCPU::ExecuteCPU()
bool & Done = g_System->m_EndEmulation; bool & Done = g_System->m_EndEmulation;
uint32_t & PROGRAM_COUNTER = *_PROGRAM_COUNTER; uint32_t & PROGRAM_COUNTER = *_PROGRAM_COUNTER;
OPCODE & Opcode = R4300iOp::m_Opcode; OPCODE & Opcode = R4300iOp::m_Opcode;
DWORD & JumpToLocation = R4300iOp::m_JumpToLocation; uint32_t & JumpToLocation = R4300iOp::m_JumpToLocation;
bool & TestTimer = R4300iOp::m_TestTimer; bool & TestTimer = R4300iOp::m_TestTimer;
const BOOL & bDoSomething= g_SystemEvents->DoSomething(); const int32_t & bDoSomething = g_SystemEvents->DoSomething();
DWORD CountPerOp = g_System->CountPerOp(); uint32_t CountPerOp = g_System->CountPerOp();
int & NextTimer = *g_NextTimer; int32_t & NextTimer = *g_NextTimer;
__try __try
{ {
@ -302,7 +302,7 @@ void CInterpreterCPU::ExecuteCPU()
break; break;
case JUMP: case JUMP:
{ {
BOOL CheckTimer = (JumpToLocation < PROGRAM_COUNTER || TestTimer); bool CheckTimer = (JumpToLocation < PROGRAM_COUNTER || TestTimer);
PROGRAM_COUNTER = JumpToLocation; PROGRAM_COUNTER = JumpToLocation;
R4300iOp::m_NextInstruction = NORMAL; R4300iOp::m_NextInstruction = NORMAL;
if (CheckTimer) if (CheckTimer)
@ -341,21 +341,19 @@ void CInterpreterCPU::ExecuteCPU()
} }
} __except( g_MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation()) ) } __except( g_MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation()) )
{ {
g_Notify->DisplayError(GS(MSG_UNKNOWN_MEM_ACTION)); g_Notify->FatalError(GS(MSG_UNKNOWN_MEM_ACTION));
ExitThread(0);
} }
} }
void CInterpreterCPU::ExecuteOps(int32_t Cycles)
void CInterpreterCPU::ExecuteOps(int Cycles)
{ {
bool & Done = g_System->m_EndEmulation; bool & Done = g_System->m_EndEmulation;
uint32_t & PROGRAM_COUNTER = *_PROGRAM_COUNTER; uint32_t & PROGRAM_COUNTER = *_PROGRAM_COUNTER;
OPCODE & Opcode = R4300iOp::m_Opcode; OPCODE & Opcode = R4300iOp::m_Opcode;
DWORD & JumpToLocation = R4300iOp::m_JumpToLocation; uint32_t & JumpToLocation = R4300iOp::m_JumpToLocation;
bool & TestTimer = R4300iOp::m_TestTimer; bool & TestTimer = R4300iOp::m_TestTimer;
const BOOL & DoSomething = g_SystemEvents->DoSomething(); const int32_t & DoSomething = g_SystemEvents->DoSomething();
DWORD CountPerOp = g_System->CountPerOp(); uint32_t CountPerOp = g_System->CountPerOp();
__try __try
{ {
@ -387,7 +385,7 @@ void CInterpreterCPU::ExecuteOps(int Cycles)
Cycles -= CountPerOp; Cycles -= CountPerOp;
*g_NextTimer -= CountPerOp; *g_NextTimer -= CountPerOp;
/*static DWORD TestAddress = 0x80077B0C, TestValue = 0, CurrentValue = 0; /*static uint32_t TestAddress = 0x80077B0C, TestValue = 0, CurrentValue = 0;
if (g_MMU->LW_VAddr(TestAddress, TestValue)) if (g_MMU->LW_VAddr(TestAddress, TestValue))
{ {
if (TestValue != CurrentValue) if (TestValue != CurrentValue)
@ -412,7 +410,7 @@ void CInterpreterCPU::ExecuteOps(int Cycles)
break; break;
case JUMP: case JUMP:
{ {
BOOL CheckTimer = (JumpToLocation < PROGRAM_COUNTER || TestTimer); bool CheckTimer = (JumpToLocation < PROGRAM_COUNTER || TestTimer);
PROGRAM_COUNTER = JumpToLocation; PROGRAM_COUNTER = JumpToLocation;
R4300iOp::m_NextInstruction = NORMAL; R4300iOp::m_NextInstruction = NORMAL;
if (CheckTimer) if (CheckTimer)
@ -449,9 +447,9 @@ void CInterpreterCPU::ExecuteOps(int Cycles)
R4300iOp::m_NextInstruction = NORMAL; R4300iOp::m_NextInstruction = NORMAL;
} }
} }
} __except( g_MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation()) ) }
__except( g_MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation()) )
{ {
g_Notify->DisplayError(GS(MSG_UNKNOWN_MEM_ACTION)); g_Notify->FatalError(GS(MSG_UNKNOWN_MEM_ACTION));
ExitThread(0);
} }
} }

View File

@ -9,9 +9,8 @@
* * * *
****************************************************************************/ ****************************************************************************/
#include "stdafx.h" #include "stdafx.h"
//#include "../C Core/Logging.h"
bool DelaySlotEffectsCompare ( DWORD PC, DWORD Reg1, DWORD Reg2 ); bool DelaySlotEffectsCompare ( uint32_t PC, uint32_t Reg1, uint32_t Reg2 );
#define ADDRESS_ERROR_EXCEPTION(Address,FromRead) \ #define ADDRESS_ERROR_EXCEPTION(Address,FromRead) \
g_Reg->DoAddressError(m_NextInstruction == JUMP,Address,FromRead);\ g_Reg->DoAddressError(m_NextInstruction == JUMP,Address,FromRead);\
@ -626,7 +625,6 @@ R4300iOp32::Func * R4300iOp32::BuildInterpreter()
return Jump_Opcode; return Jump_Opcode;
} }
/************************* Opcode functions *************************/ /************************* Opcode functions *************************/
void R4300iOp32::JAL() void R4300iOp32::JAL()
{ {
@ -645,7 +643,7 @@ void R4300iOp32::BEQ()
m_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
if (_GPR[m_Opcode.rs].W[0] == _GPR[m_Opcode.rt].W[0]) if (_GPR[m_Opcode.rs].W[0] == _GPR[m_Opcode.rt].W[0])
{ {
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{ {
if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt))
@ -665,7 +663,7 @@ void R4300iOp32::BNE()
m_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
if (_GPR[m_Opcode.rs].W[0] != _GPR[m_Opcode.rt].W[0]) if (_GPR[m_Opcode.rs].W[0] != _GPR[m_Opcode.rt].W[0])
{ {
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{ {
if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt))
@ -684,7 +682,7 @@ void R4300iOp32::BLEZ() {
m_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
if (_GPR[m_Opcode.rs].W[0] <= 0) if (_GPR[m_Opcode.rs].W[0] <= 0)
{ {
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{ {
if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0))
@ -704,7 +702,7 @@ void R4300iOp32::BGTZ()
m_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
if (_GPR[m_Opcode.rs].W[0] > 0) if (_GPR[m_Opcode.rs].W[0] > 0)
{ {
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{ {
if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0))
@ -724,10 +722,10 @@ void R4300iOp32::ADDI()
#ifdef Interpreter_StackTest #ifdef Interpreter_StackTest
if (m_Opcode.rs == 29 && m_Opcode.rt == 29) if (m_Opcode.rs == 29 && m_Opcode.rt == 29)
{ {
StackValue += (short)m_Opcode.immediate; StackValue += (int16_t)m_Opcode.immediate;
} }
#endif #endif
_GPR[m_Opcode.rt].W[0] = (_GPR[m_Opcode.rs].W[0] + ((short)m_Opcode.immediate)); _GPR[m_Opcode.rt].W[0] = (_GPR[m_Opcode.rs].W[0] + ((int16_t)m_Opcode.immediate));
#ifdef Interpreter_StackTest #ifdef Interpreter_StackTest
if (m_Opcode.rt == 29 && m_Opcode.rs != 29) if (m_Opcode.rt == 29 && m_Opcode.rs != 29)
{ {
@ -741,10 +739,10 @@ void R4300iOp32::ADDIU()
#ifdef Interpreter_StackTest #ifdef Interpreter_StackTest
if (m_Opcode.rs == 29 && m_Opcode.rt == 29) if (m_Opcode.rs == 29 && m_Opcode.rt == 29)
{ {
StackValue += (short)m_Opcode.immediate; StackValue += (int16_t)m_Opcode.immediate;
} }
#endif #endif
_GPR[m_Opcode.rt].W[0] = (_GPR[m_Opcode.rs].W[0] + ((short)m_Opcode.immediate)); _GPR[m_Opcode.rt].W[0] = (_GPR[m_Opcode.rs].W[0] + ((int16_t)m_Opcode.immediate));
#ifdef Interpreter_StackTest #ifdef Interpreter_StackTest
if (m_Opcode.rt == 29 && m_Opcode.rs != 29) if (m_Opcode.rt == 29 && m_Opcode.rs != 29)
{ {
@ -755,7 +753,7 @@ void R4300iOp32::ADDIU()
void R4300iOp32::SLTI() void R4300iOp32::SLTI()
{ {
if (_GPR[m_Opcode.rs].W[0] < (__int64)((short)m_Opcode.immediate)) if (_GPR[m_Opcode.rs].W[0] < (int64_t)((int16_t)m_Opcode.immediate))
{ {
_GPR[m_Opcode.rt].W[0] = 1; _GPR[m_Opcode.rt].W[0] = 1;
} }
@ -767,11 +765,11 @@ void R4300iOp32::SLTI()
void R4300iOp32::SLTIU() void R4300iOp32::SLTIU()
{ {
int imm32 = (short)m_Opcode.immediate; int32_t imm32 = (int16_t)m_Opcode.immediate;
__int64 imm64; int64_t imm64;
imm64 = imm32; imm64 = imm32;
_GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rs].UW[0] < (unsigned __int64)imm64?1:0; _GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rs].UW[0] < (uint64_t)imm64?1:0;
} }
void R4300iOp32::ANDI() void R4300iOp32::ANDI()
@ -791,7 +789,7 @@ void R4300iOp32::XORI()
void R4300iOp32::LUI() void R4300iOp32::LUI()
{ {
_GPR[m_Opcode.rt].W[0] = (long)((short)m_Opcode.offset << 16); _GPR[m_Opcode.rt].W[0] = (int32_t)((int16_t)m_Opcode.offset << 16);
#ifdef Interpreter_StackTest #ifdef Interpreter_StackTest
if (m_Opcode.rt == 29) if (m_Opcode.rt == 29)
{ {
@ -805,7 +803,7 @@ void R4300iOp32::BEQL()
if (_GPR[m_Opcode.rs].W[0] == _GPR[m_Opcode.rt].W[0]) if (_GPR[m_Opcode.rs].W[0] == _GPR[m_Opcode.rt].W[0])
{ {
m_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{ {
if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt))
@ -826,7 +824,7 @@ void R4300iOp32::BNEL()
if (_GPR[m_Opcode.rs].W[0] != _GPR[m_Opcode.rt].W[0]) if (_GPR[m_Opcode.rs].W[0] != _GPR[m_Opcode.rt].W[0])
{ {
m_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{ {
if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt))
@ -847,7 +845,7 @@ void R4300iOp32::BLEZL()
if (_GPR[m_Opcode.rs].W[0] <= 0) if (_GPR[m_Opcode.rs].W[0] <= 0)
{ {
m_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{ {
if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0))
@ -868,7 +866,7 @@ void R4300iOp32::BGTZL()
if (_GPR[m_Opcode.rs].W[0] > 0) if (_GPR[m_Opcode.rs].W[0] > 0)
{ {
m_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{ {
if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0))
@ -886,7 +884,7 @@ void R4300iOp32::BGTZL()
void R4300iOp32::LB() void R4300iOp32::LB()
{ {
DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset;
if (!g_MMU->LB_VAddr(Address,_GPR[m_Opcode.rt].UB[0])) if (!g_MMU->LB_VAddr(Address,_GPR[m_Opcode.rt].UB[0]))
{ {
if (bShowTLBMisses()) if (bShowTLBMisses())
@ -903,7 +901,7 @@ void R4300iOp32::LB()
void R4300iOp32::LH() void R4300iOp32::LH()
{ {
DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset;
if ((Address & 1) != 0) if ((Address & 1) != 0)
{ {
ADDRESS_ERROR_EXCEPTION(Address, true); ADDRESS_ERROR_EXCEPTION(Address, true);
@ -924,12 +922,12 @@ void R4300iOp32::LH()
void R4300iOp32::LWL() void R4300iOp32::LWL()
{ {
DWORD Offset, Address, Value; uint32_t Offset, Address, Value;
Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset;
Offset = Address & 3; Offset = Address & 3;
if (!g_MMU->LW_VAddr((Address & ~3),(uint32_t &)Value)) if (!g_MMU->LW_VAddr((Address & ~3),Value))
{ {
if (bShowTLBMisses()) if (bShowTLBMisses())
{ {
@ -939,13 +937,13 @@ void R4300iOp32::LWL()
return; return;
} }
_GPR[m_Opcode.rt].W[0] = (int)(_GPR[m_Opcode.rt].W[0] & LWL_MASK[Offset]); _GPR[m_Opcode.rt].W[0] = (int32_t)(_GPR[m_Opcode.rt].W[0] & LWL_MASK[Offset]);
_GPR[m_Opcode.rt].W[0] += (int)(Value << LWL_SHIFT[Offset]); _GPR[m_Opcode.rt].W[0] += (int32_t)(Value << LWL_SHIFT[Offset]);
} }
void R4300iOp32::LW() void R4300iOp32::LW()
{ {
DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset;
if ((Address & 3) != 0) if ((Address & 3) != 0)
{ {
ADDRESS_ERROR_EXCEPTION(Address, true); ADDRESS_ERROR_EXCEPTION(Address, true);
@ -956,7 +954,7 @@ void R4300iOp32::LW()
Log_LW((*_PROGRAM_COUNTER),Address); Log_LW((*_PROGRAM_COUNTER),Address);
} }
if (!g_MMU->LW_VAddr(Address,(uint32_t &)_GPR[m_Opcode.rt].UW[0])) if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0]))
{ {
if (bShowTLBMisses()) if (bShowTLBMisses())
{ {
@ -972,7 +970,7 @@ void R4300iOp32::LW()
void R4300iOp32::LBU() void R4300iOp32::LBU()
{ {
DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset;
if (!g_MMU->LB_VAddr(Address,_GPR[m_Opcode.rt].UB[0])) if (!g_MMU->LB_VAddr(Address,_GPR[m_Opcode.rt].UB[0]))
{ {
if (bShowTLBMisses()) if (bShowTLBMisses())
@ -989,7 +987,7 @@ void R4300iOp32::LBU()
void R4300iOp32::LHU() void R4300iOp32::LHU()
{ {
DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset;
if ((Address & 1) != 0) if ((Address & 1) != 0)
{ {
ADDRESS_ERROR_EXCEPTION(Address, true); ADDRESS_ERROR_EXCEPTION(Address, true);
@ -1010,12 +1008,12 @@ void R4300iOp32::LHU()
void R4300iOp32::LWR() void R4300iOp32::LWR()
{ {
DWORD Offset, Address, Value; uint32_t Offset, Address, Value;
Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset;
Offset = Address & 3; Offset = Address & 3;
if (!g_MMU->LW_VAddr((Address & ~3),(uint32_t &)Value)) if (!g_MMU->LW_VAddr((Address & ~3),Value))
{ {
g_Notify->BreakPoint(__FILEW__,__LINE__); g_Notify->BreakPoint(__FILEW__,__LINE__);
if (bShowTLBMisses()) if (bShowTLBMisses())
@ -1025,19 +1023,19 @@ void R4300iOp32::LWR()
return; return;
} }
_GPR[m_Opcode.rt].W[0] = (int)(_GPR[m_Opcode.rt].W[0] & LWR_MASK[Offset]); _GPR[m_Opcode.rt].W[0] = (int32_t)(_GPR[m_Opcode.rt].W[0] & LWR_MASK[Offset]);
_GPR[m_Opcode.rt].W[0] += (int)(Value >> LWR_SHIFT[Offset]); _GPR[m_Opcode.rt].W[0] += (int32_t)(Value >> LWR_SHIFT[Offset]);
} }
void R4300iOp32::LWU() void R4300iOp32::LWU()
{ {
DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset;
if ((Address & 3) != 0) if ((Address & 3) != 0)
{ {
ADDRESS_ERROR_EXCEPTION(Address, true); ADDRESS_ERROR_EXCEPTION(Address, true);
} }
if (!g_MMU->LW_VAddr(Address,(uint32_t &)_GPR[m_Opcode.rt].UW[0])) if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0]))
{ {
if (bShowTLBMisses()) if (bShowTLBMisses())
{ {
@ -1051,16 +1049,15 @@ void R4300iOp32::LWU()
} }
} }
void R4300iOp32::LL() void R4300iOp32::LL()
{ {
DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset;
if ((Address & 3) != 0) if ((Address & 3) != 0)
{ {
ADDRESS_ERROR_EXCEPTION(Address, true); ADDRESS_ERROR_EXCEPTION(Address, true);
} }
if (!g_MMU->LW_VAddr(Address,(uint32_t &)_GPR[m_Opcode.rt].UW[0])) if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0]))
{ {
if (bShowTLBMisses()) if (bShowTLBMisses())
{ {
@ -1083,7 +1080,7 @@ void R4300iOp32::SPECIAL_SLL()
void R4300iOp32::SPECIAL_SRL() void R4300iOp32::SPECIAL_SRL()
{ {
_GPR[m_Opcode.rd].W[0] = (int)(_GPR[m_Opcode.rt].UW[0] >> m_Opcode.sa); _GPR[m_Opcode.rd].W[0] = (int32_t)(_GPR[m_Opcode.rt].UW[0] >> m_Opcode.sa);
} }
void R4300iOp32::SPECIAL_SRA() void R4300iOp32::SPECIAL_SRA()
@ -1098,7 +1095,7 @@ void R4300iOp32::SPECIAL_SLLV()
void R4300iOp32::SPECIAL_SRLV() void R4300iOp32::SPECIAL_SRLV()
{ {
_GPR[m_Opcode.rd].W[0] = (int)(_GPR[m_Opcode.rt].UW[0] >> (_GPR[m_Opcode.rs].UW[0] & 0x1F)); _GPR[m_Opcode.rd].W[0] = (int32_t)(_GPR[m_Opcode.rt].UW[0] >> (_GPR[m_Opcode.rs].UW[0] & 0x1F));
} }
void R4300iOp32::SPECIAL_SRAV() void R4300iOp32::SPECIAL_SRAV()
@ -1110,7 +1107,7 @@ void R4300iOp32::SPECIAL_JALR()
{ {
m_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
m_JumpToLocation = _GPR[m_Opcode.rs].UW[0]; m_JumpToLocation = _GPR[m_Opcode.rs].UW[0];
_GPR[m_Opcode.rd].W[0] = (long)((*_PROGRAM_COUNTER) + 8); _GPR[m_Opcode.rd].W[0] = (int32_t)((*_PROGRAM_COUNTER) + 8);
m_TestTimer = true; m_TestTimer = true;
} }
@ -1189,12 +1186,12 @@ void R4300iOp32::SPECIAL_TEQ()
void R4300iOp32::SPECIAL_DSRL32() void R4300iOp32::SPECIAL_DSRL32()
{ {
_GPR[m_Opcode.rd].UW[0] = (DWORD)(_GPR[m_Opcode.rt].UDW >> (m_Opcode.sa + 32)); _GPR[m_Opcode.rd].UW[0] = (uint32_t)(_GPR[m_Opcode.rt].UDW >> (m_Opcode.sa + 32));
} }
void R4300iOp32::SPECIAL_DSRA32() void R4300iOp32::SPECIAL_DSRA32()
{ {
_GPR[m_Opcode.rd].W[0] = (long)(_GPR[m_Opcode.rt].DW >> (m_Opcode.sa + 32)); _GPR[m_Opcode.rd].W[0] = (int32_t)(_GPR[m_Opcode.rt].DW >> (m_Opcode.sa + 32));
} }
/********************** R4300i OpCodes: RegImm **********************/ /********************** R4300i OpCodes: RegImm **********************/
@ -1203,7 +1200,7 @@ void R4300iOp32::REGIMM_BLTZ()
m_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
if (_GPR[m_Opcode.rs].W[0] < 0) if (_GPR[m_Opcode.rs].W[0] < 0)
{ {
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{ {
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0))
@ -1223,7 +1220,7 @@ void R4300iOp32::REGIMM_BGEZ()
m_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
if (_GPR[m_Opcode.rs].W[0] >= 0) if (_GPR[m_Opcode.rs].W[0] >= 0)
{ {
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{ {
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0))
@ -1243,7 +1240,7 @@ void R4300iOp32::REGIMM_BLTZL()
if (_GPR[m_Opcode.rs].W[0] < 0) if (_GPR[m_Opcode.rs].W[0] < 0)
{ {
m_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{ {
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0))
@ -1264,7 +1261,7 @@ void R4300iOp32::REGIMM_BGEZL()
if (_GPR[m_Opcode.rs].W[0] >= 0) if (_GPR[m_Opcode.rs].W[0] >= 0)
{ {
m_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{ {
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0))
@ -1285,7 +1282,7 @@ void R4300iOp32::REGIMM_BLTZAL()
m_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
if (_GPR[m_Opcode.rs].W[0] < 0) if (_GPR[m_Opcode.rs].W[0] < 0)
{ {
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{ {
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0))
@ -1298,7 +1295,7 @@ void R4300iOp32::REGIMM_BLTZAL()
{ {
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
} }
_GPR[31].W[0]= (long)((*_PROGRAM_COUNTER) + 8); _GPR[31].W[0]= (int32_t)((*_PROGRAM_COUNTER) + 8);
} }
void R4300iOp32::REGIMM_BGEZAL() void R4300iOp32::REGIMM_BGEZAL()
@ -1306,7 +1303,7 @@ void R4300iOp32::REGIMM_BGEZAL()
m_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
if (_GPR[m_Opcode.rs].W[0] >= 0) if (_GPR[m_Opcode.rs].W[0] >= 0)
{ {
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{ {
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0))
@ -1319,10 +1316,12 @@ void R4300iOp32::REGIMM_BGEZAL()
{ {
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
} }
_GPR[31].W[0] = (long)((*_PROGRAM_COUNTER) + 8); _GPR[31].W[0] = (int32_t)((*_PROGRAM_COUNTER) + 8);
} }
/************************** COP0 functions **************************/ /************************** COP0 functions **************************/
void R4300iOp32::COP0_MF() { void R4300iOp32::COP0_MF()
{
if (g_LogOptions.LogCP0reads) if (g_LogOptions.LogCP0reads)
{ {
LogMessage("%08X: R4300i Read from %s (0x%08X)", (*_PROGRAM_COUNTER), CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); LogMessage("%08X: R4300i Read from %s (0x%08X)", (*_PROGRAM_COUNTER), CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]);
@ -1332,7 +1331,7 @@ void R4300iOp32::COP0_MF() {
{ {
g_SystemTimer->UpdateTimers(); g_SystemTimer->UpdateTimers();
} }
_GPR[m_Opcode.rt].W[0] = (int)_CP0[m_Opcode.rd]; _GPR[m_Opcode.rt].W[0] = (int32_t)_CP0[m_Opcode.rd];
} }
void R4300iOp32::COP0_MT() void R4300iOp32::COP0_MT()
@ -1412,7 +1411,7 @@ void R4300iOp32::COP0_MT()
void R4300iOp32::COP1_MF() void R4300iOp32::COP1_MF()
{ {
TEST_COP1_USABLE_EXCEPTION TEST_COP1_USABLE_EXCEPTION
_GPR[m_Opcode.rt].W[0] = *(int *)_FPR_S[m_Opcode.fs]; _GPR[m_Opcode.rt].W[0] = *(int32_t *)_FPR_S[m_Opcode.fs];
} }
void R4300iOp32::COP1_CF() void R4300iOp32::COP1_CF()
@ -1423,11 +1422,11 @@ void R4300iOp32::COP1_CF()
if (g_Settings->LoadBool(Debugger_Enabled)) { g_Notify->DisplayError(L"CFC1 what register are you writing to ?"); } if (g_Settings->LoadBool(Debugger_Enabled)) { g_Notify->DisplayError(L"CFC1 what register are you writing to ?"); }
return; return;
} }
_GPR[m_Opcode.rt].W[0] = (int)_FPCR[m_Opcode.fs]; _GPR[m_Opcode.rt].W[0] = (int32_t)_FPCR[m_Opcode.fs];
} }
void R4300iOp32::COP1_DMT() void R4300iOp32::COP1_DMT()
{ {
TEST_COP1_USABLE_EXCEPTION TEST_COP1_USABLE_EXCEPTION
*(__int64 *)_FPR_D[m_Opcode.fs] = _GPR[m_Opcode.rt].W[0]; *(int64_t *)_FPR_D[m_Opcode.fs] = _GPR[m_Opcode.rt].W[0];
} }

File diff suppressed because it is too large Load Diff

View File

@ -64,7 +64,6 @@ public:
static void SDC1(); static void SDC1();
static void SD(); static void SD();
/********************** R4300i OpCodes: Special **********************/ /********************** R4300i OpCodes: Special **********************/
static void SPECIAL_SLL(); static void SPECIAL_SLL();
static void SPECIAL_SRL(); static void SPECIAL_SRL();
@ -200,13 +199,12 @@ public:
/************************** Other functions **************************/ /************************** Other functions **************************/
static void UnknownOpcode(); static void UnknownOpcode();
static Func* BuildInterpreter(); static Func* BuildInterpreter();
static bool m_TestTimer; static bool m_TestTimer;
static DWORD m_NextInstruction; static uint32_t m_NextInstruction;
static OPCODE m_Opcode; static OPCODE m_Opcode;
static DWORD m_JumpToLocation; static uint32_t m_JumpToLocation;
protected: protected:
static void SPECIAL(); static void SPECIAL();
@ -232,7 +230,6 @@ protected:
static Func Jump_CoP1_W[64]; static Func Jump_CoP1_W[64];
static Func Jump_CoP1_L[64]; static Func Jump_CoP1_L[64];
static const DWORD SWL_MASK[4], SWR_MASK[4], LWL_MASK[4], LWR_MASK[4]; static const uint32_t SWL_MASK[4], SWR_MASK[4], LWL_MASK[4], LWR_MASK[4];
static const int SWL_SHIFT[4], SWR_SHIFT[4], LWL_SHIFT[4], LWR_SHIFT[4]; static const int32_t SWL_SHIFT[4], SWR_SHIFT[4], LWL_SHIFT[4], LWR_SHIFT[4];
}; };

View File

@ -10,7 +10,7 @@
****************************************************************************/ ****************************************************************************/
#include "stdafx.h" #include "stdafx.h"
bool DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2); bool DelaySlotEffectsCompare (uint32_t PC, uint32_t Reg1, uint32_t Reg2);
CCodeBlock::CCodeBlock(DWORD VAddrEnter, BYTE * RecompPos) : CCodeBlock::CCodeBlock(DWORD VAddrEnter, BYTE * RecompPos) :
m_VAddrEnter(VAddrEnter), m_VAddrEnter(VAddrEnter),

View File

@ -12,7 +12,7 @@
void InPermLoop(); void InPermLoop();
bool DelaySlotEffectsCompare(DWORD PC, DWORD Reg1, DWORD Reg2); bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2);
static bool DelaySlotEffectsJump(DWORD JumpPC) { static bool DelaySlotEffectsJump(DWORD JumpPC) {
OPCODE Command; OPCODE Command;

View File

@ -14,7 +14,7 @@
#define CHECKED_BUILD 1 #define CHECKED_BUILD 1
#endif #endif
bool DelaySlotEffectsCompare ( DWORD PC, DWORD Reg1, DWORD Reg2 ); bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2);
LoopAnalysis::LoopAnalysis(CCodeBlock * CodeBlock, CCodeSection * Section) : LoopAnalysis::LoopAnalysis(CCodeBlock * CodeBlock, CCodeSection * Section) :
m_EnterSection(Section), m_EnterSection(Section),

View File

@ -38,7 +38,7 @@ void CRecompilerOps::CompileWriteTLBMiss (x86Reg AddressReg, x86Reg LookUpReg )
m_Section->CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, CExitInfo::TLBWriteMiss, false, JeLabel32); m_Section->CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, CExitInfo::TLBWriteMiss, false, JeLabel32);
} }
bool DelaySlotEffectsCompare ( DWORD PC, DWORD Reg1, DWORD Reg2 ); bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2);
/************************** Branch functions ************************/ /************************** Branch functions ************************/
void CRecompilerOps::Compile_Branch (CRecompilerOps::BranchFunction CompareFunc, BRANCH_TYPE BranchType, bool Link) void CRecompilerOps::Compile_Branch (CRecompilerOps::BranchFunction CompareFunc, BRANCH_TYPE BranchType, bool Link)