MiSTer Custom Aspect Ratios for Horizontal Integer Scaling

Community created YouTube tutorials, interviews and helpful online information guides.
User avatar
morf77
Posts: 63
Joined: Fri Aug 28, 2020 1:42 pm
Has thanked: 12 times
Been thanked: 24 times

Re: MiSTer Custom Aspect Ratios for Horizontal Integer Scaling

Unread post by morf77 »

Most of it is self-explanatory.
Visible pixels is the horizontal resolution of the core.
Visible lines is the vertical resolution of the core.
Pixel clock in mhz is more difficult to find out for arcade cores but you could use references like https://pineight.com/mw/index.php?title=Dot_clock_rates though it isn't guaranteed that's the pixel clock the mister core is running at.

The output will include a 1200p custom_aspect_ratio line you can copy paste in your mister.ini for that specific arcade core tag. The arcade core name (you will need this for the tag in the ini) can be seen in the mister menu when the core is loaded, alternatively you can find the name in the MRA files.

Example for ghost 'n ghoblins in the mister.ini file (just an example, not claiming these values are correct or recommended):

Code: Select all

[gng]
custom_aspect_ratio_1=32:35      ; 256:224 @ 8.000, 4:5 PAR (1024:1120)
The info after ; is just commentary to denote the values used and the PAR it translates to - it can be left out of the ini.
Yim
Posts: 126
Joined: Mon Jan 18, 2021 11:51 pm
Has thanked: 3 times
Been thanked: 87 times

Re: MiSTer Custom Aspect Ratios for Horizontal Integer Scaling

Unread post by Yim »

Not actually what you’re asking but here’s how you calculate it for yourself, using CPS2 as an example:

The core’s resolution is 384x224, and the original display aspect ratio is 4:3. Your screen has a vertical resolution of 1200 lines, so the 224 lines will fit five times using 1120 of those lines. To get the original aspect ratio of 4:3 you divide that by three (373.3333) and multiply by four (1493.3333) for the horizontal resolution. Divide that by the core’s horizontal resolution of 384 and you get the horizontal multiple of 3.88889. That’s not an integer, so you’ll want to round to either 3 (much narrower) or 4 (slightly wider) and multiply the core resolution by that. 4x384=1536, so that’s your output resolution. So you should set the aspect ratio to 1536:1120, or if you simplify it 48:35. This is not exactly the 4:3 aspect ratio you’d get on an original cabinet but it’s as close as you’ll get with integer scaling on a 1600x1200 screen.
Kenzo
Posts: 21
Joined: Sun Jul 04, 2021 11:08 am
Has thanked: 18 times

Re: MiSTer Custom Aspect Ratios for Horizontal Integer Scaling

Unread post by Kenzo »

Do I keep vscale=1? Or does this override custom ratios at the bottom of the ini?

Thank you both so much.
Yim
Posts: 126
Joined: Mon Jan 18, 2021 11:51 pm
Has thanked: 3 times
Been thanked: 87 times

Re: MiSTer Custom Aspect Ratios for Horizontal Integer Scaling

Unread post by Yim »

Still need vscale=1, yeah. Without that it’ll fill the full height of the screen so you won’t get integer scaling. The custom aspect ratio doesn’t change the vertical scaling, only the horizontal.
Kenzo
Posts: 21
Joined: Sun Jul 04, 2021 11:08 am
Has thanked: 18 times

Re: MiSTer Custom Aspect Ratios for Horizontal Integer Scaling

Unread post by Kenzo »

Yim wrote: Sat Jul 10, 2021 10:38 am Still need vscale=1, yeah. Without that it’ll fill the full height of the screen so you won’t get integer scaling. The custom aspect ratio doesn’t change the vertical scaling, only the horizontal.
Thanks!

what is the difference between vscale=1 + custom AR for HV integer scaling and atrac17's modelines?
User avatar
morf77
Posts: 63
Joined: Fri Aug 28, 2020 1:42 pm
Has thanked: 12 times
Been thanked: 24 times

Re: MiSTer Custom Aspect Ratios for Horizontal Integer Scaling

Unread post by morf77 »

If I'm not mistaking atrac17's modelines were calculated using the AR calculator using a custom resolution. Meauxdal also calculated a lot of these AR's eg see https://github.com/meauxdal/MiSTer_Cus ... /1200p.txt

Both methods require vscale_mode=1, they're just different approaches to calculating them (the calculator taking the pixel_clock into account).
Kenzo
Posts: 21
Joined: Sun Jul 04, 2021 11:08 am
Has thanked: 18 times

Re: MiSTer Custom Aspect Ratios for Horizontal Integer Scaling

Unread post by Kenzo »

morf77 wrote: Sat Jul 10, 2021 12:24 pm If I'm not mistaking atrac17's modelines were calculated using the AR calculator using a custom resolution. Meauxdal also calculated a lot of these AR's eg see https://github.com/meauxdal/MiSTer_Cus ... /1200p.txt

Both methods require vscale_mode=1, they're just different approaches to calculating them (the calculator taking the pixel_clock into account).
Thanks, I guess the console custom ratios are now defunct with the osd option to HV scale.

This has been really helpful /insightful. Thanks for taking the time out to explain. Appreciated.
User avatar
morf77
Posts: 63
Joined: Fri Aug 28, 2020 1:42 pm
Has thanked: 12 times
Been thanked: 24 times

Re: MiSTer Custom Aspect Ratios for Horizontal Integer Scaling

Unread post by morf77 »

Kenzo wrote: Sat Jul 10, 2021 1:07 pm Thanks, I guess the console custom ratios are now defunct with the osd option to HV scale.
They are. It would be great to have a similar option for arcade cores but it would have to be implemented by all the different arcade core devs.
User avatar
LamerDeluxe
Top Contributor
Posts: 1179
Joined: Sun May 24, 2020 10:25 pm
Has thanked: 822 times
Been thanked: 264 times

Re: MiSTer Custom Aspect Ratios for Horizontal Integer Scaling

Unread post by LamerDeluxe »

You can get integer horizontal scaling with correct aspect ratio by just calculating the correct value for the vscale border. That's what I use with the vertical arcade cores to get perfectly clean vertical scanlines.
rhester72
Top Contributor
Posts: 1118
Joined: Thu Jun 11, 2020 2:31 am
Has thanked: 13 times
Been thanked: 171 times

Re: MiSTer Custom Aspect Ratios for Horizontal Integer Scaling

Unread post by rhester72 »

LamerDeluxe wrote: Sun Jul 11, 2021 7:52 am You can get integer horizontal scaling with correct aspect ratio by just calculating the correct value for the vscale border. That's what I use with the vertical arcade cores to get perfectly clean vertical scanlines.
Can you expand on this a bit if you don't mind?
Yim
Posts: 126
Joined: Mon Jan 18, 2021 11:51 pm
Has thanked: 3 times
Been thanked: 87 times

Re: MiSTer Custom Aspect Ratios for Horizontal Integer Scaling

Unread post by Yim »

Using the border is an alternative way to get vertical integer scaling without using vscale_mode=1. You can use it for any core, but it’s most useful for vertical arcade cores because vscale_mode=1 doesn’t work properly for them (I think it gets applied before rotation, so the result after rotation is incorrect).

Basically you need to calculate the largest integer multiple of the vertical resolution that will fit on your screen, and subtract that figure from the screen’s resolution, then divide the result by 2. Put that figure in the ini for the core as vscale_border=whatever. That puts a border of the number of pixels you specified above and below the image from the core, which results in the space available to the core to display in being an integer multiple. Then you can put in a custom aspect ratio for the horizontal scaling as I described earlier in this thread.

For example, say you have a vertical core with a resolution of 224x256 pixels and an original aspect ratio of 3:4, and you want to integer scale it onto a 1920x1080 screen. The vertical resolution of 256 will fit four times (1024 pixels) into 1080 with 56 pixels left over. So set vscale_border=28, and you get 28 blank pixels above, 1024 pixels of integer scaled output, and 28 blank pixels below = 1080 lines total. Then to get as close to the original 3:4 aspect ratio as possible while integer scaling, divide the vertical resolution (1024) by four and multiply it by three to get 768. Dividing that by the horizontal resolution (224) give a multiple of ~3.4, which is not ideal because it means your integer multiples will be fairly far from the original. You can then choose to multiply 224 by three (672) and have a picture that’s a bit narrow, or by four (896) for a picture that’s a bit wide. Then set a custom aspect ratio to reflect it. The simplest way is to just make the ratio the resolution you want, either 672:1024 or 896:1024. You can have two custom ratios, so you could just set them both and switch between on the OSD to see which you like better.
User avatar
LamerDeluxe
Top Contributor
Posts: 1179
Joined: Sun May 24, 2020 10:25 pm
Has thanked: 822 times
Been thanked: 264 times

Re: MiSTer Custom Aspect Ratios for Horizontal Integer Scaling

Unread post by LamerDeluxe »

rhester72 wrote: Tue Nov 23, 2021 8:41 pm
LamerDeluxe wrote: Sun Jul 11, 2021 7:52 am You can get integer horizontal scaling with correct aspect ratio by just calculating the correct value for the vscale border. That's what I use with the vertical arcade cores to get perfectly clean vertical scanlines.
Can you expand on this a bit if you don't mind?
Sorry, I read your message late in the evening and then forgot to reply another time. I've written a whole explanation just now, but I see Yim has already done that as well. Here's my explanation anyway:

The idea is to use the full screen mode (vscale_mode = 0) and shrink it down, using the vscale_border setting, to make the horizontal width of the image an integer scale, while still keeping the correct aspect ratio (the vertical scale will usually be non-integer). This is the exact opposite of MiSter's standard vertical integer scaling.

The result will look really sharp, with perfect vertical scanlines (no interference patterns).

The following example is for the Scramble core, using a 1920 x 1080 output resolution. Look up the source resolution at the top left of your screen when starting the core (values at the top) or alternatively take a screenshot.

Scramble source resolution: 224 x 256

The display aspect ratio, if you can't find it and assume square pixels, you can calculate it here:

Go to https://www.bellevuefineart.com/aspect- ... alculator/ to simplify your aspect ratio:
Enter 224 for W1 and 256 for H1, below it it will say "Your aspect ratio is: 7:8"

Scramble's aspect ratio is 7:8 (224:256)

It will usually be either 3:4 or 7:8, so you can always try both. Or just use the source resolution values instead (224:256).

Output display resolution is 1920 x 1080

At 7:8 aspect full screen scaling (vscale_mode=0), the output image width is:
1080 * 7 / 8 = 945

Shrink the horizontal ratio to an integer multiple:
945 / 224 = 4,21875 (this is our current horizontal scale)
Rounded down this is 4 (which is 4x integer horizontal scale)

4 x 224 = 896 (this is our new integer 4x scale output image width)

At 896 width our new image height, at the correct 7:8 aspect ratio, becomes:

896 * 8 / 7 = 1024 (non-integer scaled output image height)

So our total border size needs to be:
1080 - 1024 = 56 (output display height minus output image height)

Divided by two because we have a border above and below the image:
56 / 2 = 28 (this is the vscale_border size we will use)

In mister.ini this becomes (just add it at the end of the file if you don't have core-specific settings yet):

[scramble]
vscale_mode = 0 (if this isn't your default)
vscale_border = 28
(and video_mode=8 if your default resolution differs)
rhester72
Top Contributor
Posts: 1118
Joined: Thu Jun 11, 2020 2:31 am
Has thanked: 13 times
Been thanked: 171 times

Re: MiSTer Custom Aspect Ratios for Horizontal Integer Scaling

Unread post by rhester72 »

Thank you both VERY much - this is exactly what I was looking for!
User avatar
LamerDeluxe
Top Contributor
Posts: 1179
Joined: Sun May 24, 2020 10:25 pm
Has thanked: 822 times
Been thanked: 264 times

Re: MiSTer Custom Aspect Ratios for Horizontal Integer Scaling

Unread post by LamerDeluxe »

rhester72 wrote: Sat Nov 27, 2021 9:22 pm Thank you both VERY much - this is exactly what I was looking for!
Glad to be of help. I was really happy when I finally figured out how to do it, vertical scanlines look so much better now. I had been trying to make a case for a horizontal integer mode in mister.ini, but for some reason it just wasn't going to happen.
User avatar
LamerDeluxe
Top Contributor
Posts: 1179
Joined: Sun May 24, 2020 10:25 pm
Has thanked: 822 times
Been thanked: 264 times

Re: MiSTer Custom Aspect Ratios for Horizontal Integer Scaling

Unread post by LamerDeluxe »

For anyone wanting to try the shadow mask support in the recently updated vertical arcade cores, I've calculated the border values for integer horizontal scaling (at 1080p) with the correct aspect ratios. This provides really clean scan-lines and shadow mask patterns. Add this to your mister.ini (leave out the vscale_mode part if you already have that set to 0 globally):

Code: Select all

[ArkanoidJ]
vscale_mode=0
vscale_border=28

[Arkanoid]
vscale_mode=0
vscale_border=28

[Gyruss]
vscale_mode=0
vscale_border=28

[GyrussB]
vscale_mode=0
vscale_border=28

[GyrussCe]
vscale_mode=0
vscale_border=28

[Jackal]
vscale_mode=0
vscale_border=60

[JackalBl]
vscale_mode=0
vscale_border=60

[JackalR]
vscale_mode=0
vscale_border=60

[JailBreak]
vscale_mode=0
vscale_border=28

[ScotrSht]
vscale_mode=0
vscale_border=28

[TimePlt]
vscale_mode=0
vscale_border=28

[TP84]
vscale_mode=0
vscale_border=28
Post Reply