What's the reason for the missing PPU cycle on even frames?

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

Moderator: Moderators

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

Re: What's the reason for the missing PPU cycle on even fram

Post by lidnariq » Tue Feb 20, 2018 12:01 pm

The set of constraints you've lined up is going to be difficult. I think you're either going to need a quite long sinc FIR filter, a very high order IIR filter, or accepting some passband & stop-band ripple. Even a 10th order discrete-time butterworth lowpass (-3dB at 4.2MHz) only gets down to -12dB at 4.5MHz. Sharper filters (chebyshev, elliptic) help a little, but there's going to be a lot of group delay during the transition band.

tepples
Posts: 21975
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: What's the reason for the missing PPU cycle on even fram

Post by tepples » Tue Feb 20, 2018 12:04 pm

What filter is in an actual TV's IF section to separate the AM video from the FM audio?

psycopathicteen
Posts: 2934
Joined: Wed May 19, 2010 6:12 pm

Re: What's the reason for the missing PPU cycle on even fram

Post by psycopathicteen » Wed Feb 21, 2018 9:27 am

It looks like you stumped everybody. I wish there was an easy way of calculating butterworth and chebychev filters in the digital domain.

NewRisingSun
Posts: 1187
Joined: Thu May 19, 2005 11:30 am

Re: What's the reason for the missing PPU cycle on even fram

Post by NewRisingSun » Wed Feb 21, 2018 9:41 am

I have literature on both RF transmitters and television receivers from the mid-1950s, when color NTSC was introduced. I don't think that's pertinent though, because it's too old.

As for filters, most materials on that subject, on-line or in print, expect way too many things to be known by the reader, are gratuitously formalistic, at the same time offensively imprecise in terminology and prose, and generally are not suited for people who just want to skim trying to find what they need. Of course, I say that about pretty much any mathematical subject, so who am I to complain.

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

Re: What's the reason for the missing PPU cycle on even fram

Post by lidnariq » Wed Feb 21, 2018 11:53 am

Unfortunately, the vast majority of the service manuals and schematics I can find are either from the very early days of TV, where everything was valve-based and monochrome, or from after the VLSI revolution and all the TVs do all the interesting signal processing stuff inside a monolithic encapsulated silicon die.

Doing my best to read the valve-based schematic for the Predicta 10L4x chassis, I think it just completely ignores the modulated audio signal altogether and relies on the temporal and spatial bandwidth to hide any crosstalk.

psycopathicteen
Posts: 2934
Joined: Wed May 19, 2010 6:12 pm

Re: What's the reason for the missing PPU cycle on even fram

Post by psycopathicteen » Wed Feb 21, 2018 9:08 pm

I think the easiest way would be to make a quantized version of the frequency gain spectrum you want, and then do a discreet cosine transform.

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

Re: What's the reason for the missing PPU cycle on even fram

Post by lidnariq » Wed Feb 21, 2018 10:36 pm

In English, discrete (easily distinguished; separate in time or space) and discreet (inconspicuous) mean different things. Even though they come from the same root.

Anyway, you've basically just described generic FIR filter design. The DCT isn't particularly good for analysis either (instead of for storage, where it is).

User avatar
TmEE
Posts: 747
Joined: Wed Feb 13, 2008 9:10 am
Location: Estonia, Rapla city (50 and 60Hz compatible :P)
Contact:

Re: What's the reason for the missing PPU cycle on even fram

Post by TmEE » Thu Feb 22, 2018 2:35 am

tepples wrote:What filter is in an actual TV's IF section to separate the AM video from the FM audio?
Vast majority of the designs I have seen use surface acoustic wave filters tuned to particular IF frequencies used.

psycopathicteen
Posts: 2934
Joined: Wed May 19, 2010 6:12 pm

Re: What's the reason for the missing PPU cycle on even fram

Post by psycopathicteen » Thu Feb 22, 2018 5:31 am

lidnariq wrote:Anyway, you've basically just described generic FIR filter design. The DCT isn't particularly good for analysis either (instead of for storage, where it is).
I think the DCT would work because, for symetrical FIR filters the sine wave part of the fourier transform can be ignored, and also every frequency higher than the niquist frequency would be ignored.

Revenant
Posts: 441
Joined: Sat Apr 25, 2015 1:47 pm
Location: FL

Re: What's the reason for the missing PPU cycle on even fram

Post by Revenant » Thu Feb 22, 2018 9:26 am

lidnariq wrote:In English, discrete (easily distinguished; separate in time or space) and discreet (inconspicuous) mean different things. Even though they come from the same root.
Image

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

Re: What's the reason for the missing PPU cycle on even fram

Post by lidnariq » Thu Feb 22, 2018 11:34 am

psycopathicteen wrote:I think the DCT would work because,
The DCT causes spectral smearing, relative to the Fourier transform. As such, it's inappropriate for analysis or filtering.

It's implemented in terms of the Fourier transform, by taking the original input and duplicating it once to produce a symmetric input for analysis. When you take a copy of the original input, reverse it, and append that to the original, that changes the spectral content.

The phase information that was present in the FFT still has to be stored somewhere, and it changes the magnitudes of the specific bins of the result of the DCT.
for symmetrical FIR filters the sine wave part of the Fourier transform can be ignored
A symmetric (specifically "even") FIR filter does have a purely real Fourier transform, and that does mean that the real and imaginary components of the filter input remain in the same parts after multiplication, but the imaginary part is still affected by the filtering.
and also every frequency higher than the nyquist frequency would be ignored.
That's true regardless. Fourier transform of a purely-real input is necessarily symmetric¹, so everything above half the window width is going to be a duplicate of the bottom half. There is nothing actually "above" the Nyquist frequency there, just incorrectly plotting the result as the result of k∈[0,length) instead of k∈(-length÷2,+length÷2]

¹pedantic note: the fourier transform of a real input has an even (mirror symmetry) real component and an odd (180° symmetry) imaginary component.

nocash
Posts: 1210
Joined: Fri Feb 24, 2012 12:09 pm
Contact:

Re: What's the reason for the missing PPU cycle on even fram

Post by nocash » Thu Mar 01, 2018 6:43 am

psycopathicteen wrote:What's the reason for the missing PPU cycle on even frames?
Was it to improve composite picture quality?
Mathematically, they seem to have aimed at making each (two) frames an exact multiple of the NTSC 3.579545MHz color clock cycles (this seems to have been common practice on older pre-PSX systems like C64, NES, SNES).
I am not aware of a good reason for doing that, but they have probably believed that it would improve the picture quality, although I guess it's actually making things worse. And even if there would be some reason for the short scanline: The https://shmups.system11.org/viewtopic.php?f=6&t=61285 says that the short scanline is located right before the first visible scanline - which is really bad (to avoid jittering, it should be located after last visible line, so the TV has enough time could resync itself to hsync's).
psycopathicteen wrote:If it was, they should've had a missing half cycle every frame instead, so that artifacts cancled out entirely.
No! That would highlight the artifacts (the artifacts would be always drawn at the same static locations in all frames, which would make the artifacts more visible). Probably Nintendo actually wanted to do right that - and (fortunately) considered it too difficult to implement "half cycles".

Here are some maths from everynes.htm on the color clock:

Code: Select all

Clock Speeds
  Type               NTSC               PAL                 Dendy
  Master Clock (X1)  21.47727MHz        26.6017125MHz       Like PAL
  Color Clock        3.579545MHz=X1/6   4.43361875MHz=X1/6  Like PAL
  Dot Clock          5.3693175MHz=X1/4  5.3203425MHz=X1/5   Like PAL
  CPU Clock          1.7897725MHz=X1/12 1.66260703MHz=X1/16 1.773448MHz=X1/15
  Frame Rate         60.09914261Hz      50.00697891Hz       Like PAL

Modulator vs PPU Timings
  Type                       NTSC            PAL             Dendy
  Dots per Color Clk         1.5 (6/4)       1.2 (6/5)       1.2 (6/5)
  Color Clks per Scanline    227.3333        284.1666
  Color Clks per One Frame   59561.33        88660.0
  Color Clks per Other Frame 59560.66        88660.0
  Color Clks per Two Frames  119122.0        177320.0
For PAL/NES they've successfully achieved perfect uglyness with exactly 88660.0 color clocks per frame.
For NTSC/NES it's 119122.0 color clocks per TWO frames, which appears better than PAL, without the shortscanline it would be 3x59561.33 = 178684.0 clocks per THREE frames, which might look even better (with slight flimmering, but nearly invisible artifacts, ie. picture quality about as good as on PSX consoles).

As far as I know, one could disable the short scanline effect by disabling BG and OBJ (somewhere during vblank, and enable them when the first scanline gets drawn). I don't have a NTSC/NES console myself... but it might be interesting to patch some commercial/homebrew game to see if it looks better/worse with/without short scanlines (might be a bit difficult since NES doesn't have too much support for scanline IRQs, and stuff like Sprite0 Hit likewise won't work when having BG and OBJ disabled).

User avatar
Dwedit
Posts: 4306
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: What's the reason for the missing PPU cycle on even fram

Post by Dwedit » Thu Mar 01, 2018 8:32 am

I hear that Zelda 2 and Dragon Warrior 2 are heavily affected by the artifacts, so I'd think those would be two games to especially compare on hardware.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

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

Re: What's the reason for the missing PPU cycle on even fram

Post by tokumaru » Thu Mar 01, 2018 10:42 am

nocash wrote:As far as I know, one could disable the short scanline effect by disabling BG and OBJ (somewhere during vblank, and enable them when the first scanline gets drawn).
IIRC, Battletoads is a game that keep rendering disabled at the beginning of the frame, so that's one commercial game you can check out without any modifications (although there will be nothing to compare to).
I don't have a NTSC/NES console myself... but it might be interesting to patch some commercial/homebrew game to see if it looks better/worse with/without short scanlines (might be a bit difficult since NES doesn't have too much support for scanline IRQs, and stuff like Sprite0 Hit likewise won't work when having BG and OBJ disabled).
If you can consistently cause a sprite 0 hit or a sprite overflow *anywhere* on the screen, you can detect the end of vblank by waiting for the flag to be cleared, which happens at the beginning of the pre-render scanline. Then you just wait a little to enable rendering after the frame starts rendering.

psycopathicteen
Posts: 2934
Joined: Wed May 19, 2010 6:12 pm

Re: What's the reason for the missing PPU cycle on even fram

Post by psycopathicteen » Thu Mar 01, 2018 1:09 pm

No! That would highlight the artifacts (the artifacts would be always drawn at the same static locations in all frames, which would make the artifacts more visible). Probably Nintendo actually wanted to do right that - and (fortunately) considered it too difficult to implement "half cycles".
Actually, you're right. In order for there to be 180 degrees phases cancelation, it would need an extra 1/4 cycle each frame.

Post Reply