The NES Stretch Effect

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
The NES Stretch Effect
by on (#325)
Before emu authors get all fancy with their filters, I would hope more took the opportunity to make sure the games looked more like they do on a TV. I don't mean fuzziness, I mean aspect ratio. The NES does not display its picture inside a proportional rectangle. It stretches the picture horizontally to fill the picture tube. (This inbcludes the portions cut off by the pastic casing.) Most emulators include a stretch option, but this does not stretch the pixels proportionally, causing the screens to look and scroll weirdly. It probably decreases performance too. Unfortunately, CRT computer monitors cannot stretch the screen enough for the picture to entirely cover it if the NES's video is centered in a standard 1.33:1 resolution like 640x480.

Lets review the pixel ratios. If the NES were outputting squareish pixels, then the ratio of each pixel would be 1.067:1. However, it must stretch them out over a screen ratio of 1.33:1 Unfortunately, PCs these days do not allow emu authors to put out custom full screen resolutions. FCE Ultra does something very good, however. It allows you to scale pixel dimensions in windowed and full screen resolutions. Consider 1024x768. The NES's resolution of 256x240 would fit into a tiny box in the center of the screen without scaling. If you multiply 256x4=1024! So much for huge horizontal borders. Then multiply 240x3=720. Not quite 768, but it will have to do. Adjustments to the vertical and horizontal stretch of the monitor take care of the rest. 1280x960, 5:4 pixel ratio is also very nice but not quite right. 8bits per pixel ensures maximum sharpness.

I feel that this is a must for mature emulators. That and a ROM launcher.
CCIR 601
by on (#326)
No, 1.250 to go from 256x240 to a 4:3 box is a little too much stretching, as it would imply that the TV cuts off a nearly equal number of pixels on all four sides of the screen. In fact, the TV cuts off fewer pixels on the left and right than on the top and bottom, so it's probably a little less than 1.25. Using the 256x224 resolution of the Super NES (which is often also cited for the NES after overscan) gives a ratio of 1.167.

To settle it exactly, I'll appeal to authority, namely the International Telecommunication Union. According to the ITU standard commonly known as CCIR 601, the effective resolution of NTSC TV is 704x480 pixels, where a "pixel" is 1/4 color clock by 1 interlaced scanline. (Actually, a scanline of a CCIR 601 bitstream has 720 pixels, but 8 on each side are blank.) Take into account the limited bandwidth of composite video and the progressive-scan methods of early consoles, and you're down to 352x240, where each color clock period (at 3.580 MHz) is two "pixels". Squeeze this to fit a 4:3 display, and each half color-clock has 10:11 ratio. That seems to jibe with the stretching of the picture on the Sega Genesis console and Apple II computer, which output two pixels per color clock.

The master clock generator of a Famicom or NTSC NES console runs at 21.48 MHz. A divide-by-6 counter produces the color clock, and a divide-by-4 counter produces the 5.369 MHz pixel clock. (A separate divide-by-12 counter clocks the CPU.) This means each pixel is 2/3 of a color clock wide or 4/3 times as wide as a Genesis pixel. ("State of the art high resolution graphics" my ass.)

4/3 times 10:11 is 40:33, the exact aspect ratio of NTSC NES pixels. This corresponds to a pixel aspect ratio of 1.212 in FCE Ultra. Close ratios involving small integers are 6:5 (1.200) and 5:4 (1.250). The best way to scale the NES picture to 1024x768 is by 1. applying a simple pixel doubler in both directions and then 2. using DirectDraw built-in linear interpolation to put the result into a 931x720 pixel window.

Great Hierophant wrote:
That and a ROM launcher.

How are the implementations of the Open ROM... command in current Windows-based emulators deficient? What do you want in a ROM launcher?

(edit: correct ratio in the part about assuming snes fullscreen == 4:3)

by on (#330)
In a ROM launcher, there must be at least ROM name, PRG size, CHR size, mapper #, and mirroring. That way you won't have to scroll every time you want to open a ROM starting with the letter W.

by on (#332)
why not simply organise roms into alphabet letter directorys then it does't matter?

by on (#388)
I stretch the NES image to 640x480. While the horizontal axis must be stretched, the vertical axis must not be. This is the simples rule:

1122233444... or
1122*3344*...

If someone knows another formula to handle this... on 640x480... let me know. ;)

by on (#392)
1122*3344* looks like it'd be 1.4x scaling.

Unless I'm wrong, of course. :)

by on (#393)
1122233444... is 2.5x scaling, presumably in a 2.5x by 2.0x setup.

To get a proper 2.4x setup, try 1122a3344b55, where a=(2+3) mixed and b=(4.5) mixed. Or just do pixel doubling to a surface in video memory and use DirectX to stretch-blit it to the screen.

by on (#475)
I have at times stretched the emu window (many allow you to stretch it to any scale you like). However, I prefer debugging my game with clear pixels, rather than blurred or antialiased ones. I can run the game on hardware anytime I like, so I know what it looks like stretched. Emus don't have perfect palettes, but it's not a big deal either.

If one really cares about perfect scaling and such, they should just use real hardware, of it they can't do that, simply resize the window manually, heh ;)