Cycle times of common things reference

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

User avatar
pubby
Posts: 548
Joined: Thu Mar 31, 2016 11:15 am

Cycle times of common things reference

Post by pubby » Mon Nov 19, 2018 6:37 am

I'd like to compile a list of common time measurements to serve as a programming reference.

Code: Select all

NTSC Scanline = 113.667 CPU cycles
NTSC NMI = 2273 CPU cycles
NTSC Frame = 29780.667 CPU cycles
NTSC PPU cycles / CPU cycles = 3

PAL Scanline = 106.5625 CPU cycles
PAL NMI = 7459.375 CPU cycles (too low?)
PAL Frame = 33247.5 CPU cycles
PAL PPU cycles / CPU cycles = 3.2

OAM DMA = 513 cycles (+1 on odd CPU cycles)
Do these numbers look right? Most of them I had to calculate myself because I couldn't find them on the wiki, and I'm pretty sure I made mistakes.

I'd also like to include a reference to the delay DMC can add, but I've had a real tough time finding information on this. I think in the worst case it can add 4 cycles every 432 cycles? Is that correct?

User avatar
koitsu
Posts: 4216
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Cycle times of common things reference

Post by koitsu » Mon Nov 19, 2018 12:04 pm

The only pages that mention CPU cycle correlations are these:

https://wiki.nesdev.com/w/index.php/PPU#Notes
https://wiki.nesdev.com/w/index.php/Con ... ronization
https://wiki.nesdev.com/w/index.php/PPU_frame_timing

Other places are nesdev forum threads, which are not as helpful (re: not as organised). We really should have a cycle breakdown chart somewhere (i.e. I'm sorry you had to calculate these by hand).

lidnariq
Posts: 8786
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Cycle times of common things reference

Post by lidnariq » Mon Nov 19, 2018 12:09 pm

I'd say that that information is all here, but since these are mostly properties of the PPU we expressed them there in terms of pixels and scanlines, not CPU cycles.

User avatar
Sumez
Posts: 909
Joined: Thu Sep 15, 2016 6:29 am
Location: Denmark (PAL)

Re: Cycle times of common things reference

Post by Sumez » Mon Nov 19, 2018 2:14 pm

Yeah it would be a really good idea to expand that list with exact cycle counts. Or create a dedicated page for that. It's something I need a lot, and I always forget where to look.

User avatar
gauauu
Posts: 659
Joined: Sat Jan 09, 2016 9:21 pm
Location: Central Illinois, USA
Contact:

Re: Cycle times of common things reference

Post by gauauu » Mon Nov 19, 2018 4:33 pm

I spent awhile digging through the wiki when I first started a couple years ago, and was bummed that this didn't exist in a page. Thanks for putting it in one place.

User avatar
koitsu
Posts: 4216
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Cycle times of common things reference

Post by koitsu » Mon Nov 19, 2018 4:51 pm

lidnariq wrote:I'd say that that information is all here, but since these are mostly properties of the PPU we expressed them there in terms of pixels and scanlines, not CPU cycles.
Not to mention, only two pages on the entire Wiki reference that "Clock rate" page:

https://wiki.nesdev.com/w/index.php/NES_reference_guide -- "Clock rate of various components in different variants of NES"
https://wiki.nesdev.com/w/index.php/Detect_TV_system -- "A game can use it to compensate for differences in clock rate among various NES models."

Nothing else links to it, not even in References or See also or Notes or anything. It's no wonder nobody can find this page of super useful info! :-) (I've seen that page a couple times but I never remember where to find it either.)

And yes, having correlating CPU cycle counts (or at what particular CPU cycle something happens at from start of VBlank) would be super useful, as coders are going to need to know exactly this. I don't know if such information should go into the "Clock rate" page, or a separate page.

User avatar
rainwarrior
Posts: 7677
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Cycle times of common things reference

Post by rainwarrior » Mon Nov 19, 2018 4:58 pm

Sumez wrote:Yeah it would be a really good idea to expand that list with exact cycle counts. Or create a dedicated page for that. It's something I need a lot, and I always forget where to look.
I would say that "Clock rate" is already the dedicated page for it. The problem is more about naming and discovery.

My question would be: what name for such an article would have permitted you to find it? What search terms did you use when looking for it?

User avatar
Banshaku
Posts: 2328
Joined: Tue Jun 24, 2008 8:38 pm
Location: Fukuoka, Japan
Contact:

Re: Cycle times of common things reference

Post by Banshaku » Mon Nov 19, 2018 6:23 pm

It could be accessible from the nes reference guide and could be created as a link under clock rate. The name could be something like "cycle reference chart", which an explanation after the link that say it explain this is contains a chart for CPU cycle for specific task on the nes.

It could be a start and the naming (and english) could be improved later.

edit:

created place holder, always wanted a page like that:

http://wiki.nesdev.com/w/index.php/Cycl ... ence_chart

User avatar
tokumaru
Posts: 11466
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Cycle times of common things reference

Post by tokumaru » Mon Nov 19, 2018 7:20 pm

If this is supposed to be accurate, I don't think we should be rounding numbers.

User avatar
Banshaku
Posts: 2328
Joined: Tue Jun 24, 2008 8:38 pm
Location: Fukuoka, Japan
Contact:

Re: Cycle times of common things reference

Post by Banshaku » Mon Nov 19, 2018 7:32 pm

Sure, this is why it's a place holder and we can improve it anyway we like. It just a start and we now have a page for it ;)

User avatar
rainwarrior
Posts: 7677
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Cycle times of common things reference

Post by rainwarrior » Mon Nov 19, 2018 8:00 pm

I think that page should either redirect to the Clock rate article or the other way around, rather than create two parallel articles with subtly different sets of the same information. "Cycle reference chart" is probably the better name, so my vote is to make "Clock rate" the redirect.

User avatar
Banshaku
Posts: 2328
Joined: Tue Jun 24, 2008 8:38 pm
Location: Fukuoka, Japan
Contact:

Re: Cycle times of common things reference

Post by Banshaku » Mon Nov 19, 2018 8:32 pm

This is perfectly fine too. For some reason the clock rate never got my attention by the title only so I never thought of looking there ^^;;

The goal was to get the ball rolling so now it is! The new chart is basically more some reference so developer knows what to do with their code so it could be an addendum to the current article with a proper link at the top so it could this be easily found.

What I would like to make someday (which I was hoping to do 10 years ago) is a section with simple "how-to" for dev and I think that chart is one of those since it's not specifically technical on "how" it happen behind the scene but more on "how much" a unit take time, which is very useful for timing code.

No rush to move it yet but will check the clock rate later to see how to incorporate it inside.

User avatar
koitsu
Posts: 4216
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Cycle times of common things reference

Post by koitsu » Mon Nov 19, 2018 10:07 pm

I'll take care of merging the two pages, and making "Clock rate" redirect to the new page.

User avatar
koitsu
Posts: 4216
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Cycle times of common things reference

Post by koitsu » Mon Nov 19, 2018 10:48 pm

All done. I fixed some typos, properly made references, and added Dendy details.

I'm still in the process of cleaning up redirections on all the other pages (I know I don't have to do this, but consistency is good).

Edit: all pages have been updated, excluding the Talk pages, which I opted to leave alone for obvious reasons.

User avatar
Banshaku
Posts: 2328
Joined: Tue Jun 24, 2008 8:38 pm
Location: Fukuoka, Japan
Contact:

Re: Cycle times of common things reference

Post by Banshaku » Mon Nov 19, 2018 11:23 pm

All in one table, even better now.

Should hblank be added too? I think it was useful information when timing raster.

Post Reply