git-svn-id: https://localhost/svn/Project64/trunk@42 111125ac-702d-7242-af9c-5ba8ae61c1ef

This commit is contained in:
zilmar 2010-07-05 11:29:46 +00:00
parent edcaea006b
commit 0db60d35c2
18 changed files with 194 additions and 314 deletions

View File

@ -8,7 +8,7 @@
BOOL g_ShowCPUPer = false, g_ShowTLBMisses = false, g_UseTlb = true,
g_HaveDebugger = false, g_AudioSignal = false,
g_UseLinking = false,
g_FixedAudio = false, g_LogX86Code = false;
g_LogX86Code = false;
DWORD g_RomFileSize = 0, g_CountPerOp = 2, g_ViRefreshRate = 1500;
enum CPU_TYPE g_CPU_Type;
enum SAVE_CHIP_TYPE g_SaveUsing;
@ -33,7 +33,6 @@ void CC_Core::SetSettings ( )
g_SaveUsing = (SAVE_CHIP_TYPE)_Settings->LoadDword(Game_SaveChip);
g_AudioSignal = _Settings->LoadBool(Game_RspAudioSignal);
g_CountPerOp = _Settings->LoadDword(Game_CounterFactor);
g_FixedAudio = _Settings->LoadBool(Game_FixedAudio);
g_LogX86Code = _Settings->LoadBool(Debugger_GenerateLogFiles);
g_LookUpMode = (FUNC_LOOKUP_METHOD)_Settings->LoadDword(Game_FuncLookupMode);
g_UseLinking = _Settings->LoadBool(Game_BlockLinking);

View File

@ -65,7 +65,7 @@ DWORD StopTimer ( void );
//settings
extern BOOL g_ShowCPUPer, g_ShowTLBMisses, g_UseTlb,
g_HaveDebugger, g_AudioSignal,
g_UseLinking, g_FixedAudio, g_LogX86Code;
g_UseLinking, g_LogX86Code;
extern DWORD g_RomFileSize, g_CountPerOp;
extern enum CPU_TYPE g_CPU_Type;
extern enum SAVE_CHIP_TYPE g_SaveUsing;

View File

@ -184,9 +184,8 @@ void InPermLoop (void) {
/* check RDP running */
if (*_NextTimer > 0) {
//_Reg->COUNT_REGISTER += *_Timer + 1;
//if (CPU_Type == CPU_SyncCores) { SyncRegisters.CP0[9] += Timers.Timer + 1; }
*_NextTimer = -1;
*_NextTimer = 0 - g_CountPerOp;
_SystemTimer->UpdateTimers();
}
return;
@ -245,8 +244,8 @@ void CInterpreterCPU::ExecuteCPU (void )
//WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s t9: %08X v1: %08X",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER),_GPR[0x19].UW[0],_GPR[0x03].UW[0]);
//WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %d %d",*_PROGRAM_COUNTER,*_NextTimer,_SystemTimer->CurrentType());
}*/
NextTimer -= m_CountPerOp;
m_R4300i_Opcode[ Opcode.op ]();
NextTimer -= m_CountPerOp;
switch (R4300iOp::m_NextInstruction)
{
@ -257,6 +256,10 @@ void CInterpreterCPU::ExecuteCPU (void )
R4300iOp::m_NextInstruction = JUMP;
PROGRAM_COUNTER += 4;
break;
case PERMLOOP_DO_DELAY:
R4300iOp::m_NextInstruction = PERMLOOP_DELAY_DONE;
PROGRAM_COUNTER += 4;
break;
case JUMP:
{
BOOL CheckTimer = (JumpToLocation < PROGRAM_COUNTER || TestTimer);
@ -275,6 +278,19 @@ void CInterpreterCPU::ExecuteCPU (void )
}
}
}
break;
case PERMLOOP_DELAY_DONE:
PROGRAM_COUNTER = JumpToLocation;
R4300iOp::m_NextInstruction = NORMAL;
InPermLoop();
_SystemTimer->TimerDone();
if (bDoSomething)
{
_SystemEvents->ExecuteEvents();
}
break;
default:
_Notify->BreakPoint(__FILE__,__LINE__);
}
} else {
_Reg->DoTLBMiss(R4300iOp::m_NextInstruction == JUMP,PROGRAM_COUNTER);
@ -303,6 +319,7 @@ void CInterpreterCPU::ExecuteOps ( int Cycles )
{
if (Cycles <= 0)
{
_SystemTimer->UpdateTimers();
return;
}
@ -320,9 +337,10 @@ void CInterpreterCPU::ExecuteOps ( int Cycles )
//WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s t9: %08X v1: %08X",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER),_GPR[0x19].UW[0],_GPR[0x03].UW[0]);
//WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %d %d",*_PROGRAM_COUNTER,*_NextTimer,_SystemTimer->CurrentType());
}*/
m_R4300i_Opcode[ Opcode.op ]();
Cycles -= m_CountPerOp;
*_NextTimer -= m_CountPerOp;
m_R4300i_Opcode[ Opcode.op ]();
/*static DWORD TestAddress = 0x80077B0C, TestValue = 0, CurrentValue = 0;
if (_MMU->LW_VAddr(TestAddress, TestValue))
@ -343,6 +361,10 @@ void CInterpreterCPU::ExecuteOps ( int Cycles )
R4300iOp::m_NextInstruction = JUMP;
PROGRAM_COUNTER += 4;
break;
case PERMLOOP_DO_DELAY:
R4300iOp::m_NextInstruction = PERMLOOP_DELAY_DONE;
PROGRAM_COUNTER += 4;
break;
case JUMP:
{
BOOL CheckTimer = (JumpToLocation < PROGRAM_COUNTER || TestTimer);
@ -361,6 +383,19 @@ void CInterpreterCPU::ExecuteOps ( int Cycles )
}
}
}
break;
case PERMLOOP_DELAY_DONE:
PROGRAM_COUNTER = JumpToLocation;
R4300iOp::m_NextInstruction = NORMAL;
InPermLoop();
_SystemTimer->TimerDone();
if (DoSomething)
{
_SystemEvents->ExecuteEvents();
}
break;
default:
_Notify->BreakPoint(__FILE__,__LINE__);
}
} else {
_Reg->DoTLBMiss(R4300iOp::m_NextInstruction == JUMP,PROGRAM_COUNTER);

View File

@ -624,7 +624,7 @@ void R4300iOp32::J (void) {
if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{
InPermLoop();
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
@ -635,7 +635,7 @@ void R4300iOp32::JAL (void) {
if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{
InPermLoop();
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
@ -647,7 +647,7 @@ void R4300iOp32::BEQ (void) {
{
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,m_Opcode.rt))
{
InPermLoop();
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
} else {
@ -663,7 +663,7 @@ void R4300iOp32::BNE (void) {
{
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,m_Opcode.rt))
{
InPermLoop();
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
} else {
@ -679,7 +679,7 @@ void R4300iOp32::BLEZ (void) {
{
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0))
{
InPermLoop();
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
} else {
@ -695,7 +695,7 @@ void R4300iOp32::BGTZ (void) {
{
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0))
{
InPermLoop();
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
} else {
@ -778,7 +778,7 @@ void R4300iOp32::BEQL (void) {
{
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,m_Opcode.rt))
{
InPermLoop();
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
} else {
@ -795,7 +795,7 @@ void R4300iOp32::BNEL (void) {
{
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,m_Opcode.rt))
{
InPermLoop();
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
} else {
@ -812,7 +812,7 @@ void R4300iOp32::BLEZL (void) {
{
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0))
{
InPermLoop();
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
} else {
@ -829,7 +829,7 @@ void R4300iOp32::BGTZL (void) {
{
if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0))
{
InPermLoop();
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
} else {

View File

@ -717,8 +717,7 @@ void TestInterpreterJump (DWORD PC, DWORD TargetPC, int Reg1, int Reg2)
{
if (PC != TargetPC) { return; }
if (DelaySlotEffectsCompare(PC,Reg1,Reg2)) { return; }
InPermLoop();
R4300iOp::m_NextInstruction = DELAY_SLOT;
R4300iOp::m_NextInstruction = PERMLOOP_DO_DELAY;
R4300iOp::m_TestTimer = TRUE;
}
@ -728,7 +727,7 @@ void R4300iOp::J (void) {
m_JumpToLocation = ((*_PROGRAM_COUNTER) & 0xF0000000) + (m_Opcode.target << 2);
if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{
InPermLoop();
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
@ -739,7 +738,7 @@ void R4300iOp::JAL (void) {
if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{
InPermLoop();
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
@ -751,7 +750,7 @@ void R4300iOp::BEQ (void) {
{
if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt))
{
InPermLoop();
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
} else {
@ -767,7 +766,7 @@ void R4300iOp::BNE (void) {
{
if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt))
{
InPermLoop();
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
} else {
@ -783,7 +782,7 @@ void R4300iOp::BLEZ (void) {
{
if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0))
{
InPermLoop();
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
} else {
@ -799,7 +798,7 @@ void R4300iOp::BGTZ (void) {
{
if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0))
{
InPermLoop();
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
} else {
@ -882,7 +881,7 @@ void R4300iOp::BEQL (void) {
{
if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt))
{
InPermLoop();
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
} else {
@ -899,7 +898,7 @@ void R4300iOp::BNEL (void) {
{
if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt))
{
InPermLoop();
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
} else {
@ -916,7 +915,7 @@ void R4300iOp::BLEZL (void) {
{
if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0))
{
InPermLoop();
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
} else {
@ -933,7 +932,7 @@ void R4300iOp::BGTZL (void) {
{
if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0))
{
InPermLoop();
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
} else {
@ -1726,6 +1725,10 @@ void R4300iOp::COP0_MF (void) {
CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]);
}
#endif
if (m_Opcode.rd == 9)
{
_SystemTimer->UpdateTimers();
}
_GPR[m_Opcode.rt].DW = (int)_CP0[m_Opcode.rd];
}

View File

@ -22,7 +22,6 @@ void CAudio::Reset ( void )
DWORD CAudio::GetLength ( void )
{
DWORD TimeLeft = _SystemTimer->GetTimer(CSystemTimer::AiTimer);
WriteTraceF(TraceError,"CAudio::GetLength: TimeLeft = %d m_CountsPerByte = %d BytesLeft = %d",TimeLeft,(int)m_CountsPerByte, (int)(TimeLeft / m_CountsPerByte));
if (TimeLeft > 0)
{
return TimeLeft / m_CountsPerByte;
@ -37,12 +36,8 @@ DWORD CAudio::GetStatus ( void )
void CAudio::LenChanged ( void )
{
if (_Reg->AI_LEN_REG == 0)
if (_Reg->AI_LEN_REG != 0)
{
return;
}
WriteTraceF(TraceError,"CAudio::LenChanged: m_CurrentLength = %d AI_LEN_REG = %d m_CountsPerByte = %d",m_CurrentLength,_Reg->AI_LEN_REG,(int)m_CountsPerByte);
if (m_CurrentLength == 0) {
m_CurrentLength = _Reg->AI_LEN_REG;
_SystemTimer->SetTimer(CSystemTimer::AiTimer,m_CurrentLength * m_CountsPerByte,false);
@ -50,6 +45,13 @@ void CAudio::LenChanged ( void )
m_SecondBuff = _Reg->AI_LEN_REG;
m_Status |= 0x80000000;
}
} else {
_SystemTimer->StopTimer(CSystemTimer::AiTimer);
m_CurrentLength = 0;
m_SecondBuff = 0;
m_Status = 0;
}
if (_Plugins->Audio()->LenChanged != NULL)
{
_Plugins->Audio()->LenChanged();
@ -58,8 +60,6 @@ void CAudio::LenChanged ( void )
void CAudio::TimerDone ( void )
{
WriteTraceF(TraceError,"CAudio::TimerDone: m_SecondBuff = %d",m_SecondBuff);
_Reg->MI_INTR_REG |= MI_INTR_AI;
_Reg->CheckInterrupts();
@ -73,8 +73,6 @@ void CAudio::TimerDone ( void )
void CAudio::SetViIntr ( DWORD VI_INTR_TIME )
{
WriteTraceF(TraceError,"CAudio::SetViIntr: VI_INTR_TIME = %d",VI_INTR_TIME);
double CountsPerSecond = (DWORD)((double)VI_INTR_TIME * m_FramesPerSecond);
if (m_BytesPerSecond != 0)
{
@ -85,8 +83,6 @@ void CAudio::SetViIntr ( DWORD VI_INTR_TIME )
void CAudio::SetFrequency (DWORD Dacrate, DWORD System)
{
WriteTraceF(TraceError,"CAudio::SetFrequency: Dacrate = %d System = %d",Dacrate,System);
DWORD Frequency;
switch (System) {

View File

@ -410,7 +410,9 @@ void CMipsMemoryVM::Compile_LW (x86Reg Reg, DWORD VAddr ) {
case 0x04400000:
switch (PAddr) {
case 0x04400010:
UpdateCounters(m_RegWorkingSet,false,true);
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_CountPerOp) ;
UpdateCounters(m_RegWorkingSet,false, true);
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_CountPerOp) ;
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)this,x86_ECX);
Call_Direct(AddressOf(CMipsMemoryVM::UpdateHalfLine),"CMipsMemoryVM::UpdateHalfLine");
@ -425,9 +427,11 @@ void CMipsMemoryVM::Compile_LW (x86Reg Reg, DWORD VAddr ) {
case 0x04500000: /* AI registers */
switch (PAddr) {
case 0x04500004:
if (g_FixedAudio)
if (_Settings->LoadBool(Game_FixedAudio))
{
UpdateCounters(m_RegWorkingSet,false,true);
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_CountPerOp) ;
UpdateCounters(m_RegWorkingSet,false, true);
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_CountPerOp) ;
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)_Audio,x86_ECX);
Call_Direct(AddressOf(CAudio::GetLength),"CAudio::GetLength");
@ -447,7 +451,7 @@ void CMipsMemoryVM::Compile_LW (x86Reg Reg, DWORD VAddr ) {
}
break;
case 0x0450000C:
if (g_FixedAudio)
if (_Settings->LoadBool(Game_FixedAudio))
{
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)_Audio,x86_ECX);
@ -724,6 +728,7 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) {
}
if ( ( Value & SP_CLR_INTR ) != 0) {
AndConstToVariable(~MI_INTR_SP,&_Reg->MI_INTR_REG,"MI_INTR_REG");
AndConstToVariable(~MI_INTR_SP,&_Reg->m_RspIntrReg,"m_RspIntrReg");
BeforeCallDirect(m_RegWorkingSet);
Call_Direct(RunRsp,"RunRsp");
MoveConstToX86reg((DWORD)_Reg,x86_ECX);
@ -856,7 +861,7 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) {
case 0x04500004:
MoveConstToVariable(Value,&_Reg->AI_LEN_REG,"AI_LEN_REG");
BeforeCallDirect(m_RegWorkingSet);
if (g_FixedAudio)
if (_Settings->LoadBool(Game_FixedAudio))
{
X86BreakPoint(__FILE__,__LINE__);
MoveConstToX86reg((DWORD)_Audio,x86_ECX);
@ -871,7 +876,7 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) {
/* Clear Interrupt */;
AndConstToVariable(~MI_INTR_AI,&_Reg->MI_INTR_REG,"MI_INTR_REG");
#ifdef tofix
if (!g_FixedAudio)
if (!_Settings->LoadBool(Game_FixedAudio))
{
AndConstToVariable(~MI_INTR_AI,&_Reg->m_AudioIntrReg,"m_AudioIntrReg");
}
@ -1118,10 +1123,12 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr )
switch (PAddr) {
case 0x04500000: MoveX86regToVariable(Reg,&_Reg->AI_DRAM_ADDR_REG,"AI_DRAM_ADDR_REG"); break;
case 0x04500004:
UpdateCounters(m_RegWorkingSet,false,true);
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_CountPerOp) ;
UpdateCounters(m_RegWorkingSet,false, true);
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_CountPerOp) ;
MoveX86regToVariable(Reg,&_Reg->AI_LEN_REG,"AI_LEN_REG");
BeforeCallDirect(m_RegWorkingSet);
if (g_FixedAudio)
if (_Settings->LoadBool(Game_FixedAudio))
{
MoveConstToX86reg((DWORD)_Audio,x86_ECX);
Call_Direct(AddressOf(CAudio::LenChanged),"LenChanged");
@ -1704,7 +1711,7 @@ int CMipsMemoryVM::LW_NonMemory ( DWORD PAddr, DWORD * Value ) {
case 0x04500000:
switch (PAddr) {
case 0x04500004:
if (g_FixedAudio)
if (_Settings->LoadBool(Game_FixedAudio))
{
*Value = _Audio->GetLength();
} else {
@ -1716,7 +1723,7 @@ int CMipsMemoryVM::LW_NonMemory ( DWORD PAddr, DWORD * Value ) {
}
break;
case 0x0450000C:
if (g_FixedAudio)
if (_Settings->LoadBool(Game_FixedAudio))
{
*Value = _Audio->GetStatus();
} else {
@ -2148,7 +2155,7 @@ int CMipsMemoryVM::SW_NonMemory ( DWORD PAddr, DWORD Value ) {
case 0x04500000: _Reg->AI_DRAM_ADDR_REG = Value; break;
case 0x04500004:
_Reg->AI_LEN_REG = Value;
if (g_FixedAudio)
if (_Settings->LoadBool(Game_FixedAudio))
{
_Audio->LenChanged();
} else {
@ -2165,7 +2172,7 @@ int CMipsMemoryVM::SW_NonMemory ( DWORD PAddr, DWORD Value ) {
case 0x04500010:
_Reg->AI_DACRATE_REG = Value;
_Plugins->Audio()->DacrateChanged(g_SystemType);
if (g_FixedAudio)
if (_Settings->LoadBool(Game_FixedAudio))
{
_Audio->SetFrequency(Value,g_SystemType);
}

View File

@ -264,7 +264,7 @@ void CRegisters::SetAsCurrentSystem ( void )
void CRegisters::CheckInterrupts ( void )
{
if (!g_FixedAudio && g_CPU_Type != CPU_SyncCores) {
if (!_Settings->LoadBool(Game_FixedAudio) && g_CPU_Type != CPU_SyncCores) {
MI_INTR_REG &= ~MI_INTR_AI;
MI_INTR_REG |= (m_AudioIntrReg & MI_INTR_AI);
}
@ -454,195 +454,3 @@ void CRegisters::DoSysCallException ( BOOL DelaySlot)
m_PROGRAM_COUNTER = 0x80000180;
}
#ifdef toremove
void CRegisters::InitalizeR4300iRegisters (CMipsMemory & MMU, bool PostPif, int Country, CICChip CIC_Chip)
{
//Reset General Registers
memset(GPR,0,sizeof(GPR));
memset(CP0,0,sizeof(CP0));
memset(FPR,0,sizeof(FPR));
memset(FPCR,0,sizeof(FPCR));
HI.DW = 0;
LO.DW = 0;
LLBit = 0;
LLAddr = 0;
//Reset System Registers
memset(RDRAM_Interface,0,sizeof(RDRAM_Interface));
memset(RDRAM_Registers,0,sizeof(RDRAM_Registers));
memset(Mips_Interface,0,sizeof(Mips_Interface));
memset(Video_Interface,0,sizeof(Video_Interface));
memset(Display_ControlReg,0,sizeof(Display_ControlReg));
memset(Audio_Interface,0,sizeof(Audio_Interface));
memset(SigProcessor_Interface,0,sizeof(SigProcessor_Interface));
memset(Peripheral_Interface,0,sizeof(Peripheral_Interface));
memset(SerialInterface,0,sizeof(SerialInterface));
//COP0 Registers
RANDOM_REGISTER = 0x1F;
COUNT_REGISTER = 0x5000;
MI_VERSION_REG = 0x02020102;
SP_STATUS_REG = 0x00000001;
CAUSE_REGISTER = 0x0000005C;
CONTEXT_REGISTER = 0x007FFFF0;
EPC_REGISTER = 0xFFFFFFFF;
BAD_VADDR_REGISTER = 0xFFFFFFFF;
ERROREPC_REGISTER = 0xFFFFFFFF;
CONFIG_REGISTER = 0x0006E463;
STATUS_REGISTER = 0x34000000;
//REVISION_REGISTER = 0x00000511;
ChangeTimerFixed(CompareTimer,COMPARE_REGISTER - COUNT_REGISTER);
AudioIntrReg = 0;
if (PostPif) {
PROGRAM_COUNTER = 0xA4000040;
GPR[0].DW=0x0000000000000000;
GPR[6].DW=0xFFFFFFFFA4001F0C;
GPR[7].DW=0xFFFFFFFFA4001F08;
GPR[8].DW=0x00000000000000C0;
GPR[9].DW=0x0000000000000000;
GPR[10].DW=0x0000000000000040;
GPR[11].DW=0xFFFFFFFFA4000040;
GPR[16].DW=0x0000000000000000;
GPR[17].DW=0x0000000000000000;
GPR[18].DW=0x0000000000000000;
GPR[19].DW=0x0000000000000000;
GPR[21].DW=0x0000000000000000;
GPR[26].DW=0x0000000000000000;
GPR[27].DW=0x0000000000000000;
GPR[28].DW=0x0000000000000000;
GPR[29].DW=0xFFFFFFFFA4001FF0;
GPR[30].DW=0x0000000000000000;
switch (Country) {
case Germany: case french: case Italian:
case Europe: case Spanish: case Australia:
case X_PAL: case Y_PAL:
switch (CIC_Chip) {
case CIC_NUS_6102:
GPR[5].DW=0xFFFFFFFFC0F1D859;
GPR[14].DW=0x000000002DE108EA;
GPR[24].DW=0x0000000000000000;
break;
case CIC_NUS_6103:
GPR[5].DW=0xFFFFFFFFD4646273;
GPR[14].DW=0x000000001AF99984;
GPR[24].DW=0x0000000000000000;
break;
case CIC_NUS_6105:
MMU.SW_VAddr(0xA4001004,0xBDA807FC);
GPR[5].DW=0xFFFFFFFFDECAAAD1;
GPR[14].DW=0x000000000CF85C13;
GPR[24].DW=0x0000000000000002;
break;
case CIC_NUS_6106:
GPR[5].DW=0xFFFFFFFFB04DC903;
GPR[14].DW=0x000000001AF99984;
GPR[24].DW=0x0000000000000002;
break;
}
GPR[20].DW=0x0000000000000000;
GPR[23].DW=0x0000000000000006;
GPR[31].DW=0xFFFFFFFFA4001554;
break;
case NTSC_BETA: case X_NTSC: case USA: case Japan:
default:
switch (CIC_Chip) {
case CIC_NUS_6102:
GPR[5].DW=0xFFFFFFFFC95973D5;
GPR[14].DW=0x000000002449A366;
break;
case CIC_NUS_6103:
GPR[5].DW=0xFFFFFFFF95315A28;
GPR[14].DW=0x000000005BACA1DF;
break;
case CIC_NUS_6105:
MMU.SW_VAddr(0xA4001004,0x8DA807FC);
GPR[5].DW=0x000000005493FB9A;
GPR[14].DW=0xFFFFFFFFC2C20384;
case CIC_NUS_6106:
GPR[5].DW=0xFFFFFFFFE067221F;
GPR[14].DW=0x000000005CD2B70F;
break;
}
GPR[20].DW=0x0000000000000001;
GPR[23].DW=0x0000000000000000;
GPR[24].DW=0x0000000000000003;
GPR[31].DW=0xFFFFFFFFA4001550;
}
switch (CIC_Chip) {
case CIC_NUS_6101:
GPR[22].DW=0x000000000000003F;
break;
case CIC_NUS_6102:
GPR[1].DW=0x0000000000000001;
GPR[2].DW=0x000000000EBDA536;
GPR[3].DW=0x000000000EBDA536;
GPR[4].DW=0x000000000000A536;
GPR[12].DW=0xFFFFFFFFED10D0B3;
GPR[13].DW=0x000000001402A4CC;
GPR[15].DW=0x000000003103E121;
GPR[22].DW=0x000000000000003F;
GPR[25].DW=0xFFFFFFFF9DEBB54F;
break;
case CIC_NUS_6103:
GPR[1].DW=0x0000000000000001;
GPR[2].DW=0x0000000049A5EE96;
GPR[3].DW=0x0000000049A5EE96;
GPR[4].DW=0x000000000000EE96;
GPR[12].DW=0xFFFFFFFFCE9DFBF7;
GPR[13].DW=0xFFFFFFFFCE9DFBF7;
GPR[15].DW=0x0000000018B63D28;
GPR[22].DW=0x0000000000000078;
GPR[25].DW=0xFFFFFFFF825B21C9;
break;
case CIC_NUS_6105:
MMU.SW_VAddr(0xA4001000,0x3C0DBFC0);
MMU.SW_VAddr(0xA4001008,0x25AD07C0);
MMU.SW_VAddr(0xA400100C,0x31080080);
MMU.SW_VAddr(0xA4001010,0x5500FFFC);
MMU.SW_VAddr(0xA4001014,0x3C0DBFC0);
MMU.SW_VAddr(0xA4001018,0x8DA80024);
MMU.SW_VAddr(0xA400101C,0x3C0BB000);
GPR[1].DW=0x0000000000000000;
GPR[2].DW=0xFFFFFFFFF58B0FBF;
GPR[3].DW=0xFFFFFFFFF58B0FBF;
GPR[4].DW=0x0000000000000FBF;
GPR[12].DW=0xFFFFFFFF9651F81E;
GPR[13].DW=0x000000002D42AAC5;
GPR[15].DW=0x0000000056584D60;
GPR[22].DW=0x0000000000000091;
GPR[25].DW=0xFFFFFFFFCDCE565F;
break;
case CIC_NUS_6106:
GPR[1].DW=0x0000000000000000;
GPR[2].DW=0xFFFFFFFFA95930A4;
GPR[3].DW=0xFFFFFFFFA95930A4;
GPR[4].DW=0x00000000000030A4;
GPR[12].DW=0xFFFFFFFFBCB59510;
GPR[13].DW=0xFFFFFFFFBCB59510;
GPR[15].DW=0x000000007A3C07F4;
GPR[22].DW=0x0000000000000085;
GPR[25].DW=0x00000000465E3F72;
break;
}
} else {
PROGRAM_COUNTER = 0xBFC00000;
/* PIF_Ram[36] = 0x00; PIF_Ram[39] = 0x3F; //common pif ram start values
switch (CIC_Chip) {
case CIC_NUS_6101: PIF_Ram[37] = 0x06; PIF_Ram[38] = 0x3F; break;
case CIC_NUS_6102: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x3F; break;
case CIC_NUS_6103: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x78; break;
case CIC_NUS_6105: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x91; break;
case CIC_NUS_6106: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x85; break;
}*/
}
FixFpuLocations();
}
#endif

View File

@ -1,9 +1,9 @@
#include "stdafx.h"
CSystemTimer::CSystemTimer( int & NextTimer ) :
m_NextTimer(NextTimer)
m_NextTimer(NextTimer),
m_inFixTimer(false)
{
Reset();
}
void CSystemTimer::Reset ( void )
@ -15,10 +15,11 @@ void CSystemTimer::Reset ( void )
m_TimerDetatils[i].CyclesToTimer = 0;
}
m_Current = UnknownTimer;
m_Timer = 0;
m_LastUpdate = 0;
m_NextTimer = 0;
SetTimer(ViTimer,50000,false);
SetCompareTimer();
}
void CSystemTimer::SetTimer ( TimerType Type, DWORD Cycles, bool bRelative )
@ -37,10 +38,10 @@ void CSystemTimer::SetTimer ( TimerType Type, DWORD Cycles, bool bRelative )
{
m_TimerDetatils[Type].CyclesToTimer += Cycles; //Add to the timer
} else {
m_TimerDetatils[Type].CyclesToTimer = (__int64)Cycles - (__int64)m_Timer; //replace the new cycles
m_TimerDetatils[Type].CyclesToTimer = (__int64)Cycles - (__int64)m_NextTimer; //replace the new cycles
}
} else {
m_TimerDetatils[Type].CyclesToTimer = (__int64)Cycles - (__int64)m_Timer; //replace the new cycles
m_TimerDetatils[Type].CyclesToTimer = (__int64)Cycles - (__int64)m_NextTimer; //replace the new cycles
}
FixTimers();
}
@ -73,20 +74,32 @@ void CSystemTimer::StopTimer ( TimerType Type )
void CSystemTimer::FixTimers (void)
{
int count;
if (m_inFixTimer)
{
return;
}
m_inFixTimer = true;
UpdateTimers();
if (GetTimer(CompareTimer) > 0x60000000)
{
SetCompareTimer();
}
//Update the cycles for the remaining number of cycles to timer
int count;
for (count = 0; count < MaxTimer; count++)
{
if (!m_TimerDetatils[count].Active)
{
continue;
}
m_TimerDetatils[count].CyclesToTimer += m_Timer;
m_TimerDetatils[count].CyclesToTimer += m_NextTimer;
}
//Set Max timer
m_Timer = 0x7FFFFFFF;
m_NextTimer = 0x7FFFFFFF;
//Find the smallest timer left to go
for (count = 0; count < MaxTimer; count++)
@ -95,11 +108,11 @@ void CSystemTimer::FixTimers (void)
{
continue;
}
if (m_TimerDetatils[count].CyclesToTimer >= m_Timer)
if (m_TimerDetatils[count].CyclesToTimer >= m_NextTimer)
{
continue;
}
m_Timer = m_TimerDetatils[count].CyclesToTimer;
m_NextTimer = m_TimerDetatils[count].CyclesToTimer;
m_Current = (TimerType)count;
}
@ -110,17 +123,18 @@ void CSystemTimer::FixTimers (void)
{
continue;
}
m_TimerDetatils[count].CyclesToTimer -= m_Timer;
m_TimerDetatils[count].CyclesToTimer -= m_NextTimer;
}
m_NextTimer = m_Timer;
m_LastUpdate = m_NextTimer;
m_inFixTimer = false;
}
void CSystemTimer::UpdateTimers ( void )
{
int TimeTaken = m_Timer - m_NextTimer;
int TimeTaken = m_LastUpdate - m_NextTimer;
if (TimeTaken != 0)
{
m_Timer = m_NextTimer;
m_LastUpdate = m_NextTimer;
_Reg->COUNT_REGISTER += TimeTaken;
_Reg->RANDOM_REGISTER -= TimeTaken / g_CountPerOp;
while ((int)_Reg->RANDOM_REGISTER < (int)_Reg->WIRED_REGISTER)
@ -195,18 +209,31 @@ void CSystemTimer::TimerDone (void)
}*/
}
void CSystemTimer::UpdateCompareTimer ( void )
void CSystemTimer::SetCompareTimer ( void )
{
DWORD NextCompare = _Reg->COMPARE_REGISTER - _Reg->COUNT_REGISTER;
DWORD NextCompare = 0x7FFFFFFF;
if (_Reg)
{
NextCompare = _Reg->COMPARE_REGISTER - _Reg->COUNT_REGISTER;
if ((NextCompare & 0x80000000) != 0)
{
NextCompare = 0x7FFFFFFF;
}
_SystemTimer->SetTimer(CSystemTimer::CompareTimer,NextCompare,false);
}
SetTimer(CompareTimer,NextCompare,false);
}
void CSystemTimer::UpdateCompareTimer ( void )
{
SetCompareTimer();
}
bool CSystemTimer::SaveAllowed ( void )
{
if (GetTimer(CompareTimer) <= 0)
{
return false;
}
for (int i = 0; i < MaxTimer; i++)
{
if (i == CompareTimer) { continue; }

View File

@ -39,9 +39,11 @@ public:
private:
TIMER_DETAILS m_TimerDetatils[MaxTimer];
int m_Timer; //How many cycles to the next event
int m_LastUpdate; //Timer at last update
int & m_NextTimer;
TimerType m_Current;
bool m_inFixTimer;
void SetCompareTimer ( void );
void FixTimers ( void );
};

View File

@ -534,21 +534,13 @@ bool CN64System::SetActiveSystem( bool bActive )
if (bActive)
{
if (!m_bInitilized)
{
if (!m_MMU_VM.Initialize())
{
return false;
}
Reset(true,true);
m_bInitilized = true;
bInitPlugin = true;
}
m_Reg.SetAsCurrentSystem();
_System = this;
if (_BaseSystem == this)
{
_SyncSystem = m_SyncCPU;
}
_Recompiler = m_Recomp;
_MMU = &m_MMU_VM;
_TLB = &m_TLB;
@ -560,6 +552,17 @@ bool CN64System::SetActiveSystem( bool bActive )
_SystemEvents = this;
_NextTimer = &m_NextTimer;
_Plugins = m_Plugins;
if (!m_bInitilized)
{
if (!m_MMU_VM.Initialize())
{
return false;
}
Reset(true,true);
m_bInitilized = true;
bInitPlugin = true;
}
} else {
if (this == _BaseSystem)
{
@ -881,6 +884,9 @@ void CN64System::UpdateSyncCPU (CN64System * const SecondCPU, DWORD const Cycles
void CN64System::SyncCPU (CN64System * const SecondCPU) {
bool ErrorFound = false;
_SystemTimer->UpdateTimers();
#ifdef TEST_SP_TRACKING
if (m_CurrentSP != GPR[29].UW[0]) {
ErrorFound = true;
@ -925,7 +931,6 @@ void CN64System::SyncCPU (CN64System * const SecondCPU) {
#endif
}
if (m_Audio.GetLength() != SecondCPU->m_Audio.GetLength()) { ErrorFound = true; }
if (m_SystemTimer.CurrentType() != SecondCPU->m_SystemTimer.CurrentType()) { ErrorFound = true; }
if (m_NextTimer != SecondCPU->m_NextTimer) { ErrorFound = true; }
if (m_Reg.m_RoundingModel != SecondCPU->m_Reg.m_RoundingModel) { ErrorFound = true; }
@ -1422,8 +1427,6 @@ bool CN64System::LoadState(LPCSTR FileName) {
WriteTrace(TraceDebug,"CN64System::LoadState 8");
m_FPS.Reset(true);
WriteTrace(TraceDebug,"CN64System::LoadState 9");
m_EventList.clear();
m_NoOfEvents = m_EventList.size();
ResetX86Logs();
WriteTrace(TraceDebug,"CN64System::LoadState 12");
@ -1588,7 +1591,7 @@ void CN64System::RefreshScreen ( void ) {
}
}
_SystemTimer->SetTimer(CSystemTimer::ViTimer,VI_INTR_TIME,true);
if (g_FixedAudio)
if (bFixedAudio())
{
_Audio->SetViIntr (VI_INTR_TIME);
}

View File

@ -75,7 +75,6 @@ private:
void ExecuteCPU ( void );
void RefreshScreen ( void );
bool InternalEvent ( void );
bool InPermLoop ( void );
void RunRSP ( void );
bool SaveState ( void );
bool LoadState ( LPCSTR FileName );
@ -131,10 +130,6 @@ private:
DWORD m_LastSuccessSyncPC[10];
int m_CyclesToSkip;
//List of Internal events that need to be acted on by CPU
EVENT_LIST m_EventList;
DWORD m_NoOfEvents;
//Handle to the cpu thread
HANDLE m_CPU_Handle;
DWORD m_CPU_ThreadID;

View File

@ -70,6 +70,8 @@ enum STEP_TYPE {
DELAY_SLOT_DONE = 7,
LIKELY_DELAY_SLOT_DONE= 8,
END_BLOCK = 9,
PERMLOOP_DO_DELAY = 10,
PERMLOOP_DELAY_DONE = 11,
};
#endif

View File

@ -389,10 +389,8 @@ void CCodeSection::GenerateSectionLinkage (void)
if (!DelaySlotEffectsJump(CRecompilerOps::CompilePC())) {
MoveConstToVariable(CRecompilerOps::CompilePC(),_PROGRAM_COUNTER,"PROGRAM_COUNTER");
m_RegWorkingSet.WriteBackRegisters();
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_CountPerOp) ;
UpdateCounters(m_RegWorkingSet,false, true);
Call_Direct(InPermLoop,"InPermLoop");
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_CountPerOp) ;
UpdateCounters(m_RegWorkingSet,true,true);
CompileSystemCheck(-1,m_RegWorkingSet);
}
@ -682,13 +680,13 @@ bool CCodeSection::GenerateX86Code ( DWORD Test )
//m_RegWorkingSet.UnMap_AllFPRs();
}*/
if (m_CompilePC >= 0x0F000000 && m_CompilePC <= 0x0F000048 && m_NextInstruction == NORMAL)
/*if (m_CompilePC >= 0x80000000 && m_CompilePC <= 0x80400000 && m_NextInstruction == NORMAL)
{
m_RegWorkingSet.WriteBackRegisters();
UpdateCounters(m_RegWorkingSet,false,true);
MoveConstToVariable(m_CompilePC,&_Reg->m_PROGRAM_COUNTER,"PROGRAM_COUNTER");
if (_SyncSystem) { Call_Direct(SyncToPC, "SyncToPC"); }
}
}*/
/*if (m_CompilePC == 0x803254F0 && m_NextInstruction == NORMAL)
{

View File

@ -3576,16 +3576,16 @@ void CRecompilerOps::COP0_MF(void) {
switch (m_Opcode.rd) {
case 9: //Count
UpdateCounters(m_RegWorkingSet,false,true);
UpdateCounters(m_RegWorkingSet,false, true);
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)_SystemTimer,x86_ECX);
Call_Direct(AddressOf(CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers");
AfterCallDirect(m_RegWorkingSet);
}
Map_GPR_32bit(m_Opcode.rt,TRUE,-1);
MoveVariableToX86reg(&_CP0[m_Opcode.rd],CRegName::Cop0[m_Opcode.rd],cMipsRegMapLo(m_Opcode.rt));
}
void ChangeCompareTimer (void) {
_SystemTimer->SetTimer(CSystemTimer::CompareTimer, _Reg->COMPARE_REGISTER - _Reg->COUNT_REGISTER,false);
}
void CRecompilerOps::COP0_MT (void) {
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC));
@ -3637,7 +3637,9 @@ void CRecompilerOps::COP0_MT (void) {
AfterCallDirect(m_RegWorkingSet);
break;
case 9: //Count
UpdateCounters(m_RegWorkingSet,false,true);
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_CountPerOp) ;
UpdateCounters(m_RegWorkingSet,false, true);
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_CountPerOp) ;
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)_SystemTimer,x86_ECX);
Call_Direct(AddressOf(CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers");

View File

@ -124,7 +124,10 @@ bool CMainMenu::ProcessMessage(WND_HANDLE hWnd, DWORD FromAccelerator, DWORD Men
_Settings->SaveBool(GameRunning_LimitFPS,!_Settings->LoadBool(GameRunning_LimitFPS));
WriteTrace(TraceDebug,"ID_SYSTEM_LIMITFPS 1");
break;
case ID_SYSTEM_SAVE: WriteTrace(TraceDebug,"ID_SYSTEM_SAVE"); _BaseSystem->ExternalEvent(SysEvent_SaveMachineState); break;
case ID_SYSTEM_SAVE:
WriteTrace(TraceDebug,"ID_SYSTEM_SAVE");
_BaseSystem->ExternalEvent(SysEvent_SaveMachineState);
break;
case ID_SYSTEM_SAVEAS:
{
char drive[_MAX_DRIVE] ,dir[_MAX_DIR], fname[_MAX_FNAME],ext[_MAX_EXT];

View File

@ -1087,8 +1087,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,7,0,51
PRODUCTVERSION 1,7,0,51
FILEVERSION 1,7,51,42
PRODUCTVERSION 1,7,51,42
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -1106,14 +1106,14 @@ BEGIN
VALUE "Comments", "\0"
VALUE "CompanyName", " \0"
VALUE "FileDescription", "Project64\0"
VALUE "FileVersion", "1, 7, 0, 51\0"
VALUE "FileVersion", "1, 7, 51, 42\0"
VALUE "InternalName", "Project64\0"
VALUE "LegalCopyright", "Copyright © 2004\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "Project64.exe\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", " Project64\0"
VALUE "ProductVersion", "1, 7, 0, 51\0"
VALUE "ProductVersion", "1, 7, 51, 42\0"
VALUE "SpecialBuild", "\0"
END
END