team-phoenix / Phoenix

A multi-system emulator and library manager designed to be both powerful and easy to use.
http://phoenix.vg
GNU General Public License v2.0
376 stars 40 forks source link

Support non-square PARs (pixel aspect ratios) #211

Open athairus opened 8 years ago

athairus commented 8 years ago

Some games like Castlevania: SotN can render at resolutions like 512x240. I'm going out on a limb here but I don't think that 1:1 was the PAR the developers had intended the game to be presented at.

Solving this is tricky. I had originally assumed we could rely on the core to give us the proper aspect ratio implicitly via the dimensions of the framebuffer passed, but I hadn't taken into account the PAR being non-square.

A basic (naïve) solution to all this is to hard-code the aspect at 4:3. But this will fall apart with games that support widescreen (16:9) and also with people who believe console X really has an aspect ratio of 5:4 or 3:2 or whatever. And let's not forget handheld games, their aspect ratios are all over the place (but at least have a PAR of 1:1... right?)

Another solution is to store in the future Libretro/Phoenix database for each system the "native" aspect ratio. Things could still get tricky with newer games that let you configure the aspect ratio in-game (normal = 1:1 PAR, widescreen = ?:? PAR). We'd either have to let the user tell us what aspect ratio they want or actually examine the game's state to figure that out.

This issue only applies to cores whose original systems were capable of displaying on analog TVs. That's not a huge chunk of what we support... is it? :)

athairus commented 8 years ago

N64, which we will soon support, has native widescreen games: http://www.mobygames.com/attribute/sheet/attributeId,278/p,9/

athairus commented 8 years ago

Store in the database for each system the type of screen it was intended to display on: SDTV will be assumed to be 4:3, though the user can override this. HDTV will always be 16:9... or should it? Custom can be anything at all!

For a system like the DS, whose only core DeSmuME outputs a differently-sized framebuffer depending on the screen gap setting (different heights), we will need to come up with yet another approach. Maybe this approach could be merged with whatever we use to let the user choose between assuming 4:3 or 16:9 video output for SDTV?

athairus commented 8 years ago

For SDTV, treat width and height separately:

athairus commented 8 years ago

The algorithm works nicely. It's been added to corecontrol merged into master. I've also added in PAL support (currently not settable from UI) and widescreen (for those games that support anamorphic widescreen). These are all properties of VideoOutput, the entire thing being controlled by a master property: bool television.

TODO:

athairus commented 8 years ago

I did not realize that the Libretro API already has the ability to specify aspect ratio. In the case of the DS, it can change during runtime, but that wasn't too hard to work around.

The code I wrote is still used for anamorphic widescreen, so it's worth keeping.