PPU Reset & Timings
PPU Reset & Timings
Some PPU Reset stuff is documented here: http://wiki.nesdev.com/w/index.php/PPU_power_up_state
While trying to verify that info, I've found out something else:
Port 2007h.READs are also locked during the reset period.
Even if VRAM is completely filled with nonzero values, 2007h.READs do always return 00h during the "reset period". I don't know why it is THAT value (I'd guess that the "00h" is actually "open bus").
On my PAL NES, the "reset period" lasts until 311 lines after reset (=until END of vblank), as said in the wiki article.
On tepple's NTSC NES, that "reset period" lasts until around 261 lines after reset (=until END of vblank), that's different as in the wiki article; which says around 241 lines after reset (=until BEGIN of vblank).
Looks as if the wiki article is wrong about NTSC reset timings. Or are there different NTSC PPUs with different timings?
Well, or maybe BOTH is correct: 2007h.READs (what I was testing) being unlocked 261 lines after reset, and things like 2006h.WRITEs (what the wiki ariticle talks about) being unlocked 241 lines after reset - though that'd be pretty odd.
The test program that I was using can be found here: viewtopic.php?p=99773#p99773 (pputest.zip). The first two lines show reset related timings (in "loop cycle" steps; the actual "clock cycle" values would be somewhat higher). First line is time from Reset till 2007h.READ unlocking, and second line is time from 2007h.READ unlocking till next vblank NMI.
On my PAL NES (manufactured around 1991) with RP2A07A CPU/APU and RP2C07-0 PPU I am getting values 0BB9 and 0029EA (=reset period is 311 lines long).
On tepple's NTSC NES, the values are 0A7D and 002CBC (=reset period is 261 lines long, or maybe a little bit shorter).
According to the timings in the wiki article, the test results would be around 09B0 and 003070 (=reset period would be 241 lines long).
While trying to verify that info, I've found out something else:
Port 2007h.READs are also locked during the reset period.
Even if VRAM is completely filled with nonzero values, 2007h.READs do always return 00h during the "reset period". I don't know why it is THAT value (I'd guess that the "00h" is actually "open bus").
On my PAL NES, the "reset period" lasts until 311 lines after reset (=until END of vblank), as said in the wiki article.
On tepple's NTSC NES, that "reset period" lasts until around 261 lines after reset (=until END of vblank), that's different as in the wiki article; which says around 241 lines after reset (=until BEGIN of vblank).
Looks as if the wiki article is wrong about NTSC reset timings. Or are there different NTSC PPUs with different timings?
Well, or maybe BOTH is correct: 2007h.READs (what I was testing) being unlocked 261 lines after reset, and things like 2006h.WRITEs (what the wiki ariticle talks about) being unlocked 241 lines after reset - though that'd be pretty odd.
The test program that I was using can be found here: viewtopic.php?p=99773#p99773 (pputest.zip). The first two lines show reset related timings (in "loop cycle" steps; the actual "clock cycle" values would be somewhat higher). First line is time from Reset till 2007h.READ unlocking, and second line is time from 2007h.READ unlocking till next vblank NMI.
On my PAL NES (manufactured around 1991) with RP2A07A CPU/APU and RP2C07-0 PPU I am getting values 0BB9 and 0029EA (=reset period is 311 lines long).
On tepple's NTSC NES, the values are 0A7D and 002CBC (=reset period is 261 lines long, or maybe a little bit shorter).
According to the timings in the wiki article, the test results would be around 09B0 and 003070 (=reset period would be 241 lines long).
Re: PPU Reset & Timings
I remember it having been intended to mean the chip comes out of reset at the end of vblank. There may have been a typo. I'll fix it when I get time.
Re: PPU Reset & Timings
Oops, oh, no. I've misread the article. You are right it says 29658 cycles. And later on explains that 29658 is 261 lines. Everything fine then.
It does somewhere else explain that "27384 is almost 241 * 341/3 (241 scanlines)" that was somehow confusing & misleading me.
It does somewhere else explain that "27384 is almost 241 * 341/3 (241 scanlines)" that was somehow confusing & misleading me.
Re: PPU Reset & Timings
About the http://wiki.nesdev.com/w/index.php/Clock_rate article...
Here are some signals typed-up from pictures seen on an analog scope:
/NMI is toggled on & off at the begin of the line (after the ending "-_C-" blanking part of the previous line).
VSYNC is toggled at HSYNC, while active, it changes the "-_C-" part to "-___", and also changes the next lines "picture" part from "---" to "___".
What you can see in the above drawings (and what is probably also mentioned on many other places) is that PAL outputs only 239 picture lines, not 240 (as said in the wiki article; unless I've somehow misread that, too).
So a PAL frame should consist of these 312 lines:
I guess NTSC should be the same, but with only 20 lines vblank... unless NTSC outputs more or less than 239 picture lines?
Here are some signals typed-up from pictures seen on an analog scope:
Code: Select all
PAL Vblank Start Timing
Line <--Line238--><--Line239--><--Line240--><--Line241--><--Line242-->
/NMI ---------------------------------------__________________________
Video: PPPPPPPPP-_C-PPPPPPPPP-_C-----------_C-----------_C-----------_C-
PAL Vblank Middle Timing
Line <--Line268--><--Line269--><--Line270--><--Line271--><--Line272-->
/NMI _________________________________________________________________
Video: ----------_C-----------____________-____________-____________-_C-
PAL Vblank End Timing
Line <--Line310--><--Line311--><--Line000--><--Line001--><--Line002-->
/NMI _____________----------------------------------------------------
Video: ----------_C-----------_C-----------_C-PPPPPPPPP-_C-PPPPPPPPP-_C-
Whereas
For Video: P=Picture, -=Blank, _=Sync, C=ColorBurst
VSYNC is toggled at HSYNC, while active, it changes the "-_C-" part to "-___", and also changes the next lines "picture" part from "---" to "___".
What you can see in the above drawings (and what is probably also mentioned on many other places) is that PAL outputs only 239 picture lines, not 240 (as said in the wiki article; unless I've somehow misread that, too).
Code: Select all
1 line pre-rendering
239 lines rendering
1 line post-rendering
70 lines vblank
1 line post-blank
Re: PPU Reset & Timings
Oh, and the missing dot...
I've read this somewhere else aleady, but here's it again, confirmed by my test proggy: There is missing dot on PAL consoles. And on NTSC consoles it does actually miss only if BG layer is enabled (does NOT miss if BG and OBJ layers are both off) (haven't tested what happens when only OBJ layer is on).
According to the http://wiki.nesdev.com/w/index.php/Clock_rate, the missing dot is located in the "pre-render" (aka "post-blank") scanline. How was that confirmed, and is it really true? Asking because it'd be a BAD location. From my experiences, analog CRT TVs do need some time to "settle" on the HSYNC rate. For example, if you display a vertical line, and then add/remove one dot, then the vertical line will look somehow curved in next 10-15 scanlines.
If the missing dot occurs right before the picture rendering period, then the topmost scanlines of the picture should look somehow distorted. Instead of a vertical line you would get the curved-line effect in each 2nd frame, and a normal vertical line in each other frame (which together may look like a flimmering bold line). Is there any such effect on NTSC NES consoles?
Of course, 224 lines NTSC TVs will clip the upper ~8 lines, so that would also "hide" dirt effects in that lines.
For reference:
The NTSC SNES is having it's missing dot in the post-rendering line (which means no dirt).
The PAL SNES in interlace mode is having a long scanline located at end of vblank (which does actually produce that curvy-line dirt effect)).
I've read this somewhere else aleady, but here's it again, confirmed by my test proggy: There is missing dot on PAL consoles. And on NTSC consoles it does actually miss only if BG layer is enabled (does NOT miss if BG and OBJ layers are both off) (haven't tested what happens when only OBJ layer is on).
According to the http://wiki.nesdev.com/w/index.php/Clock_rate, the missing dot is located in the "pre-render" (aka "post-blank") scanline. How was that confirmed, and is it really true? Asking because it'd be a BAD location. From my experiences, analog CRT TVs do need some time to "settle" on the HSYNC rate. For example, if you display a vertical line, and then add/remove one dot, then the vertical line will look somehow curved in next 10-15 scanlines.
If the missing dot occurs right before the picture rendering period, then the topmost scanlines of the picture should look somehow distorted. Instead of a vertical line you would get the curved-line effect in each 2nd frame, and a normal vertical line in each other frame (which together may look like a flimmering bold line). Is there any such effect on NTSC NES consoles?
Of course, 224 lines NTSC TVs will clip the upper ~8 lines, so that would also "hide" dirt effects in that lines.
For reference:
The NTSC SNES is having it's missing dot in the post-rendering line (which means no dirt).
The PAL SNES in interlace mode is having a long scanline located at end of vblank (which does actually produce that curvy-line dirt effect)).
Re: PPU Reset & Timings
If one layer is on but the other is off, the PPU still does all tasks related to the rendering of both layers, it just doesn't show the one that's off. So the dot is indeed skipped even when only sprites are on (I tested this personally even, when I was studying the best way to turn rendering on late in order to transfer more stuff to VRAM).nocash wrote:And on NTSC consoles it does actually miss only if BG layer is enabled (does NOT miss if BG and OBJ layers are both off) (haven't tested what happens when only OBJ layer is on).
I don't know exactly what a "curved line" would look like, but the missing dot does affect how colors are rendered. Someone will explain you how exactly this works because I don't understand the technical details myself, but in practice, that missing dot is there to modify the dot crawl you get in NTSC. You can see the difference in Blargg's NTSC filter, present in Nestopia for example. Games that turn rendering on late (Battletoads is an example) don't have this dot skipped, so the dot crawl looks very different.Is there any such effect on NTSC NES consoles?
Re: PPU Reset & Timings
Can you test scanline timing the same way? It would be nice to confirm if PAL NES crops off the left and right two pixels as seemed to be happening based in this thread: viewtopic.php?f=2&t=6132.nocash wrote:About the http://wiki.nesdev.com/w/index.php/Clock_rate article...
Here are some signals typed-up from pictures seen on an analog scope:
Very interesting to see that it actually only renders 239 scanlines.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
Re: PPU Reset & Timings
If the Reset/Power on time was 261/262 scanlines long, Time Lord wouldn't work. That game is sloppily coded, and never clears frame IRQs after it disables them. If the reset timing is inaccurate, it will get a frame IRQ and will never clear it. This messes up the game after it begins the first level.nocash wrote:On tepple's NTSC NES, that "reset period" lasts until around 261 lines after reset (=until END of vblank), that's different as in the wiki article; which says around 241 lines after reset (=until BEGIN of vblank).
The game works if the first frame begins near scanline 0 or prerender line, and fails if the first frame begins near scanline 240 or vblank line.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
Re: PPU Reset & Timings
Good to know! Thanks.the dot is indeed skipped even when only sprites are on (I tested this personally even
Somehow like this:I don't know exactly what a "curved line" would look like
Code: Select all
Vertical Curved Bold
XX XX xxxxx
XX XX xxxx
XX XX xxxx
XX XX xxx
XX XX xxx
XX XX xxx
XX XX Xx
XX XX Xx
XX XX Xx
XX XX Xx
XX XX Xx
XX XX Xx
XX XX Xx
---
Yup, with the missing dot, there's an integer number of NTSC color cycles (3.5xxMHz) per 2 frames. So the "dot crawl" is just jumping back-and-forth (which will be seen as flimmering, rather than actual crawling). Without the missing dot, there should be some visible crawl (where the dots are constantly wandering back) (or maybe vice-versa: constantly forth).
On PAL it's different, there's an integer number of PAL color cycles (4.xxMHz) per EVERY frame. So there's no crawl, and even no flimmering. Which, I think doesn't actually look any good. The composite artifacts are "perfectly" visible on PAL. With a blurry back-and-forth effect (as on NTSC), the PAL picture might have looked much smoother.
Re: PPU Reset & Timings
Aren't that two different things? From what I understand:If the Reset/Power on time was 261/262 scanlines long, Time Lord wouldn't work...
The game works if the first frame begins near scanline 0 or prerender line, and fails if the first frame begins near scanline 240 or vblank line.
Upon reset the PPU starts in "Line 0", ie. it starts by doing this:
- output 1 blank line
- output 239 picture lines (which will be blank, too, since BG+OBJ is disabled)
- output 1 blank line
- output 20/70 vblank lines (NTSC/PAL)
- unlock the PPU registers NOW
- output 1 blank line
And then start over with the next frame.
Re: PPU Reset & Timings
Like using an oscilloscope instead of TV Set? Should be no need for doing that... The screen resolution of my PAL TV set (in respect to the NES dotclock) is around 260x268 (and yes, the TV Set can display a picture in that area, it doesn't crop anything there).Can you test scanline timing the same way? It would be nice to confirm if PAL NES crops off the left and right two pixels as seemed to be happening based in this thread: viewtopic.php?f=2&t=6132. Very interesting to see that it actually only renders 239 scanlines.
When outputting a 256x240 test picture on the NES (with scroll offset 0000h):
Upper scanline is missing.
Left 2 pixels are missing.
Right 2 pixels are missing.
Visible PAL picture is 252x239 pixels, surrouned by a BLACK border (regardless of any palette settings).
Re: PPU Reset & Timings
I never noticed anything like that... but the only time I can see the complete image is through my capture card... would the effect be visible that way or just with an actual TV?nocash wrote:Is the NTSC NES doing that? If yes, it might be best-visible if you can tweak the TV set to show the top-most scanlines (via VHOLD or VSIZE knobs or so).
IMO, the dot crawl makes static images look better, but the flimmering makes scrolling images more consistent.Without the missing dot, there should be some visible crawl (where the dots are constantly wandering back) (or maybe vice-versa: constantly forth).
Re: PPU Reset & Timings
May vary from hardware to hardware. Analog CRTs are probably more likely to produce that effects. Digital video grabbers might immediately adopt themselves to changed HSYNC timings - or maybe they do compute the average HBLANK time across several scanlines (to eliminate dirty signals) - then they would show the effect, too.I never noticed anything like that... but the only time I can see the complete image is through my capture card... would the effect be visible that way or just with an actual TV?
As far as I understood, the current proof for the missing dot location is that it depends on BG/OBJ enable bits at vblank end. But then it might be also possible that the hardware toggles an even/odd frame flag in that place, and then waits till vblank start, and removes the dot in that place.
Best way to see the missing dot location would be viewing it with a good oscilloscope. Best by strobing the 4016h.W signal (as trigger point) shortly before Vblank start, and, in another test, shortly before Vblank end. Somewhere at that locations one should see a slightly shorter scanline. Or if it's a very good oscilloscope, then one could simply use /NMI or VSYNC as trigger points and scroll the picture left/right towards the vblank start/end locations.
Re: PPU Reset & Timings
I think Blargg was the one that tested this and figured out where the missing do is(n't), and he's usually correct about this stuff. It might not be possible to figure the exact cycle in software, but after aligning the PPU and CPU as much as possible and enabling rendering at different times you can have an idea of the latest this can be done that will still cause the dot to be skipped. Just by looking at the picture you can tell if it's being skipped or not.
Re: PPU Reset & Timings
Okay, I've sent a PM to blargg. Maybe he has more info on how it was tested.
The thing I was wondering about wasn't to see if it gets skipped, but rather where it gets skipped.
The thing I was wondering about wasn't to see if it gets skipped, but rather where it gets skipped.