31 December 2020

Setup MAME 0.227 from scratch on Macs (Update December 2020/January 2021)

Another update on how to configure MAME from scratch in the very preferable way, which is
via its internal interface MEWUI (default MAME UI since 0.171) and a text editor.
  
If you are willing to work with your Terminal and a Text Editor, it is by far the best way to set up and maintain MAME, irrespective of which frontend you wanna use later on.

So let's go step by step from scratch. 
MEWUI - click to enlarge
Step 1 - Basic Homework 

Download and install SDL 2 as explained here. Download a good text editor - I now use Atom - https://atom.io, which needs a bit of a learning curve, but it's a very decent Open Source editor.

Change Finder Settings in order to display hidden folders and files, e.g. with Deeper (you need access to your User Library folder, which is by default a hidden folder). Another very smart way to display hidden folders and files is this key combo in the finder: SHIFT-CMD-. 

Shift - CMD - . and you see the hidden files greyed out, but fully accessible, very neat!

Of course, download MAME from here and unzip it into the place of your choice. Obviously this is the SDL version of MAME complied for Macs.

Recommendation: I currently keep my running MAME version in the folder 'mame' and keep only older versions in a version-related directory. This definitely helps you further on to stay consistent and carry on your work from version to version.

Step 2 - Create .ini files in the Terminal and manually configure ini paths

After a lot of testing, my recommendation is to create your first .ini files from the Terminal. This should save you from a lot of headache by multiple .ini files that just cause confusion.

  • Start Terminal and cd into your directory of MAME (recommendation: name your main directory mame, see above)
  • Now in the Terminal and in the right directory, the command ./mame64 -cc generates the three default config files in your mame directory:
mame.ini - your overall configuration file for MAME
plugin.ini - your configuration file for activating and deactivating MAME Plugins
ui.ini - your configuration file for the MEWUI interface
  • By default, mame.ini contains the following multiple ini paths:
inipath  "$HOME/Library/Application Support/mame;$HOME/.mame;.;ini"
Recommendation: In my own experience, this is rather unfortunate, because you may end up with multiple .ini files at multiple places rather easily. Since MAME then considers all these .ini files in a certain order, you may be lost in chaos. Right now, I actually prefer having all .ini files in the MAME sub-directory called ini, thus I reduce this line as follows:
inipath                   ini
This means of course that you have to move the three .ini files created in the first step into the ini subdirectory. As long as you do not forget about the ini directory when moving to a new MAME version, this is probably easiest to handle, and the /Library/Application Support directory stays clean of MAME config files
 Step 3 - Start MEWUI (the right way)

Open Terminal and switch to your MAME working directory (easiest way: type 'cd' and then drag the mame directory from the Finder into the Terminal -> press Return in the Terminal window)

Warning: starting mame64 with double-click does not work in the right way -> so start via Terminal as explained here. So you must be in the MAME working directory!

Step 4 - Configuration of shaders in a text editor 

Below I make reference to the line number in my 0.227 mame.ini file - the (italic comments in brackets) are just explanations, do not include them in the mame.ini file!!!

Option 1 - Settings in mame.ini for BGFX/CRT-GEOM-DELUXE (explained here):
line
4   readconfig     1 (leave it as is -> tells MAME to read out this ini and other ini files)
66  lowlatency     1 (switch to lowlatency is always a good idea)
94  artwork_crop   0  (no crop of modern bezels; 1 if you want to crop 4:3 artwork for 16:9)
201 plugins        1 (if enabled, the settings in plugin.ini should work)
253 video          bgfx (switch shaders to bgfx, crucial in macOS)
255 window         0 (start MAME in fullscreen; 1 = windowed mode, less performance)
358 bgfx_backend   metal (opengl if metal does not work on your Mac, try opengl as well)
360 bgfx_screen_chains crt-geom (or crt-geom-deluxe or hlsl if your Mac has the power)
Note: In BGFX, Bilinear Filtering seems to be irrelevant.
That is basically it! With this settings in your mame.ini, you are ready for a BGFX, enabled MAME environment.

Option 2 - Settings in mame.ini for BGFX/HLSL (explained here):
line
350 bgfx_screen_chains hlsl
Consider tweaking HLSL for performance improvements, as explained here.

Option 3 - OpenGL settings in mame.ini for GLSL/CRT-GEOM-DELUXE 

GLSL is a fallback option if BGFX does not perform well (on my machines, I am having quite different results). You need to download the shaders as explained in my new post here. Im my case, they are located in an own directory of mame called CRT-GEOM-DELUXE (but that name is up to you, as long as you include correct paths below).

These changes of mame.ini are required. You can prepare these changes as well and leave MAME with BGFX by changing everything except for the first line 253.
line
253 video       opengl (switches shaders to OpenGL instead of bgfx)
301 gl_vbo      1
302 gl_pbo      1
303 gl_glsl     1
304 gl_glsl_filter 1
305 glsl_shader_mame0   /Users/stefan/Games/mame/CRT-GEOM-DELUXE/Gaussx
306  glsl_shader_mame1 /Users/stefan/Games/mame/CRT-GEOM-DELUXE/Gaussy
307  glsl_shader_mame2  /Users/stefan/Games/mame/CRT-GEOM-DELUXE/CRT-geom-halation

So these shaders are called in a sequence of three. Obviously, you need to include your own correct file path instead of mine.

Note: No need for a separate configuration of vertical shaders!

Important: Never include the file ending .vsh or .fsh - it would not work.

Also consider to tweak the settings of both crt-geom-halation.vsh and crt-geom-halation_Vertical.vsh as described here.

Step 4a - Different Configs for Single Games

Some games work better with different shaders, or they need the waitvsync option as described here.  Also here the manual setup of MAME shines - and you do that for any frontend you may make use of afterwards. 

Name convention: (game name).ini
Directory: (Username)/Library/Application Support/mame/ (same as mame.ini)

The best way is to copy/paste your mame.ini - as soon as your mame.ini is ready. This is also a very nice way to test new mame.ini settings just with one game.

Example - I created a 1942.ini from my ready mame.ini in order to change the following settings:
line
64   speed    1.0 (waitvsync always works together with speed, but in the case of 1942, no speed adjustment is required - see the above link)
257  waitvsync 1 (activate waitvsync to stop bleeding in 1942)

Step 5 - Setup Joystick inside of MAME: 

This is probably the best time to set up your joypad for MAME - as described here. If everything works out nicely, you will from now on move the configuration file named /cfg/default.cfg into the subsequent versions.

Step 6 - Setup Artwork/Overlays inside of MAME: 

Besides a decent shader, artwork is the second most important tweak for me to get a real arcade feeling on your Mac. In this Blog, you will find a lot about tweaking Artwork for your Mac:
My Post about realistic Bezel Artwork for MAME
The most 'official' MAME Artwork directory is here:
http://www.progettosnaps.net/artworks/
When downloading, be sure that you always head for the 16:9 artwork, where available.
Place the .zip files into the Artwork directory, and you should be done.

Step 7 - Look for a Frontend

As of 2020, Negatron is the new kid around the block. On Macs, this is my first recommendation for the time being. See my review in this post.

Further options are QMC2 and Attract Mode.  Look for my older posts on those two frontends. 

Important note for QMC2: Since you configured your standard settings in mame.ini, you need to configure readconfig in QMC2's Global Configuration Settings to "1" and reset QMC2's settings to default settings.



Be careful: QMC2 settings can override mame.ini, so in case of a conflict, set QMC2 settings identical to mame.ini.
Advantage: You have identical settings in different frontends, e.g. QMC2 and Attract Mode.

Step 8: Start MEWUI with a double-click

Of course you can move ahead with MEWUI, which is built into mame64. Then you might want to do the following:

./mame64 Automation: Create a script containing these two lines:
cd /xxxxxxx/xxxxxxx/xxxxx/mame
(of course the xxxxx are placeholders for your directory - and assuming that your directory is mame)
./mame64
Save it under the filename MAME64.command and make it executable via chmod +x. From now on you can start MEWUI from the Finder it by double-clicking this script.

Conclusion: 

Setting up MAME via Terminal and a text editor is superior. You exactly know what you are doing. There are also some advantages over configuring from within QMC2: 
  • You configure the new MAME plugins in the UI, so you can e.g. turn on the new highscore LUA-support -> that one really rocks.
  • joystick works out of the box, it works in the UI without configuration, I just had to configure P1 coin, P1 start and UI exit as described here and everything is in place for moving things without the keyboard - niiiiiice
  • You set a very solid groundwork for a frontend such as Attract Mode, as explained here and here.

9 comments:

  1. One thing to note. When using NEWUI and you configure it how you want, when/if you choose save configuration, the changes are saved to ~/Library/Application Support/mame/mame.ini, not the mame.ini in the current directory. This isn't an issue normally, since by default all mame.ini files are set to read the one in Application Support folder first.

    ReplyDelete
    Replies
    1. Correct, this path is the default path for SDL MAME on OSX, thanks, I clarified

      Delete
  2. I am a rookie to this process. Is there an easier way to set this up?

    ReplyDelete
    Replies
    1. Sure! Look down for the first two posts (Welcome and Setup with QMC2) and you should be fine. You are right that this setup here is a more advanced approach, but the work spent here gives you much more stability later on. Sorry for the later response- your anonymous posting landed in Spam ;-)

      Delete
  3. I would like name to be available to all users on the machine, so I put it in /Applications/mame instead of under my user home directory like you have. is this OK or will there be problems later?

    ReplyDelete
    Replies
    1. You are right, there is no real drawback, just the size of the directory - depending upon the amount of your roms and other data. I am unsure about the impact of a too large Apps directory. Alternatively you could place the directory under Users/shared - Ann all users would have access.

      Delete
  4. Is there any way of removing the Cabinets, Control Panel, PCBs, Ends, Bosses from the right column of MEWUI?
    Thanks!

    ReplyDelete
  5. Hi!
    Any idea why some roms, like Wardner, ceased to work on Big Sur? I had no problems before.
    Looks like mame is requesting stuff inside the zip file which are not there and not sure why/if they should be included.

    Cheers!

    ReplyDelete
    Replies
    1. Hi, with every new mame version, some but not all romsets change. That's probably the reason for your problems. You could try if an older mame version still works for your romset. Cheers!

      Delete

Any comments are welcome!