Page 1 of 1

CPU Overclocking?

Posted: Sun Aug 28, 2011 9:06 pm
by beannaich
Is it possible to emulate an overclocked CPU, to allow games to run more smoothly under stress? Or would the PPU keep sync on it, and therefor limit it?

I just tried this with Mega Man 3, having the PPU running at 1/3 it's normal speed and it seemed to have a very positive effect! Just wondering if most games would benefit from something like this, cause if they do I would definitely make it an option in my emulator.

Posted: Sun Aug 28, 2011 9:23 pm
by tokumaru
Sure it is, even Nesticle allowed you to adjust the number of CPU cycles per frame (or scanline, I don't remember). It's also been done on hardware, but the audio gets screwed up because the note frequencies are derived from the CPU clock.

Some games will benefit from it, but others will glitch to various degrees, because a lot of games rely on timed code for visual effects.

Posted: Sun Aug 28, 2011 11:37 pm
by Dwedit
I think the best approach is to simulate how the Dendy did it.
You know how there's one final scanline (before NMI) which is a blanking line? The Dendy instead runs 51 blanking scanlines at that point. So games which rely on timed code still work, and the CPU runs faster with no side effects. If you want to run 300 extra scanlines at that point, you could even do that, and most games would still synchronize correctly. Some wouldn't, because they turn the screen off early and assume that vblank starts very shortly from that point, so they start waiting for a Sprite 0 hit before vblank has ended.
Of course, this will also break every game which attempts to detect the region.

But Dendy was a 50 FPS PAL system. You need to speed up the system to 60 FPS. And if you're doing cycle-accurate sound emulation, you would need to correct the sound pitches for all channels for this new "overclocked NTSC" mode. Software played PCM will play back faster, but you can fix the other sound channels.

Posted: Mon Aug 29, 2011 8:45 am
by beannaich
Couldn't I also just keep the APU running at the same clock? That would keep all the tones accurate, while still allowing the CPU to haul ass. Take the following pseudo-code:

Code: Select all

float cycles = CPU.Execute();

PPU.Execute(cycles * 3f);
APU.Execute(cycles);
Compared to the overclocked version:

Code: Select all

float cycles = CPU.Execute();

PPU.Execute(cycles);
APU.Execute(cycles / 3f);
Or would this cause errors because of DPCM IRQ timings? That is the only reason I can see why this wouldn't work.

Posted: Mon Aug 29, 2011 8:56 am
by tepples
Allowing the CPU to haul ass would break all sorts of raster effects.

Posted: Mon Aug 29, 2011 9:04 am
by MottZilla
In emulation, overclocking the CPU can be done just fine. I did it in my emulator by just changing the ratio of CPU clocks to PPU clocks. Obviously games with timed code for raster effects break. But some games benefit and work just fine, for example Teenage Mutant Ninja Turtles the first game has slowdown and often causes the status bar/background to flicker since its sprite hit zero based and too much slowdown causes this to be missed normally. But if the CPU runs faster then it never gets bogged down enough to miss.

There are other games that benefit too. I think there was a bugs bunny game that had quite a change. Games that use CPU based IRQs need adjustment so their still trigger at the right time, PPU based do not. As previously mentioned any games like the RARE developed ones such as Battletoads will break due to precise timed code but I don't know that these games would benefit from overclocking anyway. I just remembered Kirby's Adventure shows improvement by being overclocked.

Posted: Mon Aug 29, 2011 9:12 am
by Zepper
I'm giving an example: Rockman Complete Works, for PSX. There's absolutely no slowdown or sprite flickering. The 6502 PRG data is intact, only the graphics were ported to the PSX format.

Posted: Mon Aug 29, 2011 9:16 am
by beannaich
tepples wrote:Allowing the CPU to haul ass would break all sorts of raster effects.
It would of course be an option in emulator. Maybe a slider bar to change the system to certain pre-configured frequencies?
MottZilla wrote:I just remembered Kirby's Adventure shows improvement by being overclocked.
How do games like Castlevania, Contra, and Mega Man handle the overclocking?

Posted: Mon Aug 29, 2011 1:52 pm
by Bregalad
I'm giving an example: Rockman Complete Works, for PSX. There's absolutely no slowdown or sprite flickering. The 6502 PRG data is intact, only the graphics were ported to the PSX format.
Are you sure the data is actually used ?
I remember the PSX verison of Chrono Trigger contains the original ROM, but I don't think it was used at all.
How do games like Castlevania, Contra, and Mega Man handle the overclocking?
Contra and Mega Man would handle it fine I guess. Castlevania would have problems with the status bar, as it has a time-out on it's wait-for-sprite-zero-hit loop. If you hack it to remove the timeout it will work fine.

Games like Rad Racer might end up completely broken, however, this won't be true if you do it like Dwedit says. In fact his method will only break several rare games that starts forced VBlank early and expect the NMI to come just after that or something in the like. It might be the better way to go. However such overclocking is not feasible on hardware.

Posted: Mon Aug 29, 2011 1:54 pm
by Dwedit
I had tested out a few games, and Jaws is broken on a Dendy or PAL system.

Posted: Mon Aug 29, 2011 3:01 pm
by Eugene.S
Sorry, offtop.

HardWareMan can donate some UMC UA6527P and UA6538 dendy chips to nesdev community for analysis or decapsulation.
Who is interested in it? Who want to take these chips, maybe Quietust?

Posted: Mon Aug 29, 2011 8:04 pm
by beannaich
I guess I'll give it a try soon once I overhaul a few things to allow for this sort of modification. I'll report back with my findings.

Posted: Thu Dec 29, 2011 5:41 pm
by sleepy9090
i oc'd one of mine a few years ago, music is higher in pitch and you can't push them too far. Castlevania II is extra annoying (night/day happens much faster :) )