Spludlow Web Header

Case study – MAME


Contents

Introduction. 1

First look at the Data. 1

Dealing with XML. 1

Running the Conversion Code. 1

Putting it in a Database. 1

Identifying unknown video game boards. 1

Repairing corrupt video game board EPROMs. 1

Games in MAME. 1

Re-Packing ROM sets. 1

 

Introduction

If you’ve never heard of MAME, well it’s an open source “Multiple Arcade Machine Emulator”, you can play old arcade games with it.

There is a dataset available from the MAME website downloads page called the “full driver information in XML format”. It describes all the technical hardware information for each arcade game MAME supports required to emulate the machines. This data can be very useful when it comes to repairing actual old arcade game boards, especially info on the EPROMs, such as the following:

·         Identify an unknown board by pulling out an EPROM, read it, checksum the data, then look it up on the database.

·         Confirm an EPROM is not corrupt by looking if the checksum exists in the database.

·         List the EPROM set for an arcade board to see what you need and the chip locations on the PCB.

·         Look for related EPROM sets to see if you can change the game or edition with a “ROM Swap”

Wouldn’t it be nice to create a simple web page that would provide these lookups and ROM set listings?

First look at the Data

You can download the XML file from http://mamedev.org/release.html it’s the 3rd item after the 32 and 64 bit Windows Binaries.

The data is in a single XML file that’s around 200MB when it’s uncompressed. The parent elements within the XML are “machine” there was 37,317 when I looked and they represent the individual arcade game machines. Here is a simplified sample of one of the XML records, I have chopped a load of stuff out for demonstration purposes:

<machine name="mrdo" sourcefile="mrdo.cpp">

                <description>Mr. Do!</description>

                <year>1982</year>

                <manufacturer>Universal</manufacturer>

                <rom name="a4-01.bin" size="8192" crc="03dcfba2" sha1="c15e3d0c4225e0ca120bcd28aca39632575f8e11" region="maincpu" offset="0"/>

                <rom name="c4-02.bin" size="8192" crc="0ecdd39c" sha1="c64b3363593911a676c647bf3dba8fe063fcb0de" region="maincpu" offset="2000"/>

                <rom name="e4-03.bin" size="8192" crc="358f5dc2" sha1="9fed1f5d1d04935d1b77687c8b2f3bfce970dc08" region="maincpu" offset="4000"/>

                <device_ref name="z80"/>

                <chip type="cpu" tag="maincpu" name="Z80" clock="4100000"/>

                <chip type="audio" tag="u8106_1" name="U8106" clock="4100000"/>

                <display tag="screen" type="raster" rotate="270" width="240" height="192" refresh="59.943237" vtotal="262" vbend="32" vbstart="224" />

                <driver status="good" emulation="good" color="good" sound="good" graphic="good" savestate="supported"/>

</machine>

Dealing with XML

Using XML to transmit data is XMLs strong point, it is well documented, understood and supported, and is totally independent of machine architecture, OS platform, and application software. In this case, to provide the MAME data, you wouldn’t really expect it in any other format.

Thing is, I want my data in a relational database, so I can start building applications that consume it in a way I’m familiar with, so it’s going to want converting.

Running the Conversion Code

Needs 3.5GB and took 4 minutes on my hardware.

Included in the Spludlow Framework is a method “Spludlow.Data.MAME.RelationizeXmlToDatabase()” it’s only a few lines of code it calls the following standard methods:

·         Spludlow.Data.XML.ConvertRelational() – Main XML conversion, returns a DataSet (Make sure you have enough memory)

·         Spludlow.Data.ADO.Schema() – Gets a Spludlow Schema from the DataSet

·         Spludlow.Data.Database.AutoAddForeignKeys() – Automatically create foreign key relationships on the Spludlow Schema

·         Spludlow.Data.Schemas.ImportDatabase() – Main database import, uses the DataSet and Spludlow schema to create a database

Let’s go through the complete process of running this code shown in the video:

·         Ensure “SpludlowGroup” has the “sysadmin” role on the database, so it can do things like create databases: SSMS->Security->Logins->SpludlowGroup Properties->Server Roles->Tick sysadmin

·         Download and extract the MAME XML file put it here “C:\ProgramData\SpludlowV1\mame0191.xml”

·         On the Intranet call page search for “mame” and click the method “RelationizeXmlToDatabase()” the parameter textboxes will be shown

·         xmlFilename: “C:\ProgramData\SpludlowV1\mame0191.xml”

·         connectionString: “WSYS-HOME-PC” (shorthand SQL Server hostname)

·         databaseName: “MAME”

·         tempDirectory: (leave empty for null if using SQL Server see note below for other database server types)

·         Click Make Call Text

·         Click Run Call Text

·         Go check on the Intranet Status page that the task is running and no errors have occurred

·         Go and check the Windows Task Manager and check you aren’t running out of memory

·         When CPU activity has stopped go and look at the Intranet Logs page to confirm it has finished without any problems.

·         Open SSMS go into the MAME database and confirm data in the tables

·         In SSMS create a database diagram to confirm all relationships are present

·         Create an Access front end and have a look at the data

Putting it in a Database

I ran the import against Microsoft SQL and MySQL and they both ran pretty quick, using Bulk Insert, less than 5 minutes. Here is the automatically generated MySQL diagram:

The data in now in a relational database without having to mess about manually with database schemas, or writing that much code.

Identifying unknown video game boards

If you have an unmarked non JAMMA board without a pinout interface built then you can identify it from the EPROM chips.

By pulling ROMS from a video game board, reading them with an EPROM programmer (£40 for a USB one), SHA1 hashing the file (7Zip gives you a right click menu), and then searching for the rom in the MAME data you can identify the machine.

You can create a simple search web page or create a query using Microsoft Access.

Repairing corrupt video game board EPROMs

If your game board is playing up the problem can often be bad EPROM chips, where the software is stored.

Exactly like you do when identifying a board read all the EPROMS on the board and identify each one, you should be able to work out which variation of the machine you are using.

Any ROMs that you can’t find are most likely faulty. Bad ROMs often have bad sectors that return random data every time you read them, you can confirm this by doing a “read” and then “verify” in the EPROM software.

Replace the bad ROMs using chips of the same size and burn them using rom images obtained from a rom web site, SHA1 the images to confirm they are the right ones.

Games in MAME

VIDEO COMING SOON!

I really wanted to find a game I used to play at the youth club in the 1980s. I’ve tried searching the web and looking though screen shots but wasn’t getting anywhere.

My first plan was download a ROM collection from P2P and create a simple BAT file to go through booting up each game and try to find it. The problems I found:

·         No way of missing out machines that are not video games

·         No way of missing out machines from the wrong year

·         Hitting loads of duplicates (variations of the same game)

·         Many games just not working with ROM missing errors

Looks like some code needs writing to address these problems.

Re-Packing ROM sets

Doing a few tests with various ROM collections I found there were differences with the contents of the zip files so MAME was not finding the ROM images, it was either not present or the files where not named as expected.

While messing about with some reporting code to compare the machine zip contents to the database the penny dropped, I’ve got everything I need to re-create all the machine rom zips myself:

·         Maintain a “ROM Store” using only the SHA1 to reference the rom images

·         Import all the files from ROM collections into the Store (I can keep doing this for as many collections as I can find from P2P)

·         Create all the machine rom zip files using the database to grab all the ROMs from the Store and name them correctly

·         Create the BAT file to run through the games using a specific database select to only target the games I want

Please see the methods in Spludlow.Data.Mame. More details coming soon, see the method comments in the code for now.

 


 
 
 
 
 
 
 
 
 
Spludlow Web Footer