This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

VBlank/HBlank (trying understand)

VBlank/HBlank (trying understand)
by on (#19410)

I try understand the VBlank & HBlank concept (i'm little stupid ;P)
and i make graphical draft (diagram) for best see - please tell my if i make something wrong? ok?


by on (#19416)
That's mostly correct, though there are additional scanlines which fall between VBLANK and the rendered screen, adding up to a total of 312 scanlines per frame (for NTSC, it adds up to 262). Also, on the NES, only 240 scanlines actually contain rendered video, and there is no interlacing (so you don't double the number of scanlines).

by on (#19441)
Also keep in mind that the NES PPU's "HBlank" is not the same as the TV's "HBlank". The NES' HBlank area is wider than the TV's HBlank, which means that for the correct aspect ratio, you need to include a few pixels to the left and right into the 4:3 image.

by on (#19445)
About that aspect ratio: There are 279 NES pixels[1] in a TV line. This means in NTSC (240 active lines per field), the width of a pixel is 240 * 4/3 / 279 = 1.15 scanline heights. In PAL (288 active lines per field), the width of a pixel is 288 * 4/3 / 279 = 1.38 scanline heights.

[1] Strictly, analog television receivers do not use "pixels". The active period of a horizontal line is equal to 279 cycles of the NES pixel clock. This may vary by up to 5 percent depending on how the TV set is calibrated, but the ratio has been confirmed based on comparisons between NES and Game Boy Player video on the same screen.

by on (#19446)
279? From the last information gathered on the NTSC PPU video signal, I thought that number was 282 (15 + 256 + 11).

by on (#19800)
I thought we cleared this up already.

NTSC has 486 active lines per frame, or 243 per field. The horizontal resolution depends on the pixel clock; the active period is given as 52.6555 µs in ITU-R BT.470-6 and EIA RS-170A, 53.07 µs in FCC 73.699, and 52.86 µs in SMPTE 170M-1999. Given the NES PPU's clock, which is also its pixel clock, of Fsc*6/4 = 4,500,000/286*455/2*6/4 = 5,369,318.1818... Hz, this results in an active period being divided into 282.72, 284.95 and 283.82 horizontal NES pixels, respectively.
Using the ITU/EIA spec as the authoritative figure, that means the NES active picture is a resolution of 282x243, with 15+11 pixels of those falling into the NES' "HBlank" area. Just as blargg found out empirically.

Most emulators, just like most TV capturing devices, however display/capture only 240 (or 480) instead of 243 (or 486) lines. If you crop like that vertically, you also need to crop like that horizontally to maintain the aspect ratio. Therefore, the actual NES active picture is reduced from 282x243 to (240/243)*282x240 = 279x240. For a centered image, it's probably best to cut away those three pixels from the left.

Therefore, the difference between the "actual" 282 and the emulated 279 horizontal pixels is because we're all cutting away the three extra scanlines that analogue NTSC has --- a sensible choice for console emulators, obviously.