Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly apply -keepaspect with -unevenstretchx/y. Initialize window… #8209

Merged
merged 3 commits into from Jul 2, 2021

Conversation

antonioginer
Copy link
Contributor

@antonioginer antonioginer commented Jun 21, 2021

… at the correct size when -intscalex/y is used.

Fixes MAME Testers bug 7213

In MAME there are 2 scaling paths:

  • unevenstretch: (i.e. fractional). This applies fractional scaling to both axes, with or without keeping aspect ratio. This is the classical scaling method in MAME and has never been modified. No other modifiers apply.

  • nounevenstretch: (i.e. integer). This applies integer scaling to both axes. Optionally, you can turn off integer scaling on one of the 2 axes (not on both o them), by specifying -unevenstretchx (-uesx) or -unevenstretchy (-uesy). Or, alternatively, -autostretchxy will apply either -unevenstretchx or -unevenstretchy automatically based on the direction of the scanlines of the original game.

The following considerations apply to nounevenstretch:

  • Integer factors are calculated as the maximum possible to fit in the window area or fullscreen resolution, without cropping. In order to allow cropping, -intoverscan will be used, so that the closest integer factor is applied even if it means overscan with regards to the window area or fullscreen resolution.

  • By using -keepaspect, integer factors on both axes are calculated so they approach the original aspect ratio as much as possible, though this funcionality is limited due to the nature of integer scaling.

  • In addition to this, you can use -intscalex (-sx) / -intscaley (-sy) to force custom integer factors to any of the axes, regardless of the window area. These factors lock the size on that axis once set. They also override the fuctionality of keepaspect.

What this implementation does as compared to the previous one

  • Now, -keepaspect is applied with -unevenstretchx / -unevenstretchy (or -autostretchxy), so that the scaling of the fractional axis is proportional to the size of the integer one.* This works even if forced integer factors are applied to the integer axis.

mame -window -uesx -ka will force integer scaling on y, and adjust x fractionally so it meets aspect ratio. As you resize the window, y will jump by integer factors, and x will follow.

mame -window -uesx -sy 2 -ka will force integer scaling factor 2 on y, and adjust x fractionally so it meets aspect ratio. Resizing the window won't alter the visible area (it will create black borders around).

  • Now, in windowed mode, MAME will start with the correct window size, even when integer factors are forced on command line.

  • Now in Windows, you don't need to hold CTRL in order to resize the window by dragging its border.

  • Maximizing/minimizing correctly restores the window client area to the integer scaled resolution.

  • This change means that with -keepaspect, black borders produced by integer scaling are now propagated to the fractional axis. This is contrary to the behaviour we had before, and means that -nokeepaspect must be used now in certain cases like super resolutions on CRT (e.g. scaling 320x224 over 2560x240 now will need -nokeepaspect to avoid the borders to be propagated as black pillars).

… at the correct size when -intscalex/y is used.
@SuperFromND
Copy link

SuperFromND commented Jun 21, 2021

Heya, just tested this and it works great! However, there's a tiny little issue I encountered while testing in regards to intscalex and intscaley:

If you launch a game, maximize the window, and then de-maximize it, the resulting window will revert to native-resolution size instead of the multiple-of-native-resolution size. (demonstration of this bug):
https://user-images.githubusercontent.com/22881403/122832252-b3598e80-d2b0-11eb-92ba-eaca217b48d1.mp4


// apply automatic axial stretching if required
int scale_mode = m_scale_mode;
if (m_scale_mode == SCALE_FRACTIONAL_AUTO)
{
bool is_rotated = (m_manager.machine().system().flags & ORIENTATION_SWAP_XY) ^ (target_orientation & ORIENTATION_SWAP_XY);
scale_mode = is_rotated ^ target_is_portrait ? SCALE_FRACTIONAL_Y : SCALE_FRACTIONAL_X;
scale_mode = is_rotated? SCALE_FRACTIONAL_Y : SCALE_FRACTIONAL_X;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put a space before the ? of the ternary conditional operator.

Comment on lines 1222 to 1223
float integer_x = std::max(1.0f, float(m_int_overscan || x_fits? render_round_nearest(xscale) : floor(xscale)));
float integer_y = std::max(1.0f, float(m_int_overscan || y_fits? render_round_nearest(yscale) : floor(yscale)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put a space before the ? of the ternary conditional operator.

Comment on lines 1225 to 1226
//float integer_x = std::max(1.0f, float(m_int_overscan? render_round_nearest(xscale) : floor(xscale)));
//float integer_y = std::max(1.0f, float(m_int_overscan? render_round_nearest(yscale) : floor(yscale)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What’s this commented code for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I fixed that.

@antonioginer
Copy link
Contributor Author

The issue reported by SuperFromND should be fixed now.

@cuavas
Copy link
Member

cuavas commented Jun 23, 2021

I’d like to hold off on merging this until after 0.233 is frozen. It might all be fine, but I’d rather not risk weird interactions of options this close to release time. The current behaviour might be less-than-ideal, but it’s a known situation. Better to do this earlier in a release cycle to give us a chance to shake out any issues.

@antonioginer
Copy link
Contributor Author

That's perfect, thanks!

@cuavas cuavas merged commit 5186eaa into mamedev:master Jul 2, 2021
mbarnes added a commit to mbarnes/arcade-ansible that referenced this pull request Aug 1, 2021
With MAME 0.234, unevenstretchx/y and keepaspect work correctly
together [1], so it's now worthwhile to increase screen resolution
so more of the screen is used for games with unusual aspect ratios.

This is the maximum resolution my arcade monitor supports.

Also, resize splashscreen.png to higher resolution.

[1] mamedev/mame#8209
cuavas pushed a commit that referenced this pull request Jan 5, 2022
Fixes aspect related issues, undesired overscan, etc. (GitHub #8209, GitHub #8387, MT08110)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants