!!Overview The images output by the [[VDP]] consist of specific resolutions, but when displayed they are stretched by the display hardware. This page covers how that stretching works, how to scale a 1:1 image, and how to set up live preview in select paint programs. !!Master System The image is generated at (256 or 248)x(192 or 224 or 240) pixels. Regardless, it is then output as a progressive video signal at a constant timing per pixel and per row. This is then displayed on a 4:3 TV screen (assuming a normally-configured display). !!!NTSC/PAL-M The pixel aspect ratio is 8:7. This means a 100px square would appear 1.143x wider than it is tall, and a 56 by 64-pixel rectangle would appear square. You can preview this in a paint program by setting the image's pixel density to 63 by 72 dpi. For example, in GIMP, turn off View > Dot for Dot and then set the density in Image > Print Size. !!!PAL The pixel aspect ratio is 2950000:2128137. This means a 100px square would appear 1.386x wider than it is tall, and a 52 by 72-pixel rectangle would appear almost perfectly square. This can be approximated by different ratios as below. ||border=1 ||!Ratio ||! Error|| ||61:44 || +0.013%|| ||43:31 || +0.065%|| ||18:13 || -0.114%|| ||11:8 || -0.807%|| ||7:5 || +0.996%|| ||4:3 || -3.813%|| For the 18:13 approximation, set a paint program's pixel density to 52 by 72 dpi. !!!Examples ||border=1 ||! Original image ||! NTSC ||! PAL || || %height:192px%Attach:sonic-par-11.png || Attach:sonic-par-ntsc.png || Attach:sonic-par-pal.png || || || The ring around Sonic is nearly circular || || || %height:192px%Attach:t2-par-11.png || Attach:t2-par-ntsc.png || Attach:t2-par-pal.png || || He is too thin || Still a bit thin || This looks correct || !!Game Gear The image is generated at 160x144 pixels. It is then output to the LCD panel, which has an internal resolution (counting RGB subpixels as one pixel) of 160x146, with the top and bottom lines unused. The panel has an overall aspect ratio of 4:3. The pixel aspect ratio is 6:5, i.e. a 100px square would appear 1.2x wider than it is tall. Set a paint program's pixel density to 60 by 72 dpi. !!!Examples ||border=1 ||! Original image ||! GG || || %height:144px%Attach:sonic-gg-par-11.png || Attach:sonic-gg-par-fixed.png || || || The ring around Sonic is nearly circular || || %height:144px%Attach:t2-gg-par-11.png || Attach:t2-gg-par-fixed.png || || He is too thin || This looks correct || !!SMS mode on Game Gear The 256x192 screen is cropped to the central 240x192, and then scaled both horizontally and vertically: horizontally, three source pixels are spread across two output pixels (by mapping subpixels R1G1B1R2G2B2R3G3B3 to R1G1B2R2G3B3), and vertically four source pixels are spread across three output pixels (with some blurring). This is then shown on the central 160x144 pixels of the screen. This leads to a pixel aspect ratio of approximately 10:9, i.e. a 100px square would appear 1.11x wider than it is tall. ---- !!Showing our work !!!NTSC/PAL-M derivation NTSC video uses system M, whose standard timing is 4.5 MHz/286 ≈ 15734 Hz horizontal scan rate by 262.5 lines per field. (The half line is for interlacing, which SMS does not use. System J is the same as system M with a different RF band plan and black level.) On top of this is a chroma subcarrier at 227.5 cycles per line, or 4.5 MHz/286×227.5 ≈ 3.5795 MHz. SG-1000, SMS, and Mega Drive in H32 mode all have a pixel output rate 3/2 times the chroma subcarrier, for about 5.3693 MHz, or a total signal of 342 pixels by 262 lines including border and blanking. On NTSC, it has long been common practice to sample component video at 13.5 MHz and treat the center 704 samples of each line as active picture, giving a picture width of 704/13.5 ≈ 52.148 microseconds. (ATSC, the digital successor to NTSC, standardized 704 by 240 samples per field in the mid-1990s. You may see 720 in the literature; this includes a bit of nominal analog blanking at each side for recentering a signal before broadcast.) Multiplying this picture width by the NTSC SMS pixel clock rate gives 280 pixels per line. Thus the picture received by the TV contains 280 by 240 pixels: 256 or 248 pixels of SMS picture plus 24 or 32 pixels of side border, by 192 lines of SMS picture plus 48 lines of top and bottom border. Stretching 280×240 pixels to a 4:3 screen produces (4/3)/(280/240) = 8:7 ≈ 1.143:1 PAR. PAL-M video, used only in Brazil is PAL video using the same system M timing as NTSC video. Its chroma subcarrier is 227.25 Hz cycles per line, or 4.5 MHz/286×227.25 ≈ 3.5756 MHz, giving a pixel clock about 5.3634 MHz. (Standard PAL works best with a line length that differs by a quarter cycle from an integer multiple of chroma period.) This differs from NTSC by one part in 910, not enough to visibly affect shape. !!!PAL derivation PAL is messy. Very messy, with a factor of 64,489. PAL video uses system B, which has a standard timing of 15625 Hz by 312.5 lines. Its chroma subcarrier is 283.7516 cycles per line or 283.7516 × 15625 Hz = exactly 4433618.75 Hz. (This is close to the ideal quarter-cycle difference while incorporating an extra cycle every 625 lines to set up field-to-field phase that obscures the dot crawl. Systems G and I are the same as system B with different RF band plans.) SMS pixel clock is 6/5 of this, or 283.7516×15625×(6/5) = 5320342.5 Hz, and the total signal is 342 by 312 pixels. Chris Pirazzi claims in "Programmer's Guide to Video Systems" that sampling interlaced video at 14.75 MHz produces 768×576 square pixels. Likewise with progressive video at 7.375 MHz, giving 384×288. Stretching SMS video to this square pixel rate produces a pixel aspect ratio of 7375000/5320342.5 = (59*125000)/(165*64489/2) ≈ 1.3862:1. The large prime factor 64489 in the denominator does not simplify well. One may represent the fraction 2950000/2128137 as a continued fraction [1; 2, 1, 1, 2, 3, 2, 1, 1, 1, 20, 1, 3, 1, 50] and then truncate it to produce increasingly accurate convergents. # 1/1 = 1.000000000 # 3/2 = 1.500000000 # 4/3 = 1.333333333 # 7/5 = 1.400000000 # 18/13 = 1.384615385 # 61/44 = 1.386363636 # 140/101 = 1.386138614 # 201/145 = 1.386206897 # 341/246 = 1.386178862 # 542/391 = 1.386189258 etc. !!Sources * [[https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.601-7-201103-I!!PDF-E.pdf Recommendation|BT.601]] * [[https://www.itu.int/rec/R-REC-BT.1700-0-200502-I/en|SMPTE-170M and BT.1700]] * [[https://prdatsc.wpenginepowered.com/wp-content/uploads/2021/04/a_53-Part-1-6-2007.pdf|ATSC specification]] * "[[https://lurkertech.com/lg/video-systems/|Programmer's Guide to Video Systems]]" by Chris Pirazzi * "[[https://www.nesdev.org/wiki/Overscan|Overscan]]" by Damian Yerrick and other NESdev contributors * "[[https://github.com/pinobatch/240p-test-mini/blob/master/common/tools/continued.py|Continued fraction demo]]" by Damian Yerrick