GameRoom Articles
GameRoom Web Store
RetroBlast Reviews
RetroBlast Articles
Game Room Links
File Downloads
Site and Contact Information

Quick Jump:

How to Configure and Tweak Windows MAME for the Best Video Timing

Commando by Data East, 1985

It seems an odd combination, a classic arcade game such as Commando inside an XP style window, but choosing Windows as the platform for MAME is an easy one. Windows is easy to configure and use, has excellent driver support, good performance, and is quite stable in the NT/2000/XP variations.

Another good thing is that Windows MAME is very easy to get running because you don’t need any specific hardware or drivers. If your system runs Windows just fine, then you should be able to run Windows MAME also. It might be easy to get running, but after a little playing around, you will find that getting perfect video is anything but easy.

The reason for this is that Windows MAME is unable to control the video card directly; it must go through Windows. Windows does a pretty good job of handling everything related to video except one thing, the refresh rate. Precise refresh rates are not available although you usually have a few limited ones per resolution such as 60 hertz (Hz), 70 Hz, or 85 Hz.

There is a version of Mame (AdvanceMame) that can generate perfect clock rates by controlling the video hardware directly. The downsides to AdvanceMame however are that it is very hardware specific (you are better off buying hardware known to work with it than trying to get what you have working) and that it is difficult to configure.


For those who are not familiar with the term hertz, it simply means the number of times per second. You will see it used in many ways, but for our purposes it describes the number of times a monitor is updated each second. So a 60 Hz refresh rate means that the display is refreshed (or drawn) 60 times per second.


This article can get fairily technical at times, but I will do my best to explain terms and concepts as it progresses. It helps if you have a basic understanding of how a monitor works.

How CRT Monitors Work Courtesy: "How Stuff Works"

In MAME, game speed is referred to as frames per second (fps), but don’t let this confuse you as it is the same thing as hertz (60 fps = 60 Hz). In fact, a game in MAME with a 53 fps game speed is set that way because the actual arcade game ran at 53 Hz. Actual arcade games run in perfect video timing with their monitors because they actually generate the signal the monitor is displaying. Here is a depiction of how this would look:



In a game at 53 fps, there would be exactly 53 of these frames for every one second. Our goal with MAME is to reproduce this as closely as possible, but this becomes a problem because the closest available refresh rate in Windows is 60 Hz. The real issue here is that there are two timers constantly out of sync with each other. MAME has a timer it uses to keep the game at the correct game speed (fps), and the monitor has a timer (its refresh rate) that it uses to display frames one after another. Even when you think these timers should be in sync (60 fps game and 60 Hz monitor) they will not be because most likely your monitor is actually running 59.992321 Hz or 60.103341 Hz. To complicate this even further, MAME has games ranging from 30 fps to 69 fps.

There are 3 techniques that can be used to address the issue.  Here is a description of each technique along with its advantages and disadvantages.  You can use MAME's timer only, you can use the monitor's timer only, or you can use them both at the same time.


Technique 1:  Use MAME's timer only

This technique is actually default behavior for Windows MAME.  It updates the frame when its timer indicates it should and it does not care if the monitor is in the middle of drawing the last frame.  So, the monitor could be somewhere in the middle of drawing frame 1 when MAME updates to frame 2 and the monitor would never finish drawing frame 1.  Here is what this looks like:



The two advantages of this technique are perfect game speed and best video performance.  Perfect game speed means you will be playing the game at exactly the same speed it ran on the original arcade hardware.  Best video performance means that if your CPU is barely able to keep up with a game, then this technique will yield the fastest frame rate.

The disadvantage of this technique is that is looks terrible. When a frame is changed and the monitor is currently drawing the previous one, this often results in a retrace line (see the example above). Scrolling games look especially bad as the retrace line can actually slowly move up or down the display; this is called tearing. Flashing sequences also look terrible because the original arcade game may have meant the monitor to flash solid red and then solid green, but instead you will get frames that are partially red and partially green. I consider this technique so bad visually that I don’t use it unless I have to.


 Technique 2:  Use the Monitor's Timer Only

To enable this technique you must enable the syncrefresh option (I will underline all MAME options in this article). I also suggest that you enable the triplebuffer option as well. You can specify these options on the command line or put them in your MAME.INI. This will disable MAME’s internal timer and run the game speed at the monitor’s refresh rate.

If you don’t enable triplebuffer with syncrefresh, MAME will enable waitvsync whether you have it enabled or not. So, with syncrefresh you have a choice of waitvsync or triplebuffer depending on whether you enable triplebuffer or not. What is the difference between waitvsync and triplebuffer? They both seem to do the same thing, waiting for the monitor to be in the middle of the vertical blank before updating the frame. The difference is that waitvsync uses code in MAME to wait for the vertical blank and triplebuffer actually puts that task on the DirectDraw/D3D subsystem. I find that triplebuffer works better on a wider variety of hardware so I prefer it.

The advantage is that you have the closest thing to our first example of perfect video.  You can't see any retrace lines, scrolling games look perfect, and any flashing frames will look exactly as they did in the arcade:



The primary disadvantage is that you may not be playing the game at the same speed it ran in the arcade.  This is why I recommend using this technique for games that are very close to your monitor's refresh rate.  For example, a game that runs at 60.60606 fps (think about a round yellow character eating dots!) would be 1% slower if run at 60 fps.  This small decrease in speed would not be very noticeable, but if would certainly be noticeable if you sped up a game that normally runs at 53 fps to 60 fps (13% faster).

I use this technique on games from 58.5 to 61.5 fps which includes 87% of all MAME games.  Fortunately, 70% of these are 60 fps games so they run at the correct speed (unless you video adapter is too far off of 60.000000 Hz).  The other 17% of games I run using this technique will be made faster or slower by 0.1 - 2.1%.  There are emulation purists who would say that any game speed change however small is not acceptable, but I think a couple of percent difference in game speed on 17% of the games is an acceptable trade for perfect video.  I'll bet the variations in electronics from the same arcade game to another were probably off by a percent or so anyway.

 A second disadvantage of this technique is that your CPU must be fast enough to prepare the next frame before the monitor needs it.  If it isn't fast enough, then it will miss its opportunity to update the monitor when it is in between frames and have to wait for the next refresh cycle.  If this happens, you should go back to technique 1 because it will run faster if not synchronized to the monitor.

To use this technique, make sure you are running MAME 0.103u2 or later.  Versions before that had a couple of bugs regarding the syncrefresh, waitvsync, and triplebuffer options.  If you want to stick with an older version and you compile your own, please email me as I can send you a patch that corrects the bugs for older versions.


Technique 3:  Use both timers

To enable this technique you must enable either the triplebuffer or waitvsync options with syncrefresh disabled.  This will make MAME use its internal timer as well as wait for the monitor to be in the vertical blank before updating the frame.

The advantages are that this will eliminate the retrace line just like technique 2, and at the same time keep the original game speed.  This causes a problem because frames will be displayed twice when MAME's timer (the game speed) is unable to keep up with the monitor (refresh rate).



Here is an example the worst possible case:  What if you have a game that is 59 fps and you run it on a 60 Hz monitor.  This means that for every 1 second the game is 1 frame short.  What will happen is that MAME will keep the game at the slower 59 fps rate and one frame of the 59 will have to be displayed twice as in the above example.  So, think about a game that displays a frame twice every second, on the second.  If you playing a scrolling game of any type, this would mean the scrolling would stop every second on the second.  Most arcade games are all about action so the action would stop every second on the second.  Needless to say this would be very obnoxious and would make it unplayable.

When using both timers, you can't eliminate that frames will be displayed twice, but what you can do is try to make them less noticeable.  One per second is very noticeable.  Also, if you are running a 60 fps game and your monitor is actually running 60.1 Hz, then every ten seconds this 0.1 Hz difference will add up and become a displayed twice frame.  So it is games that are near the refresh rate that look horrible this technique.

To make this technique look better you want there to be as many displayed twice frames as possible and as randomly as possible.  I have found that once you approach 8 or more displayed twice frames per second that they become less noticeable.  So a 53 fps game running on a 60 Hz monitor would look much better than our 59 fps example above.  A better solution is to simply increase the refresh rate to something higher, such as 85 Hz.  Windows may not allow you to specify 57 Hz, but you usually have a few refresh rates to choose from besides 60 Hz.  Now, the 59 fps game at 85 Hz has 26 displayed twice frames all mixed in with the 59 active frames.  This will look much better.

Summary and Tweaks:

You might be asking yourself, why not just use technique 3 all the time?  The reason is that 70% of the games in MAME will have virtually no game speed difference using technique 2 and look 100% perfect using it.  Another 17% will have their game speed changed very little in order to look 100% perfect.  This leaves 13% of games which I recommend using technique 3 for.  While technique 3 looks very good, it does not look perfect like technique 2. 

I certainly did not want to configure each game so that it would run technique 2 or 3 as this would take a huge amount of time.  Instead I created two new options in MAME that would automatically determine which technique to use based on the game speed being emulated.  Here are they are from MAME -showusage:


-[no]autosyncrefresh /         enables automatic sync refresh                 


-autosyncrefresh_range / -asrr specifies automatic sync refresh range (games  

<float>                        60Hz +/- this value are included in automatic sync refresh


If autosyncrefresh is enabled, the game speed (fps) will be looked at when MAME starts.  If the game speed is within the range of 60 +/- the value specified in autosyncrefresh_range, then syncrefresh with be enabled and the refresh will be set to 60.  It is important to note that both of these will be changed when a game is within the range.  If a game is outside of the range specified, then they will not be changed and MAME will use your default syncrefresh and refresh settings.

Part 2: Changing the Default Settings