<< Newer Articles under MAME Older >>

The New Video Landscape

A whole pile of stuff has changed during the 0.106 development cycle, and though we are a few weeks away from a real 0.107 release, it's probably time to sit down and have a little heart-to-heart about the video options.

Since its inception 9 years ago, MAME's video system has defaulted to a mode where it tries to change resolutions on you. And since the first port of the core to Windows 5 years ago, it has defaulted to using your graphics card to stretch the video to that resolution.

I'm sure a lot of you out there have taken a lot of time to tweak the current set of video options to make them work the way you like. But every once in a while, you need to take a step back and re-evaluate the situation. The current video system has been in place for 5 years now without much substantial change. And with the recent rewrite, you're almost certainly going to want to rethink the way you have things configured.

At the highest level, there are really three different ways you can configure the new system. Placing yourself into one of these three categories will help you get the initial settings right. From there, you can tweak with the settings to figure out what works best.

Category 1: Bells and whistles. People who fall into this category would include anyone with a modern system and a decent video card (decent in this context means at least 16MB of VRAM and built in the last 5 years or so -- we're not talking cutting edge here). Any decent video card will be able to render the simple MAME graphics at pretty much any resolution without breaking a sweat. Configure your desktop to the video mode you want (preferably something high like 1024x768 or greater with a high refresh rate, unless you are running on a fixed-mode LCD, in which case just match what your LCD panel is), and tell MAME to leave the resolution alone. In this day and age, there is little reason to switch resolutions at all, unless you fall into Category 3, below. In this mode, you will have full access to artwork options, and you'll get your artwork scaled to full resolution and with full alpha blending effects. Vector games will look crisp, you can use decent fonts, and you can see a whole lot more of the world when using the graphics/tilemap viewer. This mode uses Direct3D, so you should configure yourself like this:

-video d3d -noswitchres [-triplebuffer] [-nofilter]

The -noswitchres option tells MAME to just run at the current resolution. Although you can let MAME pick a resolution for you, it doesn't really make much sense in D3D mode, and in fact I may even remove that feature altogether. To avoid tearing artifacts, I recommend using the -triplebuffer option as well. Just make sure your monitor's refresh rate is higher than the game you are running. If you dislike the blurry look of the graphics, you can specify the -nofilter option to disable bilinear filtering, though that will produce blocky artifacts. Alternatively, you can use the -prescale option which is described at the end of this article.

Category 2: Like the old days. I really didn't even want to support this mode at all, but certain vocal MAMEdevs would have skinned me alive otherwise. People who fall into this category include those who have weak systems that worked fine with previous versions of MAME, but who don't run well with Direct3D rendering. (Note that just because Space Invaders runs unthrottled at 2000fps with DirectDraw and 1000fps with Direct3D doesn't mean that Direct3D is going to be a serious issue when playing at a regular 60fps, so if you're unsure, give the Direct3D route a try for a while.) In this mode, MAME will draw the game screen and artwork at the game's resolution, just like it did in MAME 0.106 and earlier; however, some artwork options, such as -artcrop, won't work as you might expect, and some alpha blending artwork modes (specifically overlays) won't work. MAME will then use your video card to stretch the video to the proper aspect ratio.

-video ddraw -hwstretch [-switchres] [-triplebuffer]

The -switchres is optional here. If your video card is really ancient and struggles expanding the screen to fit your desktop resolution, you might want to turn it on. Again, to avoid tearing artifacts, I recommend using the -triplebuffer option as well, but make sure your monitor's refresh rate is higher than the game you are running (-switchres will do that for you if you use it). If your video card produces blurry pixels which you don't like, try the -prescale option described at the end of this article.

Category 3: Anal video mode types. These are the guys who have generally built their own cabinets and set them up with a CRT display where they have several dozen carefully hand-tweaked video modes that approximate the original video modes the games ran at. They want MAME to pick that hand-tweaked mode and use it, drawing one pixel on the screen for each pixel in the original game. They don't give a whit about artwork or anything other than the raw pixels going to the right place. Fortunately, you can still configure MAME for this case as well:

-video ddraw -nohwstretch -switchres [-triplebuffer]

Obviously in this case, the -switchres is required. You also want to disable hardware stretching, otherwise you won't get that "perfect" 1:1 pixel mapping. Triple buffering may or may not help.

So, I recommend starting with these initial options and then tweaking from there. One additional option you might want to try in combination with the above is the -prescale option. -prescale takes an integer parameter from 1 to 8, and specifies a magnification amount by which the screen pixels are expanded before they are drawn to the screen. Why is this useful? And how much of a performance impact does it have? Well, that depends on the mode you are running in.

If you are running in Category 1 (-video d3d), then -prescale will use your video card to scale the game graphics up before rendering them to the screen. Depending on the video card, this is usually a small performance hit, but not too significant. The benefit is that each prescale factor reduces the blurriness of the pixels. -prescale 1 is the default, which does no scaling. -prescale 2 will double each pixel, -prescale 3 will triple each pixel, etc. For my money, -prescale 2 is sufficient, but people with super high resolution displays claim that larger -prescale factors work even better.

If you are running in Category 2 (-video ddraw -hwstretch), then -prescale will cause MAME to compose the screen graphics at the specified scale factor. This is unfortunately done in software, but carries the benefit that artwork, fonts, and the graphics viewer can take advantage of the additional resolution to produce nicer results. The end effect is that you will get less blurry pixels, just like the Category 1 case, plus higher quality artwork, fonts, and more visible area in the graphics viewer.

If you are running in Category 3 (-video ddraw -nohwstretch), then -prescale will cause MAME to pick a video mode that is the prescale factor times the raw screen resolution, and then MAME will, in software, compose the screen graphics at the specified scale factor. This has all the advantages of the Category 2 case, except that since there wasn't any pixel blurring to begin with, there is no additional crispness that comes about as a result.

Finally, you may be wondering about effects (and yes, scanlines are an "effect"). Well, let's take the band-aid off quickly:

Effects are not currently present in the video system and are not planned in the short term.

Ouch.

Are they gone forever? It's too early to say for sure. They present some unique problems. It's possible that if they do come back, they will only be available in Direct3D (Category 1) mode. For the next few versions of MAME, try living without them. Certainly, I want the video system as it currently stands to stabilize before even considering it.

I'll try to post a binary for u10 when it's available to let everyone play with the options a bit.

Seriously Impressed

I've been looking through the MAME source for games that were previously using the artwork system to dynamically update non-screen elements. I started off doing Turbo (as mentioned previously) and Discs of Tron, which a number of people have been asking about. There were a couple of glitches in the new system which showed up when I did the Discs of Tron artwork, so you will need to wait for u10 to actually use the layout file linked above and have it all working.

Then I moved on to Golly Ghost. Wow. Color me seriously impressed with the folks who put this one together. The quality of the artwork is very nice and it all works very well with the game graphics overlaid. And now that the artwork scales to your screen resolution (assuming you are using Direct3D), it looks absolutely amazing. Check it out!

I'm hoping to get a few more games updated, specifically Gorf, Spy Hunter, and Sky Diver, before I put out the next release.

More MAME Testing

The update to MAME 0.106u7 is now available for download. With this version, I have added back DirectDraw support, but using the new renderer underneath. In order to get some more testing, I've made a precompiled binary version available here.

In order to run with the new Direct3D support, use -video d3d on the command line. In order to run with DirectDraw support, use -video ddraw on the command line. And if you want to try the really slow GDI support, use -video gdi on the command line. I'd appreciate it if folks could try it out on their systems and report any problems here on this blog post.

Some interesting things to try out:

Thanks!

MAME 0.106u4 is out

I've posted an updated version of MAME over at mamedev.org. This should fix most of the major issues I introduced in the last one. :)

Also, since some people want to give it a try but aren't currently set up to compile it, you can grab an unofficial pre-built version here for experimentation.

Creating New Layouts

This post is inspired from a message board post indicating that it sounded like it was a lot harder for non-programmer types to make layout files than it was in the previous system. Well, looking at my previous two posts on the layouts, I can understand why. The new system has a lot of flexibility, which can be intimidating. And then I discussed converting old .art files, which makes things sound a heck of a lot more complicated than they need to be.

So, in the hopes of convincing people that the new system is actually simpler, let's talk about making a layout that adds a bezel. I'll assume you have the bezel artwork, either with embedded alpha channel, or with a separate mask alpha, all ready to go. We'll call the bezel artwork file mybezelname.png and the mask file (if necessary) mymaskname.png.

Now, presumably, you've loaded this artwork into some kind of image editing problem, so you know the dimensions of the image. Let's say it is bezelwidth pixels wide and bezelheight pixels tall. The one remaining piece of information you need to figure out is where does the screen go, relative to the artwork? Keep in mind that if the screen is horizontal, then the screen height should be 75% of the screen width. For example, if, within your artwork, the screen should be 1000 pixels wide, then it should be 750 pixels tall. If you're dealing with a vertical game, then reverse those numbers.

Once you figure out where the screen should go relative to the artwork, make a note of the top, left, bottom, and right coordinates of the screen position. We'll call those tscrpos, lscrpos, bscrpos, rscrpos, respectively.

Now all you need to do is write a .lay file that contains a single element to hold your artwork, and then a view that positions your artwork and the screen at the right positions. Below I've written a simple template. Just plug in the values I mentioned above into the template and you're ready to go. Note that, unlike the previous system, there is no wacky math to learn. You can work entirely in pixels.

<?xml version="1.0"?>
<mamelayout version="2">
    <element name="bezel">
        <image file="mybezelname.png" alphafile="mymaskname.png" />
    </element>

    <view name="Bezel Artwork">
        <screen index="0">
            <bounds left="lscrpos" top="tscrpos" right="rscrpos" bottom="bscrpos" />
        </screen>

        <bezel element="bezel">
            <bounds left="0" top="0" right="bezelwidth" bottom="bezelheight" />
        </bezel>
    </view>
</mamelayout>

If there are questions, please post them here and I will try to answer them.