Skip to content

Commit

Permalink
Win: CPU Overclocking
Browse files Browse the repository at this point in the history
The CPU clockspeed in PCSXR is used for:
*CD read speed timing
*Framerate counter
  • Loading branch information
SonofUgly committed Nov 20, 2015
1 parent f2628cb commit 3f11d29
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 12 deletions.
26 changes: 26 additions & 0 deletions libpcsxcore/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,32 @@ int CheckCdrom() {
else Config.PsxType = PSX_TYPE_NTSC; // ntsc
}

if (Config.PsxStock == 0) {
PsxClockSpeed = 33868800; // 33.8688 MHz (stock)
} else {
if (Config.PsxClock == 0) {
PsxClockSpeed = 16934400; // 16.9344 MHz (0.5x)
}
if (Config.PsxClock == 1) {
PsxClockSpeed = 25401600; // 25.4016 MHz (0.75x)
}
if (Config.PsxClock == 2) {
PsxClockSpeed = 50803200; // 50.8032 MHz (1.5x)
}
if (Config.PsxClock == 3) {
PsxClockSpeed = 67737600; // 67.7376 MHz (2x)
}
if (Config.PsxClock == 4) {
PsxClockSpeed = 101606400; // 101.6064 MHz (3x)
}
if (Config.PsxClock == 5) {
PsxClockSpeed = 135475200; // 135.4752 MHz (4x)
}
if (Config.PsxClock == 6) {
PsxClockSpeed = 169344000; // 169.3440 MHz (5x)
}
}

if (CdromLabel[0] == ' ') {
strncpy(CdromLabel, CdromId, 9);
}
Expand Down
6 changes: 5 additions & 1 deletion libpcsxcore/psxcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ typedef struct {
u8 HackFix;
u8 MemHack;
u8 NoHack;
boolean PsxStock;
u8 PsxClock;
#ifdef _WIN32
char Lang[256];
#endif
Expand All @@ -184,8 +186,10 @@ extern u8 vblank_count_hideafter;
// Make the timing events trigger faster as we are currently assuming everything
// takes one cycle, which is not the case on real hardware.
// FIXME: Count the proper cycle and get rid of this
u32 PsxClockSpeed;
#define BIAS 2
#define PSXCLK 33868800 /* 33.8688 MHz */
#define PSXCLK PsxClockSpeed


enum {
PSX_TYPE_NTSC = 0,
Expand Down
4 changes: 4 additions & 0 deletions win32/gui/ConfigurePlugins.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ int LoadConfig() {
QueryKeyV("HackFix", Conf->HackFix);
QueryKeyV("MemHack", Conf->MemHack);
QueryKeyV("NoHack", Conf->NoHack);
QueryKeyV("PsxStock", Conf->PsxStock);

QueryKeyV("Cpu", Conf->Cpu);
QueryKeyV("PsxType", Conf->PsxType);
QueryKeyV("PsxClock", Conf->PsxClock);

if (Config.Cpu == CPU_DYNAREC) {
Config.Debug = 0; // don't enable debugger if using dynarec core
Expand Down Expand Up @@ -149,9 +151,11 @@ void SaveConfig() {
SetKeyV("HackFix", Conf->HackFix);
SetKeyV("MemHack", Conf->MemHack);
SetKeyV("NoHack", Conf->NoHack);
SetKeyV("PsxStock", Conf->PsxStock);

SetKeyV("Cpu", Conf->Cpu);
SetKeyV("PsxType", Conf->PsxType);
SetKeyV("PsxClock", Conf->PsxClock);

RegCloseKey(myKey);
}
Expand Down
39 changes: 38 additions & 1 deletion win32/gui/WndMain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1357,9 +1357,11 @@ BOOL CALLBACK ConfigureCpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPar
Button_SetText(GetDlgItem(hW,IDC_HACKFIX), _("Compatibility hacks (Raystorm/VH-D/MML/Cart World/...)"));
Button_SetText(GetDlgItem(hW,IDC_MEMHACK), _("Wipeout memory hack (causes slowdowns in many games)"));
Button_SetText(GetDlgItem(hW,IDC_NOHACK), _("Disable all hacks"));
Button_SetText(GetDlgItem(hW,IDC_PSXSTOCK), _("CPU Overclocking"));

Static_SetText(GetDlgItem(hW,IDC_MISCOPT), _("Options"));
Static_SetText(GetDlgItem(hW,IDC_SELPSX), _("Psx System Type"));
Static_SetText(GetDlgItem(hW,IDC_SELPSX), _("PSX System Type"));
Static_SetText(GetDlgItem(hW,IDC_SELPSXCLOCK), _("CPU Overclocking"));

Button_SetCheck(GetDlgItem(hW,IDC_XA), Config.Xa);
Button_SetCheck(GetDlgItem(hW,IDC_SIO), Config.SioIrq);
Expand All @@ -1379,11 +1381,21 @@ BOOL CALLBACK ConfigureCpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPar
Button_SetCheck(GetDlgItem(hW,IDC_HACKFIX), Config.HackFix);
Button_SetCheck(GetDlgItem(hW,IDC_MEMHACK), Config.MemHack);
Button_SetCheck(GetDlgItem(hW,IDC_NOHACK), Config.NoHack);
Button_SetCheck(GetDlgItem(hW,IDC_PSXSTOCK), Config.PsxStock);

ComboBox_AddString(GetDlgItem(hW,IDC_PSXTYPES), "NTSC");
ComboBox_AddString(GetDlgItem(hW,IDC_PSXTYPES), "PAL");
ComboBox_SetCurSel(GetDlgItem(hW,IDC_PSXTYPES),Config.PsxType);

ComboBox_AddString(GetDlgItem(hW, IDC_PSXCLOCK), "0.5x");
ComboBox_AddString(GetDlgItem(hW, IDC_PSXCLOCK), "0.75");
ComboBox_AddString(GetDlgItem(hW, IDC_PSXCLOCK), "1.5x");
ComboBox_AddString(GetDlgItem(hW, IDC_PSXCLOCK), "2.0x");
ComboBox_AddString(GetDlgItem(hW, IDC_PSXCLOCK), "3.0x");
ComboBox_AddString(GetDlgItem(hW, IDC_PSXCLOCK), "4.0x");
ComboBox_AddString(GetDlgItem(hW, IDC_PSXCLOCK), "5.0x");
ComboBox_SetCurSel(GetDlgItem(hW, IDC_PSXCLOCK), Config.PsxClock);

if (Config.Cpu == CPU_DYNAREC) {
Config.Debug = 0;
Button_SetCheck(GetDlgItem(hW, IDC_DEBUG), FALSE);
Expand All @@ -1399,6 +1411,7 @@ BOOL CALLBACK ConfigureCpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPar
Config.Widescreen = 0;
Config.HackFix = 0;
Config.MemHack = 0;
Config.PsxStock = 0;
Button_SetCheck(GetDlgItem(hW, IDC_XA), FALSE);
Button_SetCheck(GetDlgItem(hW, IDC_MDEC), FALSE);
Button_SetCheck(GetDlgItem(hW, IDC_CDDA), FALSE);
Expand All @@ -1407,6 +1420,7 @@ BOOL CALLBACK ConfigureCpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPar
Button_SetCheck(GetDlgItem(hW, IDC_WIDESCREEN), FALSE);
Button_SetCheck(GetDlgItem(hW, IDC_HACKFIX), FALSE);
Button_SetCheck(GetDlgItem(hW, IDC_MEMHACK), FALSE);
Button_SetCheck(GetDlgItem(hW, IDC_PSXSTOCK), FALSE);
EnableWindow(GetDlgItem(hW, IDC_XA), FALSE);
EnableWindow(GetDlgItem(hW, IDC_MDEC), FALSE);
EnableWindow(GetDlgItem(hW, IDC_CDDA), FALSE);
Expand All @@ -1415,9 +1429,16 @@ BOOL CALLBACK ConfigureCpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPar
EnableWindow(GetDlgItem(hW, IDC_WIDESCREEN), FALSE);
EnableWindow(GetDlgItem(hW, IDC_HACKFIX), FALSE);
EnableWindow(GetDlgItem(hW, IDC_MEMHACK), FALSE);
EnableWindow(GetDlgItem(hW, IDC_PSXSTOCK), FALSE);
}

EnableWindow(GetDlgItem(hW,IDC_PSXTYPES), !Config.PsxAuto);

if (Config.PsxStock) {
EnableWindow(GetDlgItem(hW, IDC_PSXCLOCK), TRUE);
} else {
EnableWindow(GetDlgItem(hW, IDC_PSXCLOCK), FALSE);
}
break;

case WM_COMMAND: {
Expand All @@ -1428,6 +1449,8 @@ BOOL CALLBACK ConfigureCpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPar
if (tmp == 0) Config.PsxType = 0;
else Config.PsxType = 1;

Config.PsxClock = ComboBox_GetCurSel(GetDlgItem(hW, IDC_PSXCLOCK));

Config.Xa = Button_GetCheck(GetDlgItem(hW,IDC_XA));
Config.SioIrq = Button_GetCheck(GetDlgItem(hW,IDC_SIO));
Config.Mdec = Button_GetCheck(GetDlgItem(hW,IDC_MDEC));
Expand Down Expand Up @@ -1456,6 +1479,7 @@ BOOL CALLBACK ConfigureCpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPar
Config.HackFix = Button_GetCheck(GetDlgItem(hW,IDC_HACKFIX));
Config.MemHack = Button_GetCheck(GetDlgItem(hW,IDC_MEMHACK));
Config.NoHack = Button_GetCheck(GetDlgItem(hW, IDC_NOHACK));
Config.PsxStock = Button_GetCheck(GetDlgItem(hW, IDC_PSXSTOCK));

if(Config.SaveWindowPos) {
GetWindowRect(gApp.hWnd, &rect);
Expand Down Expand Up @@ -1487,6 +1511,15 @@ BOOL CALLBACK ConfigureCpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPar
}
break;

case IDC_PSXSTOCK:
if (Button_GetCheck(GetDlgItem(hW, IDC_PSXSTOCK))) {
EnableWindow(GetDlgItem(hW, IDC_PSXCLOCK), TRUE);
}
else {
EnableWindow(GetDlgItem(hW, IDC_PSXCLOCK), FALSE);
}
break;

case IDC_NOHACK:
if (Button_GetCheck(GetDlgItem(hW, IDC_NOHACK))) {
EnableWindow(GetDlgItem(hW, IDC_XA), FALSE);
Expand All @@ -1497,6 +1530,8 @@ BOOL CALLBACK ConfigureCpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPar
EnableWindow(GetDlgItem(hW, IDC_WIDESCREEN), FALSE);
EnableWindow(GetDlgItem(hW, IDC_HACKFIX), FALSE);
EnableWindow(GetDlgItem(hW, IDC_MEMHACK), FALSE);
EnableWindow(GetDlgItem(hW, IDC_PSXSTOCK), FALSE);
EnableWindow(GetDlgItem(hW, IDC_PSXCLOCK), FALSE);
Button_SetCheck(GetDlgItem(hW, IDC_XA), FALSE);
Button_SetCheck(GetDlgItem(hW, IDC_MDEC), FALSE);
Button_SetCheck(GetDlgItem(hW, IDC_CDDA), FALSE);
Expand All @@ -1505,6 +1540,7 @@ BOOL CALLBACK ConfigureCpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPar
Button_SetCheck(GetDlgItem(hW, IDC_WIDESCREEN), FALSE);
Button_SetCheck(GetDlgItem(hW, IDC_HACKFIX), FALSE);
Button_SetCheck(GetDlgItem(hW, IDC_MEMHACK), FALSE);
Button_SetCheck(GetDlgItem(hW, IDC_PSXSTOCK), FALSE);
}
else {
EnableWindow(GetDlgItem(hW, IDC_XA), TRUE);
Expand All @@ -1515,6 +1551,7 @@ BOOL CALLBACK ConfigureCpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPar
EnableWindow(GetDlgItem(hW, IDC_WIDESCREEN), TRUE);
EnableWindow(GetDlgItem(hW, IDC_HACKFIX), TRUE);
EnableWindow(GetDlgItem(hW, IDC_MEMHACK), TRUE);
EnableWindow(GetDlgItem(hW, IDC_PSXSTOCK), TRUE);
}
break;

Expand Down
31 changes: 22 additions & 9 deletions win32/pcsxr.rc
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ BEGIN
GROUPBOX "",IDC_STATIC,43,100,234,79
END

IDD_CPUCONF DIALOGEX 0, 0, 353, 184
IDD_CPUCONF DIALOGEX 0, 0, 353, 199
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Cpu Config"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
GROUPBOX "Misc Options",IDC_MISCOPT,7,7,130,135
GROUPBOX "Misc Options",IDC_MISCOPT,7,7,130,150
CONTROL "Sio Irq Always Enabled",IDC_SIO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,15,86,10
CONTROL "Spu Irq Always Enabled",IDC_SPUIRQ,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,30,89,10
CONTROL "Enable Console Output",IDC_PSXOUT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,45,88,10
Expand All @@ -117,7 +117,7 @@ BEGIN
CONTROL "Slow Boot",IDC_SLOWBOOT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,90,46,10
CONTROL "Hide cursor",IDC_HIDECURSOR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,105,49,10
CONTROL "Save window position",IDC_SAVEWINDOWPOS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,120,83,10
GROUPBOX "Hacks",IDC_MISCOPT2,140,7,205,135
GROUPBOX "Hacks",IDC_MISCOPT2,140,7,205,150
CONTROL "Disable Xa Decoding",IDC_XA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,143,15,79,10
CONTROL "Disable Cd Audio",IDC_CDDA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,143,30,68,10
CONTROL "Black && White Movies",IDC_MDEC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,143,45,84,10
Expand All @@ -129,12 +129,14 @@ BEGIN
CONTROL "Compatibility hacks (Raystorm/VH-D/MML/Cart World/...)",IDC_HACKFIX,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,143,105,195,10
CONTROL "Widescreen (GTE Hack)",IDC_WIDESCREEN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,143,120,93,10
GROUPBOX "Select Psx System Type",IDC_SELPSX,7,141,130,35
CONTROL "Autodetect",IDC_PSXAUTO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,155,48,10
COMBOBOX IDC_PSXTYPES,75,155,53,50,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
CONTROL "Disable all hacks",IDC_NOHACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,143,155,69,10
DEFPUSHBUTTON "OK",IDOK,231,162,50,14
PUSHBUTTON "Cancel",IDCANCEL,291,162,50,14
CONTROL "CPU Overclocking",IDC_PSXSTOCK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,143,135,93,10
COMBOBOX IDC_PSXCLOCK,283,135,53,50,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
GROUPBOX "Select PSX System Type",IDC_SELPSX,7,156,130,35
CONTROL "Autodetect",IDC_PSXAUTO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,170,48,10
COMBOBOX IDC_PSXTYPES,75,170,53,50,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
CONTROL "Disable all hacks",IDC_NOHACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,143,170,69,10
DEFPUSHBUTTON "OK",IDOK,231,177,50,14
PUSHBUTTON "Cancel",IDCANCEL,291,177,50,14
END

IDD_NETPLAY DIALOG 0, 0, 165, 95
Expand Down Expand Up @@ -368,6 +370,17 @@ MAIN_LOGO BITMAP "gui\\pcsxr.bmp"
//

1 RT_MANIFEST "gui\\pcsxr.exe.manifest"

/////////////////////////////////////////////////////////////////////////////
//
// AFX_DIALOG_LAYOUT
//

IDD_CPUCONF AFX_DIALOG_LAYOUT
BEGIN
0
END

#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////

Expand Down
6 changes: 5 additions & 1 deletion win32/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
#define IDC_DEBUG 1053
#define IDC_GPR7 1054
#define IDC_LISTCDR 1054
#define IDC_CUSTOM1 1054
#define IDC_GPR8 1055
#define IDC_LISTBIOS 1055
#define IDC_GPR9 1056
Expand Down Expand Up @@ -309,6 +310,9 @@
#define IDC_HACKFIX 1267
#define IDC_MEMHACK 1268
#define IDC_NOHACK 1269
#define IDC_SELPSXCLOCK 1270
#define IDC_PSXSTOCK 1271
#define IDC_PSXCLOCK 1272
#define ID_FILE_EXIT 40001
#define ID_HELP_ABOUT 40002
#define ID_FILE_RUN_CD 40003
Expand Down Expand Up @@ -363,7 +367,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 117
#define _APS_NEXT_COMMAND_VALUE 40047
#define _APS_NEXT_CONTROL_VALUE 1054
#define _APS_NEXT_CONTROL_VALUE 1055
#define _APS_NEXT_SYMED_VALUE 102
#endif
#endif

0 comments on commit 3f11d29

Please sign in to comment.