Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news


  

Author Topic: Compile MAME 0.169 with MSYS2 build tools and various patches  (Read 2650 times)

0 Members and 1 Guest are viewing this topic.

artyfarty

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 72
  • I want to build my own arcade controls!
Compile MAME 0.169 with MSYS2 build tools and various patches
« on: February 11, 2016, 08:39:29 pm »
So I wanted to compile my own version of MAME, to apply a number of patches that are available to customize my setup.

I was going to use MAME Compiler, but was having trouble getting it working, and I also wanted to understand how things were actually achieved.

With the recent change in toolset for compiling mame, the old instructions I could find didn't work so well, so I thought I would document my process compiling a 64bit version of MAME with patches, in case it helps someone else.

What I wanted:

MAME 0.169 64-bit
MAMEUIFX extra games support (for Donkey Kong Pauline Edition, Mr and Mrs Pacman, and Asteroids Six Bullets Shot Hack)
HiScore Patch (to save hiscores on older games)
Defender-Battlezone-Stargate Joystick Patch (to use an 8 way joystick for directions on these games)
FastStart Patch (to accelerate loading of some old games that are slow to start)
Direct Input (so AutoHotKey works with MAME)


1. MSYS2 Build Tools

(a) Installation

Download the 64-bit toolset from mamedev.org/tools -
https://github.com/mamedev/buildtools/releases/download/1.4/msys64-2016-01-07.exe
or if you want to build a 32-bit binary as well as a 64-bit binary, download the dual 32-bit/64-bit toolset -
https://github.com/mamedev/buildtools/releases/download/1.4/msys64-32-2016-01-07.exe

Double click this, and select a directory to extract to. I used M:\Games\MAMEdev.

Then double click the autorebase.bat file in the msys64 directory that you just extracted.

Later on, I had trouble because I didn't have a HOME environment variable set, so now is a good time to check. I decided to make a directory M:\Games\MAMEdev\home, and set the environment variable in the win32con.bat file (in the msys64 directory where the files were just extracted M:\Games\MAMEdev\msys64\wincon32.bat), by adding the following line at the top of the file:
@set HOME=M:\Games\MAMEdev\home

(b) Configuration

Next you need to run win32con.bat, which should start a console in the msys64\src subdirectory:
[MINGW64] M:\Games\MAMEdev\msys64\src>

The mamedev.org/tools page tells you to run the following commands to update your tools environment:
Code: [Select]
git config --global core.autocrlf true
git pull
Then exit
Code: [Select]
exit
(c) Updating build tools  [Edited 14-Feb-2016 to reflect instructions for "the safest procedure" for updating on the MSYS2 install wiki https://sourceforge.net/p/msys2/wiki/MSYS2%20installation/]

Run win32con.bat, and enter the following command to check the MSYS2 tools are up to date:
Code: [Select]
pacman -Sy
pacman --needed -S bash pacman pacman-mirrors msys2-runtime

Then exit
Code: [Select]
exit
Run win32con.bat again
You need to install the patch utility, which isn't installed by default, so enter the following commands:
Code: [Select]
pacman --needed -Sy patch
pacman -Su

Then exit
Code: [Select]
exit

2. MAME Source

Instead of downloading the latest MAME source from github, I wanted to use the specific 0.169 source.
Download the 0.169 source from mamedev.org/oldrel.html -
https://github.com/mamedev/mame/releases/download/mame0169/mame0169s.zip

Double click this, and enter M:\Games\MAMEdev\msys64\src as the extraction directory

At this point, you should be able to start win32con.bat, and type "make" at the command line to build a vanilla version of MAME - but I want to add patches first.


3. Patches

(a) MAMEUIFX extra games support

Download the mameuifx extra roms source from mame32fx.altervista.org/forum/viewtopic.php?f=1&t=4 -

http://www.mediafire.com/download/q1ba8pg15nlzlsq/extra_games_src.7z
[Note this post has a link to the latest source, and there doesn't seem to be anywhere that has previous versions. I downloaded 0.169, but currently 0.170 is available. I'll ask mamesick if he can keep links to old source.]

Extract the files in this download to over the top of the MAME source code in the msys64\src subdirectory. You need to have 7-zip installed for this, yopu can download it from 7-zip.org

In my case, I right clicked, 7-zip, Extract files..., extract to M:\Games\MAMEdev\msys64\src\
Answer "Yes to all" when prompted to overwrite files

The MAMEUIFX extra rom source excludes the MESS subtarget by default. I wanted to include these, so you need to uncomment a line in one of the files.

In the msys64\src\src\mame directory, edit mame.lst with notepad (in my case, M:\Games\MAMEdev\msys64\src\src\mame\mame.lst)
Change the line:
Code: [Select]
/*#../../../../../src/mame/mess.lst*/ // this stuff is disabled for now...to:
Code: [Select]
#../../../../../src/mame/mess.lst
And save the file.

(b) HiScore patch

Download the hi-score diff file from forum.arcadecontrols.com/index.php/topic,64298.0.html -
http://mamestuff.lowtrucks.net/MKChamp/hi_169.txt
and copy it to the msys64\src directory (M:\Games\MAMEdev\msys64\src)

Start wincon32.bat, and type the command:
Code: [Select]
patch -p0 -E < hi_169.diff
Then exit
Code: [Select]
exit
(c) Defender-Battlezone-Stargate Joystick Patch

Download the patch Defender-Battlezone-Stargate_169.diff.txt from forum.arcadecontrols.com/index.php/topic,108813.0/all.html -
http://forum.arcadecontrols.com/index.php?action=dlattach;topic=108813.0;attach=343868
and copy it to the msys64\src directory (M:\Games\MAMEdev\msys64\src)

Start wincon32.bat, and type the command:
Code: [Select]
patch -p0 -E < Defender-BattleZone-Stargate_169.diff.txt
Then exit
Code: [Select]
exit
(d) FastStart Patch

Download faststart-0169.patch from forum.arcadecontrols.com/index.php?topic=146146.0 -
http://playground.zaplabs.com/sandbox/kb/arcade/emulation/mame/patches/faststart-0169.patch
and copy it to the msys64\src directory (M:\Games\MAMEdev\msys64\src)

Start wincon32.bat, and type the command:
Code: [Select]
patch -p1 -E < faststart-0169.patch
Then exit
Code: [Select]
exit
(e) Static linking of libwinpthread-1.dll

As explained at http://www.mameworld.info/ubbthreads/showflat.php?Cat=&Number=348783&page=0&view=expanded&sb=5&o=&vc=1 there is a problem with the MAME 0.169 source, that libwinpthread-1.dll is not statically linked, but needs to be present a runtime for MAME to start. This is fixed in the 0.170 source tree, but I wanted to fix it for 0.169.

In the msys64\src\scripts directory, edit genie.lua with notepad (M:\Games\MAMEdev\msys64\src\scripts\genie.lua), and find the following line (line 1097 for me):
Code: [Select]
"-static-libstdc++",
Underneath this, insert a new line:
Code: [Select]
"-static",
And save the file.


4. Direct Input

I want to use AutoHotkey to send input to MAME - I use this primarly to exit MAME on my cabinet, bu using an AHK script that sends an exit command to MAME when I press the pause key for 3 seconds. By default this doesn't work, so you need to compile MAME to support DirectInput.

In the msys64\src\src\osd\windows directory, edit input.cpp with notepad (M:\Games\MAMEdev\msys64\src\src\osd\windows\input.cpp), and find the following line (line 10 for me):
Code: [Select]
#define FORCE_DIRECTINPUT   0and change it to:
Code: [Select]
#define FORCE_DIRECTINPUT   1
And save the file.


5. Compiling

Start win32con.bat, and enter the following command, replacing the number in "-j8" with the number of cores on your PC:
Code: [Select]
make all -j8 OPTIMIZE=3 SYMLEVEL=1 SYMBOLS=0 PTR64=1 TOOLS=1 DIRECTINPUT=7
This will take "an extended period of time" to complete, after which you will have a mame64.exe (plus all the MAME tools exes) in the msys64\src directory.

If you want to compile a 32-bit version of MAME, start win32con.bat, and enter the following commands:
Code: [Select]
config32
make all -j8 OPTIMIZE=3 SYMLEVEL=1 SYMBOLS=0 PTR64=0 TOOLS=1 DIRECTINPUT=7


6. Troubleshooting

If the compile doesn't complete, try running:
Code: [Select]
make clean
and then re-run the compile command.
« Last Edit: February 14, 2016, 06:19:18 am by artyfarty »

artyfarty

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 72
  • I want to build my own arcade controls!
Re: Compile MAME 0.169 with MSYS2 build tools and various patches
« Reply #1 on: February 11, 2016, 10:32:31 pm »
I forgot to thank the people who provide the patches to modify the standard MAME and make it even better:

mamesick for the MAMEUIFX extra roms source (and also for the fabulous MAMEUIFX, which I use when not in cabinet mode)
MKChamp for the hiscore patch
h0tw1r3 for the joystick and faststart patches (and for his interesting custom MAME build UXME)

Martin

  
 

Sitemap 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31