CPU Overclocking?

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
beannaich
Posts: 207
Joined: Wed Mar 31, 2010 12:40 pm

CPU Overclocking?

Post 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.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post 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.
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post 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.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
beannaich
Posts: 207
Joined: Wed Mar 31, 2010 12:40 pm

Post 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.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

Allowing the CPU to haul ass would break all sorts of raster effects.
User avatar
MottZilla
Posts: 2837
Joined: Wed Dec 06, 2006 8:18 pm

Post 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.
User avatar
Zepper
Formerly Fx3
Posts: 3262
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post 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.
beannaich
Posts: 207
Joined: Wed Mar 31, 2010 12:40 pm

Post 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?
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Post 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.
Useless, lumbering half-wits don't scare us.
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit »

I had tested out a few games, and Jaws is broken on a Dendy or PAL system.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
Eugene.S
Posts: 317
Joined: Sat Apr 18, 2009 4:36 am
Location: UTC+3
Contact:

Post 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?
beannaich
Posts: 207
Joined: Wed Mar 31, 2010 12:40 pm

Post 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.
sleepy9090
Posts: 81
Joined: Fri Aug 22, 2008 10:04 am

Post 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 :) )
Post Reply