From 342c10bd8536e038ec8c7b4eeecfd2b600100a1d Mon Sep 17 00:00:00 2001 From: Timothy O'Barr Date: Sat, 26 May 2018 05:20:02 -0600 Subject: [PATCH] PS1 mode: Adjustments to processor clock speed and CD read speed. (#2447) switch IOP clock, CD read speed and EE/IOP cycle ratio for PSX mode --- pcsx2/CDVD/CDVD.cpp | 7 +++++++ pcsx2/CDVD/CdRom.cpp | 6 +++++- pcsx2/CDVD/CdRom.h | 1 + pcsx2/Common.h | 2 ++ pcsx2/IopCommon.h | 1 - pcsx2/R3000A.cpp | 2 +- pcsx2/R3000AInterpreter.cpp | 12 ++++++++++-- 7 files changed, 26 insertions(+), 5 deletions(-) diff --git a/pcsx2/CDVD/CDVD.cpp b/pcsx2/CDVD/CDVD.cpp index 304e355aaf..e86dece608 100644 --- a/pcsx2/CDVD/CDVD.cpp +++ b/pcsx2/CDVD/CDVD.cpp @@ -21,6 +21,7 @@ #include #include +#include "CdRom.h" #include "CDVD.h" #include "CDVD_internal.h" #include "CDVDisoReader.h" @@ -38,6 +39,9 @@ wxString DiscSerial; static cdvdStruct cdvd; +s64 PSXCLK = 36864000; + + static __fi void SetResultSize(u8 size) { cdvd.ResultC = size; @@ -1416,6 +1420,9 @@ static __fi void cdvdWrite0F(u8 rt) { // TYPE static __fi void cdvdWrite14(u8 rt) { // PS1 MODE?? // This should be done in the SBUS_F240 bit 19 write in HwWrite.cpp u32 cycle = psxRegs.cycle; + PSXCLK = 33868800; + setPsxSpeed(); + if (rt == 0xFE) Console.Warning("*PCSX2*: go PS1 mode DISC SPEED = FAST"); else diff --git a/pcsx2/CDVD/CdRom.cpp b/pcsx2/CDVD/CdRom.cpp index e537feae50..b7512d7276 100644 --- a/pcsx2/CDVD/CdRom.cpp +++ b/pcsx2/CDVD/CdRom.cpp @@ -85,7 +85,6 @@ u8 Test23[] = { 0x43, 0x58, 0x44, 0x32, 0x39 ,0x34, 0x30, 0x51 }; // 1x = 75 sectors per second // PSXCLK = 1 sec in the ps // so (PSXCLK / 75) / BIAS = cdr read time (linuzappz) -//#define cdReadTime ((PSXCLK / 75) / BIAS) u32 cdReadTime;// = ((PSXCLK / 75) / BIAS); #define CDR_INT(eCycle) PSX_INT(IopEvt_Cdrom, eCycle) @@ -604,6 +603,11 @@ void cdrWrite0(u8 rt) { } } +void setPsxSpeed() +{ + cdReadTime = ((PSXCLK / 75) / BIAS); +} + u8 cdrRead1(void) { if (cdr.ResultReady && cdr.Ctrl & 0x1) { psxHu8(0x1801) = cdr.Result[cdr.ResultP++]; diff --git a/pcsx2/CDVD/CdRom.h b/pcsx2/CDVD/CdRom.h index 9b04a2b480..599a9b25b0 100644 --- a/pcsx2/CDVD/CdRom.h +++ b/pcsx2/CDVD/CdRom.h @@ -93,6 +93,7 @@ u8 cdrRead0(void); u8 cdrRead1(void); u8 cdrRead2(void); u8 cdrRead3(void); +void setPsxSpeed(); void cdrWrite0(u8 rt); void cdrWrite1(u8 rt); void cdrWrite2(u8 rt); diff --git a/pcsx2/Common.h b/pcsx2/Common.h index 34b895796e..b740afd310 100644 --- a/pcsx2/Common.h +++ b/pcsx2/Common.h @@ -19,6 +19,8 @@ static const u32 BIAS = 2; // Bus is half of the actual ps2 speed static const u32 PS2CLK = 294912000; //hz /* 294.912 mhz */ +extern s64 PSXCLK; /* 36.864 Mhz */ + #include "System.h" #include "Memory.h" diff --git a/pcsx2/IopCommon.h b/pcsx2/IopCommon.h index 57203eb19a..011fadd67b 100644 --- a/pcsx2/IopCommon.h +++ b/pcsx2/IopCommon.h @@ -28,7 +28,6 @@ #include "IopCounters.h" #include "IopSio2.h" #include "IopGte.h" -static const s64 PSXCLK = 36864000; /* 36.864 Mhz */ //#define PSXCLK 9216000 /* 36.864 Mhz */ //#define PSXCLK 186864000 /* 36.864 Mhz */ diff --git a/pcsx2/R3000A.cpp b/pcsx2/R3000A.cpp index 182ee9a5f3..338449f4a1 100644 --- a/pcsx2/R3000A.cpp +++ b/pcsx2/R3000A.cpp @@ -63,7 +63,7 @@ void psxReset() g_iopNextEventCycle = psxRegs.cycle + 4; psxHwReset(); - + PSXCLK = 36864000; ioman::reset(); psxBiosReset(); } diff --git a/pcsx2/R3000AInterpreter.cpp b/pcsx2/R3000AInterpreter.cpp index b78035d9ec..223a6c865a 100644 --- a/pcsx2/R3000AInterpreter.cpp +++ b/pcsx2/R3000AInterpreter.cpp @@ -142,8 +142,16 @@ static __fi void execI() psxRegs.pc+= 4; psxRegs.cycle++; - iopCycleEE-=8; - + + if ((psxHu32(HW_ICFG) & (1 << 3))) + { + //One of the Iop to EE delta clocks to be set in PS1 mode. + iopCycleEE-=9; + } + else + { //default ps2 mode value + iopCycleEE-=8; + } psxBSC[psxRegs.code >> 26](); }