Skip to content

Commit

Permalink
Integrate SonofUgly's overclocking mechanism
Browse files Browse the repository at this point in the history
SonofUgly/PCSX-Reloaded@3f11d29

Integrated with a few small changes.
  • Loading branch information
iCatButler committed May 8, 2016
1 parent cd126bc commit 1a30cfb
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 13 deletions.
35 changes: 35 additions & 0 deletions libpcsxcore/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,41 @@ int CheckCdrom() {
else Config.PsxType = PSX_TYPE_NTSC; // ntsc
}


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

if (CdromLabel[0] == ' ') {
strncpy(CdromLabel, CdromId, 9);
}
Expand Down
5 changes: 4 additions & 1 deletion libpcsxcore/psxcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ typedef struct {
u32 AltSpeed2;
u8 HackFix;
u8 MemHack;
boolean OverClock; // enable overclocking
u8 PsxClock;
#ifdef _WIN32
char Lang[256];
#endif
Expand All @@ -185,8 +187,9 @@ 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 /* 33.8688 MHz */

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

QueryKeyV("OverClock", Conf->OverClock);

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 +152,11 @@ void SaveConfig() {
SetKeyV("WindowPosY", Conf->WindowPos[1]);
SetKeyV("HackFix", Conf->HackFix);
SetKeyV("MemHack", Conf->MemHack);
SetKeyV("OverClock", Conf->OverClock);

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

RegCloseKey(myKey);
}
Expand Down
28 changes: 28 additions & 0 deletions win32/gui/WndMain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1356,9 +1356,11 @@ BOOL CALLBACK ConfigureCpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPar
Button_SetText(GetDlgItem(hW,IDC_SAVEWINDOWPOS), _("Save window position"));
Button_SetText(GetDlgItem(hW,IDC_HACKFIX), _("Compatibility hacks (Raystorm/VH-D/MML/Cart World/...)"));
Button_SetText(GetDlgItem(hW,IDC_MEMHACK), _("Wipeout MemHack"));
Button_SetText(GetDlgItem(hW,IDC_OVRCLOCK), _("CPU Overclocking"));

Static_SetText(GetDlgItem(hW,IDC_MISCOPT), _("Options"));
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 @@ -1377,18 +1379,33 @@ BOOL CALLBACK ConfigureCpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPar
Button_SetCheck(GetDlgItem(hW,IDC_SAVEWINDOWPOS), Config.SaveWindowPos);
Button_SetCheck(GetDlgItem(hW,IDC_HACKFIX), Config.HackFix);
Button_SetCheck(GetDlgItem(hW,IDC_MEMHACK), Config.MemHack);
Button_SetCheck(GetDlgItem(hW,IDC_OVRCLOCK), Config.OverClock);

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);
EnableWindow(GetDlgItem(hW, IDC_DEBUG), FALSE);
}

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

if (Config.OverClock)
EnableWindow(GetDlgItem(hW, IDC_PSXCLOCK), TRUE);
else
EnableWindow(GetDlgItem(hW, IDC_PSXCLOCK), FALSE);
break;

case WM_COMMAND: {
Expand All @@ -1399,6 +1416,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 @@ -1426,6 +1445,8 @@ BOOL CALLBACK ConfigureCpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPar
Config.SaveWindowPos = Button_GetCheck(GetDlgItem(hW,IDC_SAVEWINDOWPOS));
Config.HackFix = Button_GetCheck(GetDlgItem(hW, IDC_HACKFIX));
Config.MemHack = Button_GetCheck(GetDlgItem(hW, IDC_MEMHACK));
Config.OverClock = Button_GetCheck(GetDlgItem(hW, IDC_OVRCLOCK));


if(Config.SaveWindowPos) {
GetWindowRect(gApp.hWnd, &rect);
Expand All @@ -1448,6 +1469,13 @@ BOOL CALLBACK ConfigureCpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPar

return TRUE;

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

case IDC_CPU:
if (Button_GetCheck(GetDlgItem(hW,IDC_CPU))) {
EnableWindow(GetDlgItem(hW,IDC_DEBUG), TRUE);
Expand Down
41 changes: 30 additions & 11 deletions win32/pcsxr.rc
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,19 @@ BEGIN
CTEXT "PCSXR EMU\nVersion x.x",IDC_PCSXR_ABOUT_TEXT,22,10,112,15,0,WS_EX_TRANSPARENT
CTEXT "PCSXR a psx emulator...",IDC_PCSXR_ABOUT_AUTHORS,10,35,135,63,0,WS_EX_TRANSPARENT
CTEXT "Greets to...",IDC_PCSXR_ABOUT_GREETS,45,110,232,65
CONTROL 113,IDC_STATIC,"Static",SS_BITMAP | WS_BORDER,155,10,171,101
CONTROL SPLASH_LOGO,IDC_STATIC,"Static",SS_BITMAP | WS_BORDER,155,10,171,101
GROUPBOX "",IDC_STATIC,5,25,145,77
GROUPBOX "",IDC_STATIC,43,100,234,79
END

IDD_CPUCONF DIALOGEX 0, 0, 240, 320
IDD_CPUCONF DIALOGEX 0, 0, 241, 363
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Cpu Config"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
DEFPUSHBUTTON "OK",IDOK,51,289,50,14
PUSHBUTTON "Cancel",IDCANCEL,120,289,50,14
GROUPBOX "Misc Options",IDC_MISCOPT,5,5,220,236
DEFPUSHBUTTON "OK",IDOK,51,323,50,14
PUSHBUTTON "Cancel",IDCANCEL,119,323,50,14
GROUPBOX "Misc Options",IDC_MISCOPT,6,5,220,236
CONTROL "Disable Xa Decoding",IDC_XA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,15,205,10
CONTROL "Sio Irq Always Enabled",IDC_SIO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,30,205,10
CONTROL "Spu Irq Always Enabled",IDC_SPUIRQ,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,45,205,10
Expand All @@ -124,13 +124,17 @@ BEGIN
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,150,205,10
CONTROL "InuYasha Sengoku Battle Fix",IDC_VSYNCWA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,165,205,10
CONTROL "Widescreen (GTE Hack)",IDC_WIDESCREEN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,180,205,10
GROUPBOX "Select Psx System Type",IDC_SELPSX,5,255,220,35
CONTROL "Autodetect",IDC_PSXAUTO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,265,80,10
GROUPBOX "Select Psx System Type",IDC_SELPSX,6,255,220,35
CONTROL "Autodetect",IDC_PSXAUTO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,265,80,10
COMBOBOX IDC_PSXTYPES,105,265,53,50,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
CONTROL "Hide cursor",IDC_HIDECURSOR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,195,205,10
CONTROL "Save window position",IDC_SAVEWINDOWPOS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,210,205,10
CONTROL "Compatibility hacks (Raystorm/VH-D/MML/Cart World/...)",IDC_HACKFIX, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,225,205,10
CONTROL "Wipeout MemHack", IDC_MEMHACK, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 10, 240, 205, 10
CONTROL "Compatibility hacks (Raystorm/VH-D/MML/Cart World/...)",IDC_HACKFIX,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,225,205,10
CONTROL "Wipeout MemHack",IDC_MEMHACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,240,205,10
GROUPBOX "CPU Overclocking",IDC_SELPSXCLOCK,7,290,220,32
CONTROL "Enable",IDC_OVRCLOCK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,300,80,10
COMBOBOX IDC_PSXCLOCK,105,297,53,50,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
END

IDD_NETPLAY DIALOG 0, 0, 165, 95
Expand Down Expand Up @@ -292,9 +296,9 @@ BEGIN
IDD_CPUCONF, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 225
RIGHTMARGIN, 226
TOPMARGIN, 7
BOTTOMMARGIN, 287
BOTTOMMARGIN, 337
END

IDD_NETPLAY, DIALOG
Expand Down Expand Up @@ -350,20 +354,35 @@ END
// remains consistent on all systems.
IDI_APP_ICON ICON "gui\\pcsxr.ico"


/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//

SPLASH_LOGO BITMAP "gui\\about.bmp"

MAIN_LOGO BITMAP "gui\\pcsxr.bmp"


/////////////////////////////////////////////////////////////////////////////
//
// RT_MANIFEST
//

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 @@ -56,6 +56,7 @@
#define IDC_BREAK 1012
#define IDC_DISCPUQKEYS 1012
#define IDC_QKEYS 1012
#define IDC_OVRCLOCK 1012
#define IDC_EDIT1 1013
#define IDC_CDDA 1013
#define IDC_DESCR 1013
Expand All @@ -72,6 +73,7 @@
#define IDC_CDTIMING 1017
#define IDC_SLOWBOOT 1017
#define IDC_ASMCHECK4 1018
#define IDC_PSXCLOCK 1018
#define IDC_ASMCHECK5 1019
#define IDC_RELOAD1 1019
#define IDC_CP07 1020
Expand Down Expand Up @@ -113,6 +115,8 @@
#define IDC_CP021 1034
#define IDC_ASMCHECK20 1034
#define IDC_FIRSTCONTROLLER 1034
#define IDC_SELPSX2 1034
#define IDC_SELPSXCLOCK 1034
#define IDC_CP022 1035
#define IDC_ASMCHECK21 1035
#define IDC_SECONDCONTROLLER 1035
Expand Down Expand Up @@ -359,7 +363,7 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 116
#define _APS_NEXT_RESOURCE_VALUE 117
#define _APS_NEXT_COMMAND_VALUE 40047
#define _APS_NEXT_CONTROL_VALUE 1054
#define _APS_NEXT_SYMED_VALUE 102
Expand Down

0 comments on commit 1a30cfb

Please sign in to comment.