bubble2k16 / picodrive_3ds

75 stars 1 forks source link

Hardware-accurate aspect ratio scaling (and also maybe forced 320-wide display). #1

Open vaguerant opened 6 years ago

vaguerant commented 6 years ago

Me again with the stupid "pixel aspect ratio" stuff I'm still very grateful you implemented in your Snes9x port. The best part: correct Master System/Mega Drive (Genesis) scaling is literally identical to correct NES/SNES scaling: you leave the vertical alone (i.e., 224 or 240 lines, "raw" and unscaled) and scale your horizontal to 292 pixels wide. There are no exceptions.

You can mostly ignore the rest of this issue, which is just background on why the above scaling is correct, except for the "Bonus suggestion" at the bottom.

The fun (not-fun) part: this is correct in both H32 (256-wide) and H40 (320-wide) modes of the Mega Drive hardware--the Master System always runs 256-wide and it's also correct there. This isn't by accident: the dot clock (which determines how fast/wide to draw the pixels to the screen) is adjusted by the MD depending on which screen-width it's running at.

256-wide mode

In 256-wide mode (on both Master System and Mega Drive), the hardware uses a slower ("wider") dot clock of 5.37 MHz, exactly the same as the NES, SNES, TurboGrafx-16, etc., which results in a "pixel aspect ratio" of 8:7, meaning that each individual pixel (not the full screen itself) is in the ratio 8:7 (1.14:1).

Formula:

(8/7)×256
=292.571429

And round down to 292.

320-wide mode

In 32-wide mode (on the Mega Drive), the hardware uses a faster ("thinner") dot clock of 6.71 MHz, which results in pixels that are thinner than square at a 32:35 (0.91:1) "pixel aspect ratio".

Formula:

(32/35)×320
=292.571429

And round down to 292.

Conclusion

Ta-da, same number. ☺️ Always 292-wide is as accurate as you can get on 3DS to the way games look on real hardware. The idea here is that games can adjust their display mode during screen transitions (e.g. Bugs Bunny in Double Trouble does this constantly in the level "Bully for Bugs") without the size of the image on the TV changing; the horizontal resolution changes, but the aspect ratio is always the same.

Bonus suggestion!

It's not accurate to anything at all, but another option that's reasonably attractive is to include a mode where the image is always scaled to 320 horizontal×(native vertical). That is, when the Mega Drive is in H40/320-wide mode, you're doing no scaling at all and just presenting the pixel-perfect image to the player, and when the Mega Drive is in H32/256-wide mode, you scale the image to 320 horizontal×(native vertical). Like the 292-wide scaling, in this scenario you never touch the vertical at all.

Most Mega Drive games run at 320-wide, and most of the time, they look great "pixel-perfect" at 1:1 PAR (technically wider than they would be displayed "correctly"). A mode that's just permanently 320-wide regardless of mode preserves these games that run 320-wide, while bumping up the less-common 256-wide games/mixed-mode games so that they fill the same area as the better looking 320-wide games. This is particularly important for games like Bugs Bunny as mentioned above, where the screen resolution is changing all the time and it would look jarring without scaling.

Sorry for the long issue! Thanks for all your incredible work on 3DS, you make it a better platform to own with every release! 👍