Skip to content

Commit

Permalink
COP0: Preserve read only fields IC and DC in the config register
Browse files Browse the repository at this point in the history
  • Loading branch information
F0bes authored and refractionpcsx2 committed Feb 24, 2021
1 parent 0a8ac3b commit b088ee6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
10 changes: 9 additions & 1 deletion pcsx2/COP0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions pcsx2/COP0.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 12 additions & 1 deletion pcsx2/x86/iCOP0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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_);
Expand Down

0 comments on commit b088ee6

Please sign in to comment.