NTSC emulation test?

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

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

Post by tepples »

byuu wrote:EDIT: darn, doesn't seem they sell PAL CRTs very often anymore, and the ones they do seem to be those dual NTSC/PAL ones.
A conforming dual NTSC/PAL TV should switch to PAL "pixel" aspect ratio (where "pixel" = 1/341 scanline period) when fed a PAL signal.
User avatar
dXtr
Posts: 375
Joined: Tue Sep 21, 2004 12:11 am
Location: Karlshamn (Sweden)

Post by dXtr »

byuu wrote:If someone wants to draw a 256x224x256-color (or less) bitmap, I can make an SNES ROM with a test image. But we need someone with a PAL copier + TV to verify.

I'll use 48/35 for now, until we hear otherwise. I'd be happy with NES verification, too. It actually doesn't look that bad.

Meh, maybe I should just buy a PAL TV and SNES, I think my UFO is supposed to work on both. I've been asking questions on PAL for over two years and never gotten anything concrete :/

EDIT: darn, doesn't seem they sell PAL CRTs very often anymore, and the ones they do seem to be those dual NTSC/PAL ones. Maybe that will work, maybe not ...
I got a crappy PAL TV and a SNES with a SWC DX2.. so I could probably try it out.

edit: but I probably would need some instructions on what I'm supposed to do when testing it ;)
Sorry for misspellings, I'm from Sweden ^^
Near
Founder of higan project
Posts: 1553
Joined: Mon Mar 27, 2006 5:23 pm

Post by Near »

I figured some people here might be interested in this ...

http://board.zsnes.com/phpBB2/viewtopic ... 142#148142

Verdauga Greeneyes took a screenshot of http://i73.photobucket.com/albums/i221/byuusan/som.gif , at a very high resolution (2592x1944), and with a tripod to make sure the image was minimally slanted. I then cropped the "Secret of Mana" logo out of the picture.

Below are my results:

Code: Select all

 127x 43 = 2.953488 -- 256x239 1:1 image size
1140x272 = 4.191176 -- CRT TV image size

43x4.191176 = 180.220568

180.220568 / 127 = 1.419060
So, ~1.42x is very close to tepples' ~1.39x, enough to be the difference between two different TV sets.

But, as we can see, it's definitely way off compared to NTSC's 8:7 (~1.14x). I will probably use a rounded average between our three samples. Maybe 1.40x. It's "close enough", but probably not 100% perfect.

If anyone wants, I can forward them the PAL TV screenshot for double verification. I know it's not a perfect test, but it's the best we can do.
User avatar
blargg
Posts: 3715
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Post by blargg »

It's "close enough", but probably not 100% perfect.
I think it's clear that there is no "perfect", since TVs differ slightly in how they distort the image.

I think porting tepple's test to the SNES is a perfect solution, along with emulator authors providing a horizontal stretch slider so that the user can make the correct box square on whatever they're displaying the emulator with. This way the user can calibrate it as closely as desired, or throw it off to match a particular TV.

We should add NTSC/PAL detection to the ROMs to simplify things for the user.
User avatar
Zepper
Formerly Fx3
Posts: 3262
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper »

If you capture the TV output through a video card and measure the frame, isn't this the correct thing?

EDIT: OK, now I'm curious. If you output the emulator image to the TV, the test still fails. Why?
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

Fx3 wrote:OK, now I'm curious. If you output the emulator image to the TV, the test still fails. Why?
If your emulator assumes square pixels, then your video card will just shoot those square pixels straight out to the TV, likely at 7/12 color cycle per pixel, unless you can tell your video card to run in some 560x480 pixel overscan mode.
User avatar
blargg
Posts: 3715
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Post by blargg »

If you output the emulator image to the TV, the test still fails. Why?
Because TVs don't have pixels, just scanlines whose hue/saturation/luminance varies from left to right. It's the video ENCODER chip that determines the width of a pixel. The NES has a different video encoder than your PC's video output, so the pixel width probably differs. Your PC's video output probably uses a pixel width that matches scanline height, resulting in square pixels on the TV screen, because PC pixels are usually square and you'd want the image to appear nearly the same on a TV as it does on your PC display.

There's really no difference between the above situation and a normal PC video card connected to a CRT-based display. In the same way, the PC video card determines the width of a pixel, and could make them rectangular if it wanted.
NewRisingSun
Posts: 1510
Joined: Thu May 19, 2005 11:30 am

Post by NewRisingSun »

I thought this aspect ratio business was a done deal already.
If you capture the TV output through a video card and measure the frame, isn't this the correct thing?
Most TV cards don't capture the image properly, at least not with default settings.

Correct pixel aspect ratio (NTSC):
Active scanline is 52+59/90 µs (ITU-R BT.470-6). NES' pixel clock is precisely 6/4*Fsc = 7,5*63/88 MHz, giving 282.7 pixels, or 282 full pixels horizontally.
Active height is 486 scanlines for interlaced, or 243 for progressive pictures (one is always black in progressive, so 242. Since that black line is part of the 4:3 area however, we must include it).
Therefore, the NES active area including overscan is 282x243. For square pixels forming a 4:3 image, you'd need 243*4/3=324 horizontal pixels, giving you the NTSC NES' precise pixel aspect ratio of 324/282, or 54/47, about 1.148936 :)

Correct pixel aspect ratio (PAL):
Active scanline is 52 µs (ITU-R BT.1700). NES' pixel clock is (1135/4 + 1/625)*15625*6/5 Hz, giving 276.7 pixels, say 276 full pixels.
Active height is 576 scanlines for interlaced, or 288 for progressive.
Therefore, the NES active area including overscan is 276x288. For square pixels, we'd need 288*4/3=384 horizontal pixels, giving you the PAL NES' precise pixel aspect ratio of 384/276, or 32/23, about 1.391304. :)

These values are what you should go for, not by empirically measuring screencaps from consumer-grade TV cards, which rarely get things right, or pushing a ruler against your TV. And if you're trying to get your emulator to imitate the image of every cheap-ass TV out there, you'd have to simulate curvature, overscan, phosphor chromaticities and aperture, dust on the tube, the influence of the earth's magnetic field depending on your particular geographic location (no, really!)...
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

NewRisingSun wrote:Correct pixel aspect ratio (NTSC):
Active scanline is 52+59/90 µs (ITU-R BT.470-6). NES' pixel clock is precisely 6/4*Fsc = 7,5*63/88 MHz, giving 282.7 pixels, or 282 full pixels horizontally.
Active height is 486 scanlines for interlaced, or 243 for progressive pictures (one is always black in progressive, so 242. Since that black line is part of the 4:3 area however, we must include it).
Therefore, the NES active area including overscan is 282x243. For square pixels forming a 4:3 image, you'd need 243*4/3=324 horizontal pixels, giving you the NTSC NES' precise pixel aspect ratio of 324/282, or 54/47, about 1.148936 :)
324/282.7 is still damn close to the 324/283.5 resulting from the easy-to-compute-with assumption that scanline height = 7/12 of the width of a color cycle. (Interestingly enough, this results in the 14x12 pixel metatiles of several Apple II games being perfect squares.)
For square pixels, we'd need 288*4/3=384 horizontal pixels, giving you the PAL NES' precise pixel aspect ratio of 384/276, or 32/23, about 1.391304. :)
I get 1.38800 by not rounding the 276.66 down, but whatever. Good job on coming up with the data behind the exact values.
And if you're trying to get your emulator to imitate the image of every cheap-ass TV out there, you'd have to simulate curvature, overscan
The whole 256x224 myth comes from emus that simulate overscan the wrong way.
NewRisingSun
Posts: 1510
Joined: Thu May 19, 2005 11:30 am

Post by NewRisingSun »

324/282.7 is still damn close to the 324/283.5
The standard allows quite some tolerance for the blanking and thus for the active duration of a scanline. But blargg already found that that the NES does indeed 282 pixels including overscan.

The only question is whether that weird "pulse" pixel should be considered part of the active area or not; if so, we would need to go with 283 and 324/283 (1.144876) pixel aspect ratio, which would be most unfortunate, since 283 is a prime number. ;)

(I have seen this pulse on imported Japanese NTSC VHS videos, too; never on US ones. I suspect this has something to do with NTSC-J, maybe a help for the TV to properly center the picture, as it can no longer tell the active from the blanking area by looking for a 7.5% setup.)
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

blargg wrote:Oh, and you might want to add an epilepsy warning for the NTSC test, as it flickered a bunch on the TV (probably due to the PPU alternating between two phases between frames, rather than your code slowly shifting the diagonal pattern).
Done.
blargg wrote:We should add NTSC/PAL detection to the ROMs to simplify things for the user.
Done.

New version uploaded
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit »

Dammit, now I have to make FlashMe for this nes demo....
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
aspectyl
Posts: 6
Joined: Tue Aug 25, 2015 3:17 pm

Re: NTSC emulation test?

Post by aspectyl »

In reply to tvpassfail

Have any of you seen this? It looks to be very thorough multi-platform test (minus NES).
http://junkerhq.net/xrgb/index.php/240p_test_suite

Linearity test is extra useful.
User avatar
mikejmoffitt
Posts: 1353
Joined: Sun May 27, 2012 8:43 pm

Re: NTSC emulation test?

Post by mikejmoffitt »

aspectyl wrote:Have any of you seen this? It looks to be very thorough multi-platform test (minus NES).
http://junkerhq.net/xrgb/index.php/240p_test_suite

Linearity test is extra useful.
Recreating the suite for the NES would be a good simple project to gain familiarity with the NES PPU.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: NTSC emulation test?

Post by tepples »

mikejmoffitt wrote:
Recreating the suite for the NES would be a good simple project to gain familiarity with the NES PPU.
As a start, I've redrawn most of the test screens for the NES, in case anyone else wants to pick up this project.
Attachments
240p test suite, partially redrawn for NES<br />Row 1: PLUGE, PLUGE highlight, color bars, gray ramp<br />Row 2: SMPTE bars, SMPTE on gray, bleed check vertical lines, bleed check checkerboard<br />Row 3: IRE, CPS-2 grid, linearity NTSC, linearity PAL<br />Row 4: sharpness, overscan, lag test, manual lag test<br />Row 5: horizontal stripes, checkerboard, grid scroll, backlit zone
240p test suite, partially redrawn for NES
Row 1: PLUGE, PLUGE highlight, color bars, gray ramp
Row 2: SMPTE bars, SMPTE on gray, bleed check vertical lines, bleed check checkerboard
Row 3: IRE, CPS-2 grid, linearity NTSC, linearity PAL
Row 4: sharpness, overscan, lag test, manual lag test
Row 5: horizontal stripes, checkerboard, grid scroll, backlit zone
Post Reply