DragonMinded / libdragon

Open source library for N64 development.
https://libdragon.dev
The Unlicense
746 stars 108 forks source link

PAL50 resolutions are letterboxed #566

Open thekovic opened 5 months ago

thekovic commented 5 months ago

Currently, the VI setup causes the following situation in PAL50 mode: image V_START is set to 95 (0x5F) and V_END is set to 569 (0x239), drawing a total of 474 lines. Y_SCALE is calculated with the same formula as NTSC mode which gives result of 1.205 (0x4cd). This has the effect of placing the frame roughly in the vertical center of the screen and drawing it with NTSC aspect ratio. This results in a squished image when actually displaying the frame on a TV because a PAL format video is still intended to be displayed in 4:3. PAL releases of Super Mario 64 or Mario Kart 64 display like this. (NOTE: The actual resolution of the frame buffer does not affect this behaviour. A frame made from a 320x240 frame buffer and from a 320x288 are both letterboxed and equally squished when finally displayed on screen.)

As a fix, I set V_START to 45 (0x2D) and V_END to 621 (0x26D), drawing a total of 576 lines, per PAL spec. The formula to calculate Y_SCALE is modified to (1024 * (res.height) + 120) / 288. The result is a frame which covers the entire screen and displays properly on a TV. PAL releases of Ocarina of Time or Mario Party display like this. image

Loosely related: I also played with V_VIDEO settings for NTSC. Currently, V_START is set to 37 (0x25) and V_END is set to 511 (0x1FF), drawing a total of 474 lines. This causes black lines at the top and bottom of the image. image One could choose to change this to V_START set to 35 (0x23) and V_END is set to 515 (0x203), drawing a total of 480 lines. This displays the image fully. image As far as I can tell, no commercial game does. There may be a good reason for skipping 6 lines that I don't know about and that I didn't come into in my testing. In case of such a reason, the "fixed" PAL configuration for V_VIDEO described above will need to be adjusted slightly.