COP0: Preserve read only fields IC and DC in the config register

This commit is contained in:
ty 2021-02-24 11:38:57 -05:00 committed by refractionpcsx2
parent 0a8ac3ba04
commit b088ee69cd
3 changed files with 22 additions and 2 deletions

View File

@ -41,10 +41,14 @@ void __fastcall WriteCP0Status(u32 value) {
//DMA_LOG("COP0 Status write = 0x%08x", value);
cpuRegs.CP0.n.Status.val = value;
cpuUpdateOperationMode();
cpuSetNextEventDelta(4);
}
void __fastcall WriteCP0Config(u32 value) {
// Protect the read-only ICacheSize (IC) and DataCacheSize (DC) bits
cpuRegs.CP0.n.Config = value & ~0xFC0;
cpuRegs.CP0.n.Config |= 0x440;
}
//////////////////////////////////////////////////////////////////////////////////////////
// Performance Counters Update Stuff!
@ -472,6 +476,10 @@ void MTC0()
WriteCP0Status(cpuRegs.GPR.r[_Rt_].UL[0]);
break;
case 16:
WriteCP0Config(cpuRegs.GPR.r[_Rt_].UL[0]);
break;
case 24:
COP0_LOG("MTC0 Breakpoint debug Registers code = %x", cpuRegs.code & 0x3FF);
break;

View File

@ -17,6 +17,7 @@
#define __COP0_H__
extern void __fastcall WriteCP0Status(u32 value);
extern void __fastcall WriteCP0Config(u32 value);
extern void cpuUpdateOperationMode();
extern void WriteTLB(int i);
extern void UnmapTLB(int i);

View File

@ -212,7 +212,12 @@ void recMTC0()
{
case 12:
iFlushCall(FLUSH_INTERPRETER);
xFastCall((void*)WriteCP0Status, g_cpuConstRegs[_Rt_].UL[0] );
xFastCall((void*)WriteCP0Status, g_cpuConstRegs[_Rt_].UL[0]);
break;
case 16:
iFlushCall(FLUSH_INTERPRETER);
xFastCall((void*)WriteCP0Config, g_cpuConstRegs[_Rt_].UL[0]);
break;
case 9:
@ -265,6 +270,12 @@ void recMTC0()
xFastCall((void*)WriteCP0Status, ecx );
break;
case 16:
iFlushCall(FLUSH_INTERPRETER);
_eeMoveGPRtoR(ecx, _Rt_);
xFastCall((void*)WriteCP0Config, ecx);
break;
case 9:
xMOV(ecx, ptr[&cpuRegs.cycle]);
_eeMoveGPRtoM((uptr)&cpuRegs.CP0.r[9], _Rt_);