From ddfdf735dba89e1e05bf4a263b6d24bc4e8045b6 Mon Sep 17 00:00:00 2001 From: feos-tas Date: Sun, 26 Jun 2016 06:50:08 +0000 Subject: [PATCH] overclocking cleanup --- trunk/src/drivers/win/config.cpp | 2 +- trunk/src/drivers/win/timing.cpp | 12 ++++++------ trunk/src/fceu.cpp | 19 +++++++++---------- trunk/src/fceu.h | 4 ++-- trunk/src/ppu.cpp | 17 +++++++++++------ 5 files changed, 29 insertions(+), 25 deletions(-) diff --git a/trunk/src/drivers/win/config.cpp b/trunk/src/drivers/win/config.cpp index 12d7589e..fe709d1d 100644 --- a/trunk/src/drivers/win/config.cpp +++ b/trunk/src/drivers/win/config.cpp @@ -182,7 +182,7 @@ static CFGSTRUCT fceuconfig[] = AC(ntsccol_enable),AC(ntsctint),AC(ntschue), AC(force_grayscale), AC(dendy), - AC(extrascanlines), + AC(postrenderscanlines), AC(vblankscanlines), AC(overclock_enabled), AC(skip_7bit_overclocking), diff --git a/trunk/src/drivers/win/timing.cpp b/trunk/src/drivers/win/timing.cpp index 0a4a5a9d..9f29adec 100644 --- a/trunk/src/drivers/win/timing.cpp +++ b/trunk/src/drivers/win/timing.cpp @@ -36,16 +36,16 @@ void CloseTimingDialog(HWND hwndDlg) skip_7bit_overclocking = (IsDlgButtonChecked(hwndDlg, CB_SKIP_7BIT) == BST_CHECKED); GetDlgItemText(hwndDlg, IDC_EXTRA_SCANLINES, str, 4); - sscanf(str,"%d",&extrascanlines); + sscanf(str,"%d",&postrenderscanlines); GetDlgItemText(hwndDlg, IDC_VBLANK_SCANLINES, str, 4); sscanf(str,"%d",&vblankscanlines); - if (extrascanlines < 0) + if (postrenderscanlines < 0) { - extrascanlines = 0; + postrenderscanlines = 0; MessageBox(hwndDlg, "Overclocking is when you speed up your CPU, not slow it down!", "Error", MB_OK); - sprintf(str,"%d",extrascanlines); + sprintf(str,"%d",postrenderscanlines); SetDlgItemText(hwndDlg,IDC_EXTRA_SCANLINES,str); } else if (vblankscanlines < 0) @@ -62,7 +62,7 @@ void CloseTimingDialog(HWND hwndDlg) else EndDialog(hwndDlg, 0); - totalscanlines = normalscanlines + (overclock_enabled ? extrascanlines : 0); + totalscanlines = normalscanlines + (overclock_enabled ? postrenderscanlines : 0); } /** @@ -94,7 +94,7 @@ BOOL CALLBACK TimingConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar SendDlgItemMessage(hwndDlg,IDC_EXTRA_SCANLINES, EM_SETLIMITTEXT,3,0); SendDlgItemMessage(hwndDlg,IDC_VBLANK_SCANLINES,EM_SETLIMITTEXT,3,0); - sprintf(str,"%d",extrascanlines); + sprintf(str,"%d",postrenderscanlines); SetDlgItemText(hwndDlg,IDC_EXTRA_SCANLINES,str); sprintf(str,"%d",vblankscanlines); diff --git a/trunk/src/fceu.cpp b/trunk/src/fceu.cpp index cd539399..d6ceb6b1 100644 --- a/trunk/src/fceu.cpp +++ b/trunk/src/fceu.cpp @@ -92,17 +92,16 @@ using namespace std; //----------- //overclocking-related -// overclock the console by adding dummy scanlines to PPU loop -// disables DMC DMA and WaveHi filling for these dummies +// overclock the console by adding dummy scanlines to PPU loop or to vblank +// disables DMC DMA, WaveHi filling and image rendering for these dummies // doesn't work with new PPU bool overclock_enabled = 0; -// 7-bit samples have priority over overclocking -bool skip_7bit_overclocking = 1; -int normalscanlines; -int extrascanlines = 0; -int totalscanlines; -int vblankscanlines = 0; bool overclocking = 0; +bool skip_7bit_overclocking = 1; // 7-bit samples have priority over overclocking +int normalscanlines; +int totalscanlines; +int postrenderscanlines = 0; +int vblankscanlines = 0; //------------ int AFon = 1, AFoff = 1, AutoFireOffset = 0; //For keeping track of autofire settings @@ -879,7 +878,7 @@ void FCEU_ResetVidSys(void) { overclock_enabled = 0; normalscanlines = (dendy ? 290 : 240)+newppu; // use flag as number! - totalscanlines = normalscanlines + (overclock_enabled ? extrascanlines : 0); + totalscanlines = normalscanlines + (overclock_enabled ? postrenderscanlines : 0); FCEUPPU_SetVideoSystem(w || dendy); SetSoundVariables(); } @@ -968,7 +967,7 @@ void FCEUI_SetRegion(int region) { break; } normalscanlines += newppu; - totalscanlines = normalscanlines + (overclock_enabled ? extrascanlines : 0); + totalscanlines = normalscanlines + (overclock_enabled ? postrenderscanlines : 0); FCEUI_SetVidSystem(pal_emulation); RefreshThrottleFPS(); #ifdef WIN32 diff --git a/trunk/src/fceu.h b/trunk/src/fceu.h index 572684dd..bea3e656 100644 --- a/trunk/src/fceu.h +++ b/trunk/src/fceu.h @@ -9,12 +9,12 @@ void ResetGameLoaded(void); //overclocking-related extern bool overclock_enabled; +extern bool overclocking; extern bool skip_7bit_overclocking; extern int normalscanlines; -extern int extrascanlines; extern int totalscanlines; +extern int postrenderscanlines; extern int vblankscanlines; -extern bool overclocking; extern bool AutoResumePlay; extern char romNameWhenClosingEmulator[]; diff --git a/trunk/src/ppu.cpp b/trunk/src/ppu.cpp index ffa0a62b..ba4b3cfe 100644 --- a/trunk/src/ppu.cpp +++ b/trunk/src/ppu.cpp @@ -1225,12 +1225,17 @@ static void Fixit1(void) { void MMC5_hb(int); //Ugh ugh ugh. static void DoLine(void) { + if (overclocking) + { + X6502_Run(256 + 69); + scanline++; + X6502_Run(16); + return; + } + int x; - // scanlines after 239 are dummy for dendy, and Xbuf is capped at 0xffff bytes, don't let it overflow - // send all future writes to the invisible sanline. the easiest way to "skip" them altogether in old ppu - // todo: figure out what exactly should be skipped. it's known that there's no activity on PPU bus - uint8 *target = XBuf + ((scanline < 240 ? scanline : 240) << 8); - u8* dtarget = XDBuf + ((scanline < 240 ? scanline : 240) << 8); + uint8 *target = XBuf + (scanline << 8); + u8* dtarget = XDBuf + (scanline << 8); if (MMC5Hack) MMC5_hb(scanline); @@ -1815,7 +1820,7 @@ int FCEUPPU_Loop(int skip) { if (DMC_7bit && skip_7bit_overclocking) totalscanlines = normalscanlines; else - totalscanlines = normalscanlines + (overclock_enabled ? extrascanlines : 0); + totalscanlines = normalscanlines + (overclock_enabled ? postrenderscanlines : 0); for (scanline = 0; scanline < totalscanlines; ) { //scanline is incremented in DoLine. Evil. :/ deempcnt[deemp]++;