More refactoring of the remaining C code

This commit is contained in:
Emmet Young 2012-09-30 22:24:07 +10:00
parent 5c8cad4b5d
commit 90b0f6d60d
10 changed files with 56 additions and 56 deletions

View File

@ -5,7 +5,7 @@
//settings
BOOL g_HaveDebugger = false, g_AudioSignal = false;
DWORD g_RomFileSize = 0, g_CountPerOp = 2, g_ViRefreshRate = 1500;
DWORD g_CountPerOp = 2, g_ViRefreshRate = 1500;
enum CPU_TYPE g_CPU_Type;
enum SAVE_CHIP_TYPE g_SaveUsing;

View File

@ -26,7 +26,7 @@ void CloseSaveChips ( void );
//settings
extern BOOL g_HaveDebugger, g_AudioSignal;
extern DWORD g_RomFileSize, g_CountPerOp;
extern DWORD g_CountPerOp;
extern enum CPU_TYPE g_CPU_Type;
extern enum SAVE_CHIP_TYPE g_SaveUsing;

View File

@ -357,7 +357,7 @@ void Log_LW (DWORD PC, DWORD VAddr) {
LogMessage("%08X: read word from Pif Ram at 0x%X (%08X)",PC,VAddr - 0xBFC007C0, Value);
return;
}
if ( VAddr >= 0xB0000040 && ((VAddr - 0xB0000000) < g_RomFileSize)) { return; }
if ( VAddr >= 0xB0000040 && ((VAddr - 0xB0000000) < _Rom->GetRomSize())) { return; }
if ( VAddr >= 0xB0000000 && VAddr < 0xB0000040) {
if (!LogOptions.LogRomHeader) { return; }

View File

@ -167,7 +167,32 @@ int DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2) {
return FALSE;
}
void InPermLoop (void) {
CInterpreterCPU::CInterpreterCPU ()
{
}
CInterpreterCPU::~CInterpreterCPU()
{
}
void CInterpreterCPU::BuildCPU (void )
{
R4300iOp::m_TestTimer = FALSE;
R4300iOp::m_NextInstruction = NORMAL;
R4300iOp::m_JumpToLocation = 0;
m_CountPerOp = _Settings->LoadDword(Game_CounterFactor);
if (_Settings->LoadBool(Game_32Bit))
{
m_R4300i_Opcode = R4300iOp32::BuildInterpreter();
} else {
m_R4300i_Opcode = R4300iOp::BuildInterpreter();
}
}
void CInterpreterCPU::InPermLoop (void) {
// *** Changed ***/
//if (CPU_Type == CPU_SyncCores) { SyncRegisters.CP0[9] +=5; }
@ -191,37 +216,12 @@ void InPermLoop (void) {
/* check RDP running */
if (*_NextTimer > 0) {
*_NextTimer = 0 - g_CountPerOp;
*_NextTimer = 0 - m_CountPerOp;
_SystemTimer->UpdateTimers();
}
}
}
CInterpreterCPU::CInterpreterCPU ()
{
}
CInterpreterCPU::~CInterpreterCPU()
{
}
void CInterpreterCPU::BuildCPU (void )
{
R4300iOp::m_TestTimer = FALSE;
R4300iOp::m_NextInstruction = NORMAL;
R4300iOp::m_JumpToLocation = 0;
m_CountPerOp = _Settings->LoadDword(Game_CounterFactor);
if (_Settings->LoadBool(Game_32Bit))
{
m_R4300i_Opcode = R4300iOp32::BuildInterpreter();
} else {
m_R4300i_Opcode = R4300iOp::BuildInterpreter();
}
}
void CInterpreterCPU::ExecuteCPU (void )
{
bool & Done = _System->m_EndEmulation;
@ -282,7 +282,7 @@ void CInterpreterCPU::ExecuteCPU (void )
case PERMLOOP_DELAY_DONE:
PROGRAM_COUNTER = JumpToLocation;
R4300iOp::m_NextInstruction = NORMAL;
InPermLoop();
CInterpreterCPU::InPermLoop();
_SystemTimer->TimerDone();
if (bDoSomething)
{
@ -387,7 +387,7 @@ void CInterpreterCPU::ExecuteOps ( int Cycles )
case PERMLOOP_DELAY_DONE:
PROGRAM_COUNTER = JumpToLocation;
R4300iOp::m_NextInstruction = NORMAL;
InPermLoop();
CInterpreterCPU::InPermLoop();
_SystemTimer->TimerDone();
if (DoSomething)
{

View File

@ -8,7 +8,7 @@ public:
static void BuildCPU ( void );
static void ExecuteCPU ( void );
static void ExecuteOps ( int Cycles );
static void InPermLoop ( void );
private:
static R4300iOp::Func * m_R4300i_Opcode;
static DWORD m_CountPerOp;

View File

@ -1,7 +1,6 @@
#include "stdafx.h"
//#include "../C Core/Logging.h"
void InPermLoop ( void );
int DelaySlotEffectsCompare ( DWORD PC, DWORD Reg1, DWORD Reg2 );
#define ADDRESS_ERROR_EXCEPTION(Address,FromRead) \
@ -1095,7 +1094,7 @@ void R4300iOp32::REGIMM_BLTZ (void) {
{
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0))
{
InPermLoop();
CInterpreterCPU::InPermLoop();
}
}
} else {
@ -1111,7 +1110,7 @@ void R4300iOp32::REGIMM_BGEZ (void) {
{
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0))
{
InPermLoop();
CInterpreterCPU::InPermLoop();
}
}
} else {
@ -1127,7 +1126,7 @@ void R4300iOp32::REGIMM_BLTZL (void) {
{
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0))
{
InPermLoop();
CInterpreterCPU::InPermLoop();
}
}
} else {
@ -1144,7 +1143,7 @@ void R4300iOp32::REGIMM_BGEZL (void) {
{
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0))
{
InPermLoop();
CInterpreterCPU::InPermLoop();
}
}
} else {
@ -1161,7 +1160,7 @@ void R4300iOp32::REGIMM_BLTZAL (void) {
{
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0))
{
InPermLoop();
CInterpreterCPU::InPermLoop();
}
}
} else {
@ -1178,7 +1177,7 @@ void R4300iOp32::REGIMM_BGEZAL (void) {
{
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0))
{
InPermLoop();
CInterpreterCPU::InPermLoop();
}
}
} else {

View File

@ -1689,7 +1689,7 @@ void R4300iOp::REGIMM_BLTZ (void) {
{
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0))
{
InPermLoop();
CInterpreterCPU::InPermLoop();
}
}
} else {
@ -1705,7 +1705,7 @@ void R4300iOp::REGIMM_BGEZ (void) {
{
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0))
{
InPermLoop();
CInterpreterCPU::InPermLoop();
}
}
} else {
@ -1721,7 +1721,7 @@ void R4300iOp::REGIMM_BLTZL (void) {
{
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0))
{
InPermLoop();
CInterpreterCPU::InPermLoop();
}
}
} else {
@ -1738,7 +1738,7 @@ void R4300iOp::REGIMM_BGEZL (void) {
{
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0))
{
InPermLoop();
CInterpreterCPU::InPermLoop();
}
}
} else {
@ -1755,7 +1755,7 @@ void R4300iOp::REGIMM_BLTZAL (void) {
{
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0))
{
InPermLoop();
CInterpreterCPU::InPermLoop();
}
}
} else {
@ -1772,7 +1772,7 @@ void R4300iOp::REGIMM_BGEZAL (void) {
{
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0))
{
InPermLoop();
CInterpreterCPU::InPermLoop();
}
}
} else {

View File

@ -117,20 +117,20 @@ void CDMA::PI_DMA_WRITE (void) {
#ifdef ROM_IN_MAPSPACE
if (WrittenToRom) {
DWORD OldProtect;
VirtualProtect(ROM,g_RomFileSize,PAGE_READONLY, &OldProtect);
VirtualProtect(ROM,m_RomFileSize,PAGE_READONLY, &OldProtect);
}
#endif
#endif
BYTE * ROM = _Rom->GetRomAddress();
BYTE * RDRAM = _MMU->Rdram();
_Reg->PI_CART_ADDR_REG -= 0x10000000;
if (_Reg->PI_CART_ADDR_REG + _Reg->PI_WR_LEN_REG + 1 < g_RomFileSize) {
if (_Reg->PI_CART_ADDR_REG + _Reg->PI_WR_LEN_REG + 1 < _Rom->GetRomSize()) {
for (i = 0; i < _Reg->PI_WR_LEN_REG + 1; i ++) {
*(RDRAM+((_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM+((_Reg->PI_CART_ADDR_REG + i) ^ 3));
}
} else {
DWORD Len;
Len = g_RomFileSize - _Reg->PI_CART_ADDR_REG;
Len = _Rom->GetRomSize() - _Reg->PI_CART_ADDR_REG;
for (i = 0; i < Len; i ++) {
*(RDRAM+((_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM+((_Reg->PI_CART_ADDR_REG + i) ^ 3));
}

View File

@ -778,7 +778,8 @@ void CN64System::ExecuteCPU ( void )
m_EndEmulation = false;
_Notify->RefreshMenu();
g_RomFileSize = _Rom->GetRomSize();
//Check me
// _Rom->m_RomFileSize = _Rom->GetRomSize();
CC_Core C_Core;
C_Core.SetSettings();

View File

@ -393,7 +393,7 @@ void CCodeSection::GenerateSectionLinkage (void)
MoveConstToVariable(CompilePC(),_PROGRAM_COUNTER,"PROGRAM_COUNTER");
m_Jump.RegSet.WriteBackRegisters();
UpdateCounters(m_Jump.RegSet,false, true);
Call_Direct(InPermLoop,"InPermLoop");
Call_Direct(AddressOf(CInterpreterCPU::InPermLoop),"CInterpreterCPU::InPermLoop");
MoveConstToX86reg((DWORD)_SystemTimer,x86_ECX);
Call_Direct(AddressOf(&CSystemTimer::TimerDone),"CSystemTimer::TimerDone");
CPU_Message("CompileSystemCheck 3");
@ -463,7 +463,7 @@ void CCodeSection::GenerateSectionLinkage (void)
}
if (JumpInfo[i]->TargetPC <= CompilePC()) {
if (JumpInfo[i]->PermLoop) {
CPU_Message("PermLoop *** 1");
CPU_Message("PermLoop *** 1");
MoveConstToVariable(JumpInfo[i]->TargetPC,_PROGRAM_COUNTER,"PROGRAM_COUNTER");
UpdateCounters(JumpInfo[i]->RegSet,false, true);
if (_SyncSystem) {
@ -472,7 +472,7 @@ void CCodeSection::GenerateSectionLinkage (void)
}
//JumpInfo[i]->RegSet.BlockCycleCount() -= CountPerOp();
Call_Direct(InPermLoop,"InPermLoop");
Call_Direct(AddressOf(CInterpreterCPU::InPermLoop),"CInterpreterCPU::InPermLoop");
//JumpInfo[i]->RegSet.BlockCycleCount() += CountPerOp();
UpdateCounters(JumpInfo[i]->RegSet,true,true);
CPU_Message("CompileSystemCheck 4");
@ -509,7 +509,7 @@ void CCodeSection::GenerateSectionLinkage (void)
CPU_Message("PermLoop *** 2");
MoveConstToVariable(JumpInfo[i]->TargetPC,_PROGRAM_COUNTER,"PROGRAM_COUNTER");
UpdateCounters(JumpInfo[i]->RegSet,false, true);
Call_Direct(InPermLoop,"InPermLoop");
Call_Direct(AddressOf(CInterpreterCPU::InPermLoop),"CInterpreterCPU::InPermLoop");
UpdateCounters(JumpInfo[i]->RegSet,true,true);
CPU_Message("CompileSystemCheck 6");
CompileSystemCheck(-1,JumpInfo[i]->RegSet);
@ -575,9 +575,9 @@ void CCodeSection::GenerateSectionLinkage (void)
if (JumpInfo[i]->TargetPC <= JumpInfo[i]->JumpPC) {
UpdateCounters(JumpInfo[i]->RegSet,true,true);
if (JumpInfo[i]->PermLoop) {
CPU_Message("PermLoop *** 3");
CPU_Message("PermLoop *** 3");
MoveConstToVariable(JumpInfo[i]->TargetPC,_PROGRAM_COUNTER,"PROGRAM_COUNTER");
Call_Direct(InPermLoop,"InPermLoop");
Call_Direct(AddressOf(CInterpreterCPU::InPermLoop),"CInterpreterCPU::InPermLoop");
CPU_Message("CompileSystemCheck 8");
CompileSystemCheck(-1,JumpInfo[i]->RegSet);
} else {