Customized MAME.EXE versions suited for cabinets

Show us your cabinet, control panel, or clever mod. Tell us what you did and share how you did it. Bask in the glory!
User avatar
aaronbewza
Gamer Extreme
Gamer Extreme
Posts: 25
Joined: October 20th, 2011, 3:27 am
Favorite Game: Galaga
Location: Cache Creek, British Columbia
Contact:

Customized MAME.EXE versions suited for cabinets

Post by aaronbewza » October 20th, 2011, 3:41 am

How to custom compile MAME v141

This is a tutorial on how to compile your own version of MAME.EXE with high score support
and "State successfully loaded" message boxes removed.

I'd like to thank Mr. Do for most of the information presented below, and an anonymous friend
who provided the information about how to remove Save State message boxes.


DISCLAIMER: If you do not follow these instructions and mess up your system, please don't
insult me by blaming me. All we are doing here is creating a custom MAME.EXE which will not
affect any other part of whatever system you have, it is a replacement for your
existing MAME.EXE. Please back up or move your existing MAME.EXE and
your MAME.INI config file to a safe place before you begin.

Version 141 was mentioned in an post below... so we will be using version 141
for the demonstration. We are also going to assume the 32-bit version is
going to be created. We are going to start by getting the source
code directly from MAME. All previous releases (older than the latest release)
can be obtained directly from the MAME website at the following page:

http://mamedev.org/oldrel.html

- Select Version 0.141 from the "Source" column (not the "Binary" column) and
download it to a location on your computer. You should now have a ZIP file
which is about 16mb in size

- Create a folder down at the root of C: drive (the short path name minimizes glitches)
called "mamesrc"... so this new folder is now at the location C:\mamesrc

Open the downloaded ZIP file and extract the package inside (another ZIP folder called "mame.zip")
to any location of your choice on your computer. Open mame.zip and you should see the following
folders and files:

docs (folder)
src (folder)
makefile (file)
whatsnew (file)

Extract these 4 items to "C:\mamesrc" folder you created earlier.
The entire C:\mamesrc folder will now be approximately 93mb in size.

- Browse to the following page at the MAME website:

http://mamedev.org/tools

We are going to need the tools to compile the source code we have stashed in C:\mamesrc.
If you look partway down the page under section 2, in the "Binaries" column, download
"mingw-mame-20110519.exe" (the latest version as of the date this post was made)...
we want that. It is usable for both 32 and 64-bit builds, and in my opinion works
great for what we are doing.

So as that's downloading, let's go back to C: drive and create a folder called "mingw"...
This is the folder we are going to extract the new package to. Open your downloaded
"mingw-mame-20110519.exe" file and make sure C:\mingw is displayed in the "Extract to" box
which appears, and press OK. This will auto-extract the contents of the package into C:\mingw.
You should see two folders in C:\mingw: mingw64-w32 and mingw64-w64

Now, on C: drive, we have two folders like this:

mamesrc
mingw


And we are almost ready to work on this!

We now need a few tools to make patching easy.

- Browse to the following page at Mr. Do's MAME page:

http://mameworld.info/mrdo/compile.html

...and download a file called "compile_extras.zip" from the "DIFFs, Extra Files, and Stuff"
category which is partway down the page. Unpack the contents of "compile_extras.zip" into
your "C:\mamesrc" folder.

- Browse to the following page at Arcadecontrols.com:

http://forum.arcadecontrols.com/index.php?topic=64298.0

...and under the "DIFF TO DOWNLOAD" column, right-click "Save as" on version 141...
where it asks for a file-name, change the extension from .txt to .diff (important!)
and point it to your C:\mamesrc folder (it should look like C:\mamesrc\hi_141.diff when it is in there).

Now we are going to tweak our helper tools we got from Mr. Do... open your C:\mamesrc folder
and right-click on "MakeMAME.bat". Select "Edit" from the menu... notepad should open up and
display the following:

set path=c:mingw\bin
mingw32-make


This needs to be changed to reflect the actual path, so change the first line to:

set path=c:mingw\mingw64-w32\bin

...save the file then close it.

At this point, we are 100% ready to patch in the HI_141.DIFF file which includes high score support...
This, by default, also removes the message windows that say "loading" and the other ones that display
"This game may not run correctly..." etc...

Please note that anything described in the section below is not officially supported by MAME
and would be frowned upon, so PLEASE do not bug them with any support questions at all... they
will not be honored there. If you want to compile a regular version of MAME, skip the following section
and start again down at "Compiling".

- Open "!Command Prompt" in your C:\mamesrc folder, a CMD window will appear.
- type the following:

patchmame hi_141

and press ENTER. You will see a list of files displayed as it alters them... close the window once it is finished.

This has patched necessary source files, and has included the high score support we discussed earlier.

I want to take you the extra mile. We are also going to manually remove the message boxes
which display "State successfully loaded." when a game is opened. There is no patch for this,
it must be done manually. Hey I could write a short script that removes these automatically! I just thought
of that lol, I will get to that soon.

You may skip this step if you are ok with seeing those message windows every time a saved state is loaded,
but I personally cannot stand them after a few hundred times of moving the joystick back and forth.


We need to alter a specific file, located in "C:\mamesrc\src\emu", called "machine.c" so find that,
and just for safety purposes, copy that file and place the copy somewhere safe, in case we mess up.
Right-click "machine.c" and choose "Edit" from the menu that appears.
The file should open in notepad. We need to find the following lines:

case STATERR_NONE:
if (!(m_game.flags & GAME_SUPPORTS_SAVE))
popmessage("State successfully %s.\nWarning: Save states are not officially supported for this game.", opnamed);
else
popmessage("State successfully %s.", opnamed);
break;


They are located about 2/3 of the way down... or choose "Edit/Find" from the menu
and search for "case STATERR_NONE:" (without the quotes).

Let's remove everything after "case STATERR_NONE:" and before "break;"... place your cursor
just to the left of the word "if" (located on the line under "case STATERR_NONE:") click and hold, and drag your mouse down to highlight
everything down to the left side of "break;", and delete it.
Now you should have something that looks like this:

case STATERR_NONE:
break;


If you do not have the above two lines instead of what was there before... please make sure you
try again until you get it right. "break;" needs to be on the line UNDER "case STATERR_NONE:"
or it may cause a massive malfunction.

OK! Once you are confident it has been altered correctly, save and exit "machine.c" and return to
your C:\mamesrc folder.


Compiling:

- Open your C:\mamesrc folder and open "!Command Prompt", a CMD window will appear.
- type makemame
- press ENTER
- go make a cheeseburger, the compile will take probably half and hour.

You should end up with "mame.exe" in your C:\mamesrc folder, after it is finished.
Try it out!!! Move it into your working MAME folder and open your system as usual.
For safety purposes, maybe back up your existing MAME.EXE somewhere.

NOTE: for hiscore support to work, you need the version of HISCORE.DAT which matches your
version of MAME, in this case 0.141 so browse to the following page:

http://www.mameworld.info/highscore/download.htm

and click the top red button to download the latest Hiscore.dat file... you should now have
a ZIP folder called "hiscoredat.zip". Open this and extract Hiscore.dat to your working MAME folder
where you should now have your new MAME.EXE file located.
You also need to create a new folder called "hi" (without the quotes) in your working MAME folder...
so Hiscore.dat can save high score files in it. It will not work otherwise.

You can right-click "Create Shortcut" on your new MAME.EXE and if you right-click on the shortcut
and select "properties" you can then add " -cc" to the Target line (without quotes, note the space!).
Now run this shortcut and it will create a "MAME.INI" configuration file with the new high-score options listed in it.
It also lists other options which you probably normally configure, but I'll go through them here so you are clear.
Change the following options in "MAME.INI" to what shows here:

Under # CORE STATE/PLAYBACK OPTIONS
set AUTOSAVEto 1 (for automatic game state saving support)

Under # CORE PERFORMANCE OPTIONS
set autoframeskip to 1 (will keep timing of game more accurate)

Under # CORE MISC OPTIONS
set skip_gameinfo to 1 (removes info message box)
set confirm_quit to 0 (removes confirmation dialog box when exiting)

Under # CORE ARTWORK OPTIONS
set artwork_crop to 1 (crops your artwork files to show game maximum size)

Under # WINDOWS VIDEO OPTIONS
set waitvsync to 1 (should remove "tearing" effect on graphics)

If you make a copy of MAME.INI and place it into your INI folder, and rename it the same name as a ROM,
MAME.EXE will refer to that new INI file whenever you open that particular game. For example, if I copy
MAME.INI into the INI folder and then rename it to 1942.INI, and if I open that and set "autosave" to 0,
MAME.EXE will not attempt to open any saved state files for the game 1942, ever again. I can change
configuration details for 1942 in 1942.INI and they won't affect any other games but 1942.

I'll make any corrections or field any questions that may arise... just leave your questions and comments here and I will do whatever I can
to get you with the answers you need. I hope each and every one of you finds use for this information... it is handy for arcade cabinets.

Without Mr.Do's tutorials and MkChamp's contributions, the ability to do this would not exist
so I would like to thank them for making this tutorial possible.

I will add information for x64 builds soon :smile: as soon as I can have a chance to do it first for myself,
just so everything is verified before I pass that information along.
Last edited by aaronbewza on November 4th, 2011, 2:41 pm, edited 5 times in total.
AutoHotkey builds cool stuff.

User avatar
aaronbewza
Gamer Extreme
Gamer Extreme
Posts: 25
Joined: October 20th, 2011, 3:27 am
Favorite Game: Galaga
Location: Cache Creek, British Columbia
Contact:

Re: Customized MAME.EXE versions suited for cabinets

Post by aaronbewza » October 20th, 2011, 5:20 pm

I should clarify... the changes I've described above can be applied to most releases of
MAME, including brand-new ones, not just the versions I've mentioned... those are
simply the versions that work within my own ROMset (143u5).

Another thing I can potentially contribute is my "backup system" for 3DArcade
frontends, which I've built myself using CMD and AutoHotkey scripting.
It is 100% functional on my cabinet and I use it all the time for its extra features.
Basically, if 3DArcade crashes on your cabinet, a screen appears that says it crashed
and you have two options listed:

Player 1 Start button = Restart Arcade, or
Player 2 Start button = Run Restore Tool.

The Restore Tool will restore 3DArcade's basic folder structure, from the last time
it was archived... which brings us to the extra features:

Archive High Scores - Archives all the NVRAM, High Score files, and Save State files into a ZIP folder.
Restore High Scores - Restores all the above files back into their working folders, effectively taking the system back in time.
Exit System - Shuts the cabinet down completely
Restart System - Shuts down, then starts system again
Archive Entire Arcade - Backs up working folders completely (without roms, snap, titles, artwork, or video folders)

Before I collect together all these things to make it possible to share it and for others to use it, I need
to restructure my working folders to match the default 3DArcade setup... for example I have all my MAME
stuff in the same folder as 3DArcade stuff, not in a subfolder of its own. Obviously for it to work
on other peoples' systems it would have to be standardized like that, and users would have to
make sure to have their own working folder standardized the same way (so all the paths listed
in the backup system script will hook up properly to the items it is working on).

In any case, I will be sharing these extra things with the MAME community, when I can.
AutoHotkey builds cool stuff.

User avatar
aaronbewza
Gamer Extreme
Gamer Extreme
Posts: 25
Joined: October 20th, 2011, 3:27 am
Favorite Game: Galaga
Location: Cache Creek, British Columbia
Contact:

Re: Customized MAME.EXE versions suited for cabinets

Post by aaronbewza » October 21st, 2011, 2:34 am

MkChamp's hiscore.diff files makes three options in the MAME.INI file:

disable_hiscore_patch 0 <--- allows HISCORE.DAT to be used and save many high scores permanently
disable_nagscreen_patch 0 <--- removes all those message windows (game may not run properly etc)
disable_loading_patch 0 <--- removes "loading" message windows

Setting these to "1" would be the default behavior you see with using a regular build of MAME...
The question becomes: Do you know how to compile version 141? It needs to be "patched" with
MkChamp's diff files so you'd need all the "source files" for version 141.
AutoHotkey builds cool stuff.

User avatar
Incito
Founder
Founder
Posts: 2094
Joined: June 5th, 2008, 3:20 pm
Favorite Game: Marvel vs. Capcom 2
Location: Metro City
Contact:

Re: Customized MAME.EXE versions suited for cabinets

Post by Incito » October 22nd, 2011, 1:02 am

Usually you only see that on the absolute first game play. Aftr that you should not see it.

User avatar
aaronbewza
Gamer Extreme
Gamer Extreme
Posts: 25
Joined: October 20th, 2011, 3:27 am
Favorite Game: Galaga
Location: Cache Creek, British Columbia
Contact:

Re: Customized MAME.EXE versions suited for cabinets

Post by aaronbewza » October 22nd, 2011, 6:21 am

That''s totally true for games flagged as working... but there are still the nag screens
for the ones that aren't 100% (This game may not run correctly etc...)
I find after a few hundred times seeing them over and over, it becomes
quite aggravating and takes away from the "authentic" feel of playing
an old arcade favorite on a cabinet.
AutoHotkey builds cool stuff.

User avatar
Incito
Founder
Founder
Posts: 2094
Joined: June 5th, 2008, 3:20 pm
Favorite Game: Marvel vs. Capcom 2
Location: Metro City
Contact:

Re: Customized MAME.EXE versions suited for cabinets

Post by Incito » October 24th, 2011, 8:49 am

Welcome to MA aaron. :thumbsup:

User avatar
aaronbewza
Gamer Extreme
Gamer Extreme
Posts: 25
Joined: October 20th, 2011, 3:27 am
Favorite Game: Galaga
Location: Cache Creek, British Columbia
Contact:

Re: Customized MAME.EXE versions suited for cabinets

Post by aaronbewza » October 24th, 2011, 1:42 pm

Thanks for having me! :smile: I thought to myself "Why should it be so difficult to find all this information in one spot?"
so when I found this place accidentally I was totally stoked about sharing the information I have learned in the last
few years. Especially once I read through some threads and realized this info is definitely needed here with all
the cabinets floating around.
Ever since I've ditched all those message windows, and played many many games with the high scores STILL
intact (some are a couple years old now), I could never go back to a regular build of MAME.EXE because it's
too painful to deal with that stuff lol...
OK so later today (time permitting) I will start work on a tutorial which will explain all these things and
how to accomplish them yourselves (it's not hard once you do it). Of course I will provide help and support for
the tutorial, I know not everyone will "get it" right away... I did not understand completely until I applied myself
to going through the steps from start to finish.
Ok talk to you all in a while...
AutoHotkey builds cool stuff.

User avatar
aaronbewza
Gamer Extreme
Gamer Extreme
Posts: 25
Joined: October 20th, 2011, 3:27 am
Favorite Game: Galaga
Location: Cache Creek, British Columbia
Contact:

Re: Customized MAME.EXE versions suited for cabinets

Post by aaronbewza » October 25th, 2011, 2:22 pm

When creating your own MAME.EXE, the worst thing that could happen
is it won't compile at all, or won't completely compile. This would most likely happen if the files are not
in the correct spot, or if "MakeMAME.BAT" or "PatchMAME.BAT" list the wrong path
(which should be C:\mingw\mingw64-w32\bin).

Sometimes there is a glitch, and that can be from odd reasons... for example: v0.135 did not want to compile
for me at first, it kept glitching out on a file called "video.c" so I replaced that one file with the "video.c" file
from the mame v0.136 source files instead, and then it was able to completely finish.

I've just remembered that if any of you attempt to compile and are unsuccessful, there is a folder created during compiling
called "obj" (in C:\mamesrc) and this needs to be deleted between attempts at compiling. The "obj" folder contains
freshly put-together files made from existing files in your C:\mamesrc folder, and if an error occurs,
the entire "obj" folder should be deleted to avoid glitches. I will add this info to the post above :)

Like I mentioned, I am available for questions or help. I'm no expert but I understand the process, I may
not be able to help 100% of the time though... it all depends on what the problem is.

EDIT: I can edit the last post I made, but I cannot edit any other posts... this is not good as I've planned to go back into
the tutorial and fine-tune it to cover all angles and make it easier to follow, and add alternate information for other
versions of MAME... and add the info for x64 builds. Is this possible at all?
AutoHotkey builds cool stuff.

User avatar
Incito
Founder
Founder
Posts: 2094
Joined: June 5th, 2008, 3:20 pm
Favorite Game: Marvel vs. Capcom 2
Location: Metro City
Contact:

Re: Customized MAME.EXE versions suited for cabinets

Post by Incito » October 25th, 2011, 2:53 pm

I could grant you privies to allow you to edit your post. You on your way to be a GSO member and that is one of the benefits. :rolleyes:

User avatar
aaronbewza
Gamer Extreme
Gamer Extreme
Posts: 25
Joined: October 20th, 2011, 3:27 am
Favorite Game: Galaga
Location: Cache Creek, British Columbia
Contact:

Re: Customized MAME.EXE versions suited for cabinets

Post by aaronbewza » October 25th, 2011, 4:18 pm

Ah the "Gold Skull" status... :smile: That would be one way, it is definitely one of my goals to earn
one of those skulls. Let's wait and see how this tutorial sits with other members, and as
I help them along the way perhaps that would earn one of those skulls at some point?

If you follow the tutorial step by step, one thing at a time, then it
will all work out. It seems like a huge complicated set of things to do but split that up into a step-by-step process
and each step becomes a simple task, really. I think the trick is not to be in a hurry, and to have
enough patience to deal only with the one item on the list you have in front of you before moving on to the next step.
That's the beautiful part of computers... they will sit there obediently waiting for you to tell it what to do next.
Then it is not a hugely complicated list where you are trying to keep track of everything all at once.

The high score thing you are talking about, that would be the HISCORE.DAT file I mention above... there are
no other options to save high scores (unless you have Save States enabled, but that's not all the games).
Your MAME.EXE must have high score support to use HISCORE.DAT, and the only way to give a newer version
of MAME high score support is to patch it with the diffs (as described in the tutorial).
New games are added to it every once in a while, so it is probably best to download the newest version from
the link I've provided, from their site directly. For MAME versions earlier than v0.133u1 you'd need to
use the old version of HISCORE.DAT, which is included with the newest version's download anyway.

There are custom compiled MAME.EXEs floating around out on the net that have this support, and most of them are great, but none
of them (as far as I know) have the "State successfully loaded" message boxes removed... and this is where
we are now, you can compile your own with high score support and no message boxes... and at the same time
you will gain that sense of accomplishment and know you did it yourself, each and every time you open your favorite
games on your machine. :smile:

In any case, if you stumble on something you don't understand, I will do my best to explain what it is, and/or what needs to be done.

To place HISCORE.DAT in your mame working folder correctly:

- Place HISCORE.DAT in the same folder as your MAME.EXE (your "working folder")
- Create a new empty folder called HI in the same folder as your MAME.EXE (your "working folder")

HISCORE.DAT will use the HI folder to store high score files into... provided your version of MAME.EXE supports HISCORE.DAT
(which is why patching that DIFF file is important to do)
AutoHotkey builds cool stuff.

Post Reply