Build Your Own Arcade Controls Forum

Main => Software Forum => Topic started by: teknikfrik on September 19, 2013, 04:26:51 pm

Title: Success with MAME and custom refresh rates (no tearing)
Post by: teknikfrik on September 19, 2013, 04:26:51 pm
Hello there (first post, wall of text incoming),

I just wanted to write about my MAME setup that works without screen tearing and hopefully minimal lag for _some_ games.

It's basically a combination of running MAME in sync with the refresh rate, and making sure the games' refresh rates are available in my monitor settings. I haven't really found anyone describing a setup like that when googling. So here goes!

Computer setup:
Windows 8 64-bit
MAME64 0.149u1
DELL U2412M 16:10 LCD monitor (native resolution 1920x1200)
ATI HD4850

I'm using Custom Resolution Utility (cru 1.0.1) http://www.monitortests.com/forum/Thread-Custom-Resolution-Utility-CRU (http://www.monitortests.com/forum/Thread-Custom-Resolution-Utility-CRU). With this utility I can add custom resolutions AND REFRESHRATES to my monitor settings.
What I did was select a few games that I want to run at 100% exactly, and check for their monitor refresh rates in the MAME game xml. There is a limit of 4 custom resolutions in CRU (probably Windows' fault). The games I currently use are:

(The numbers are from memory, but that's not really important.)
Mortal Kombat 54.5 Hz
ESP RaDe 57.55 Hz
Donkey Kong 60.60 Hz
I would've liked to use the neogeo refresh rate as well, but my monitor did not like it, so i had to use 59.95 Hz instead of 59.16(?).

These refresh-rates are added with CRU using the native resolution of my monitor, 1920x1200, on each entry, but with a different refresh rate for each entry (one for each game/system).

This is combined with the following MAME.ini settings:

throttle 0 (If this is not set to 0, no speeds over 100% will be allowed)
multithreading 0 (With mt on, syncrefresh seems to not work and run games at 400% and above)
syncrefresh 1
resolution 1920x1200  (This is important: I want to run the panel at native resolution always. And: when not specifying refresh rate, MAME selects the best available)
switchres 1 (MAME must actually switch the resolution/refresh-rate combination)

waitvsync 0
triplebuffer 0

Since syncrefresh will make sure the game runs in sync with the monitor, we can disable the other 'screen tearing'-fixes.

With this setup, there is a small delay when launching different games since the monitor must adapt to the new refresh rate.

This runs Mortal Kombat, ESP RaDe and Donkey Kong at 100% without audio glitching (like happens with waitvsync and triplebuffer for donkey kong). Other games that don't match exactly run at e.g. 101% (neo geo games).

I might improve on this by using these settings only for games that are confirmed to run at 100%, and use triplebuffer, throttling, and multithreading for games with refresh rates that my monitor does not accept.

When trying refresh rates on your monitor, some may not work. In that case, just exit MAME and it will revert back to your desktop refresh rate. Then use CRU to try a different refresh rate, reboot, and launch the game again.

For some reason, not all refresh rates between 57-61 Hz work even though those 'endpoints' work. I guess it's trial and error to get the 'perfect 4' refresh rates for the favorite games to run as close as 100% as possible.

Comments are welcome if you know how to improve on this :)
Title: Re: Success with MAME and custom refresh rates (no tearing)
Post by: TheManuel on September 20, 2013, 04:27:52 pm
This is nice.  I saved the link to this post for when I buy an LCD monitor for my cab.  Thanks for taking the time to share.

Why did you need a custom resolution for Mortal Kombat?
I've never had any issues with that game, but maybe it is because I use triplebuffer and refreshspeed.
One game that is notorious for this kind of problem is Kung Fu Master.  With triplebuffer and refreshspeed you get rid of the screen tearing but introduce a bit of stuttering in the scrolling.  I probably don't notice this issue in MK because it hardly does any scrolling.
Title: Re: Success with MAME and custom refresh rates (no tearing)
Post by: BadMouth on September 20, 2013, 04:52:30 pm
This is nice.  I saved the link to this post for when I buy an LCD monitor for my cab.  Thanks for taking the time to share.

Why did you need a custom resolution for Mortal Kombat?
I've never had any issues with that game, but maybe it is because I use triplebuffer and refreshspeed.
One game that is notorious for this kind of problem is Kung Fu Master.  With triplebuffer and refreshspeed you get rid of the screen tearing but introduce a bit of stuttering in the scrolling.  I probably don't notice this issue in MK because it hardly does any scrolling.

Triplebuffering adds lag which is not good for shmups (which are most susceptible to tearing because of the scrolling).
Not that I'm good enough for it to make any difference, but I'll give this method a go when my cab is finished and I'm fine tuning the little things.

I had horrible tearing in the NAOMI shmups using both Demul and Makaron.  Forcing triple buffer through my video card software fixed it, but I may have to revisit the issue and see if the refresh rate can be adjusted somehow.
Title: Re: Success with MAME and custom refresh rates (no tearing)
Post by: teknikfrik on September 20, 2013, 06:40:58 pm
Why did you need a custom resolution for Mortal Kombat?
Because I could ;) True, the animation fps in mortal kombat is far below the screen refreshrate, and there's not much scrolling. It was mostly a test of my monitor's refresh 'range' using one of the games with the lowest refresh rate in my game list - and as BadMouth mentioned, it should give less lag.

I might drop the MK-resolution to give me 1 more slot for some other refresh rate. Don't know which game I will try to sync with, though. I'll check the rest of the Cave shmups maybe.

But ESP RaDe was my main goal, and it works great =) With the monitor at 60Hz it would run at a smooth-scrolling 104% speed or with triplebuffer + lag/non-smooth-scrolling - both options felt less than ideal.
Title: Re: Success with MAME and custom refresh rates (no tearing)
Post by: teknikfrik on September 23, 2013, 03:49:48 pm
The biggest problem right now is that the refresh rate list is sometimes reset after reboot... Not always, but sometimes.. Any ideas?
Title: Re: Success with MAME and custom refresh rates (no tearing)
Post by: marioxb on September 24, 2013, 10:07:57 am
Is there a list somewhere of what resolutions a game uses? Or which games need custom resolutions to work properly? I heard Paperboy may be one of them? Does this only apply for LCD monitors?
Title: Re: Success with MAME and custom refresh rates (no tearing)
Post by: gildahl on September 25, 2013, 04:32:46 pm
I'd like to report that this does seem to work, and to thank the OP for the info.

Normally, I turn on vsync and autoframeskip whenever tearing is evident.  This has always cleaned up tearing and sound issues with no downsides that have ever seemed evident to me.  However, in 0.149 I discovered that certain games like Missile Command have trackball slowdown issues when vSync is turned on (I use vsync in MC due to tearing evident in the explosions--especially "The End").  Since Pokey sound in MC has been tweaked in 149, I wanted to "upgrade" but couldn't come up with a useable fix for the tearing.  The very next day I saw this post and tried it out.

I created a new entry in CRU at Missile Command's refresh rate and my monitor's native resolution (1920x1200) , then set the MAME options as instructed.  I also turned off vsync and autoframeskip.  Magically, this worked!  The tearing is gone and the trackball is back to normal.  It is too bad that only four resolutions can be configured, but since there are very few games with this particular problem, it's probably enough.
Title: Re: Success with MAME and custom refresh rates (no tearing)
Post by: teknikfrik on September 27, 2013, 05:10:37 pm
Cool gildahl :-)

I think I've solved my problem with Windows 8 resetting the refresh rates. Now I'm using a VGA cable with pin 12 removed (the EDID-pin). And after about 3-4 reboots, the resolutions are still there. Keeping my fingers crossed!
Title: Re: Success with MAME and custom refresh rates (no tearing)
Post by: teknikfrik on September 27, 2013, 05:20:54 pm
Is there a list somewhere of what resolutions a game uses? Or which games need custom resolutions to work properly? I heard Paperboy may be one of them? Does this only apply for LCD monitors?

Yes, you can generate an XML file which contains the refresh rates for all games by running:

mame.exe -listxml > list.xml

in the command prompt. (That's how I remeber it.. may be wrong ;) )
Title: Re: Success with MAME and custom refresh rates (no tearing)
Post by: teknikfrik on July 13, 2016, 02:12:18 pm
Wow... I just realized I read and followed the instructions from my own thread when googling last week after upgrading to Windows 10.

..and I didn't even realize it was my own thread  :laugh2:

A small update: In Windows 10 and with an ATI HD6970 I can use HDMI and still use custom resolutions without them resetting on reboot.

And in Mame 0.175 I can use multithreading without getting 400% speed as I mentioned in my original post.
Title: Re: Success with MAME and custom refresh rates (no tearing)
Post by: Rataplan626 on January 10, 2017, 05:25:33 pm
You might want to try my tool at http://forum.arcadecontrols.com/index.php/topic,152919.0.html (http://forum.arcadecontrols.com/index.php/topic,152919.0.html) which can switch resolution per game based on the refresh rate in mame.xml. You can use it to automate resolution / refresh rate switching so you'll have a perfect match for any game.