MiSTer-devel / Template_MiSTer

Template with latest framework for MiSTer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Integer scaling modes work incorrectly on a 4:3 display

MilanPolle opened this issue · comments

The current logic for the integer scaling options (this goes for both the integer scaling options in the menu core and the mister ini file) is based on only the vertical resolutions of the source and destination images, assuming a wide-screen output display. On a 4:3 aspect-ratio output display, when using cores with a wider aspect-ratio (Atari Lynx, Gameboy Advance, WonderSwan), this strategy fails. What seems to happen is that the resulting image is too wide for the available 4:3 horizontal resolution and gets squashed down to fit. This results in both an incorrect aspect-ratio and non-integer horizontal scaling.

The LCD handheld cores need proper integer scaling for shadow masks to work correctly.

Example with the Atari Lynx core and a 4:3 iPad monitor:
Atari Lynx resolution: 160 x 102, square pixels, 160:102 display aspect-ratio
iPad monitor display resolution: 2048 x 1536, square pixels, 4:3 display aspect-ratio

Horizontal upscaling (desired in this case):
2048 / 160 = 12.8 = 12x up-scaling, 12 x 12 pixel shadow mask pattern, resulting resolution: 1920 x 1224. Resulting in a correct aspect-ratio and shadow mask pattern on this monitor.

Vertical upscaling (current logic):
1536 / 102 = 15.06 = 15x up-scaling, 15 x 15 pixel shadow mask pattern, resulting resolution: 2400 x 1530.

As 2400 is much wider than the available 2048 pixels, the image gets squashed down horizontally, to 2048 x 1530, resulting in an aspect-ratio close to 4:3. Shadow masks will also no longer work correctly.

One correct solution would be to calculate the scaling factors based on both horizontal and vertical resolutions and then choosing the smallest scaling factor of the two. This would work correctly for all variations of source and destination image aspect-ratios.

Currently trying to update the code myself, it looks pretty straightforward.

I have made a working solution. Will make a PR.

Pull request here: #79

This fix is only for the integer scaling options in a core's menu. I'll see if I can do a fix for the integer scaling options in mister.ini as well.

Turns out I misunderstood the purpose of vscale_mode 4 and 5, they crop the output resolution to an integer multiple, which the monitor then up-scales. Mode 4 stretches it up to a full-screen image, mode 5 respects the original aspect-ratio.

Closing the ticket as there seem to be no more related problems.