MAME and ROM Merging - Why and How
----------------------------------
(Please send corrections and/or additions to dweston@globaldialog.com)

To merge or not to merge?

That seems to be the question on the minds of the emulation community of
late.

This document will attempt to explain the changes to the ROM files,
including the reasoning behind the renaming, as well as what merging
entails,  the pros and cons associated with it, and how to go about
accomplishing this task.

Why -

Recently, MAME has been taking greater lengths to document the hardware
that the games run on. It started with printing out the CPU and sound
chip information and now it has been extended to display the company and
year information for each game. As a logical extension of that, the
driver now also stores information about whether a game is a derivative,
or clone, of another driver.

To this end, MAME now supports several ways to load the ROM files it
needs. To make it all work, MAME now follows a standard ROM naming
procedure which was sorely lacking before. In a nutshell, for every ROM
with a unique checksum, MAME now requires that it have a unique filename.
This enables MAME to make sure it's loading the right ROM from the right
place. For example, there are a ton of Galaxian games and clones. Before,
they all had individual ROMs with names like galaxian.* and now they
have names like superg.* etc. to differentiate between the sets.

Related to that, MAME now assumes that the latest revision of a ROM set
is the common name - the one that presumably contains bug fixes and was
in the widest distribution. It will continue to follow this standard in
the future. This is why, for example, the Asteroids ROM sets were
renamed. The old set, asteroid was revision 1 and the alternate,
asteroi2 was revision 2. They have been renamed to conform to the new
standard, so that revision 1 is now called asteroi1 and revision 2 is
asteroid.

To this end, it became apparent early on that for games which are
derivatives, a lot of redundant ROM information could be discarded since
it was shared amongst the sets. By discarded, I mean that since MAME now
knows that a game is a clone of another, it will use the ROMs from the
main set in instances where the checksums are identical to those in the
clone set. This has several consequences.

1. You can now remove these redundant ROMs from the clone sets. In doing
so, you are not losing anything unique since the redundant ROMs are
identical in every way to those in the main set. Deleting these ROMs is
entirely optional.

2. You can optionally store all related ROMs into one folder or .zip
file. Merging ROMs is entirely optional.

If you choose to merge or delete any ROMs, you are risking compatibility
problems with other emulators. If you intend to use games with MAME and
another emulator, you are better off not merging or deleting until that
other emulator supports the same features as MAME. The file merging.txt
that comes with MAME explains any renaming you might have to do if you
choose not to merge your ROM sets.

Here is how MAME now looks for ROM files:

1. It looks in the directory for that ROM set for the files it needs.
2. If it doesn't find the files there and the game is a clone, it will
then look in the directory of the main set for the ROM files.
3. If it doesn't find it there, it reports the ROM as missing.

With these changes, you may find that some games, like the Popeye bootleg
now require the non-working main set. At first glance, you may think this
is a waste of space, but this isn't necessarily so. You can copy the ROMs
needed for the bootleg Popeye from the main set and then delete the
non-working main set. Alternatively, you can rename the ROMs in the
bootleg set to match the names in the main set. The checksums are
identical, so this doesn't change the gameplay at all.

How -

Some of you may decide to hold off merging your ROM sets for the time
being.
You should, however, prepare your ROM sets for the potential of merging.
You see, the issue here is not just the merging of original games with
clones and/or bootlegs, but renaming existing ROM sets as well. The
merging of ROM sets is a two step process, and many folks are expressing
concern over step two before completing step one.

Before proceeding, I should point out that while step one of this process
(the renaming of ROMs and/or ROM sets is mandatory (in order for games to
work properly), step two (the merging of ROM sets), is *OPTIONAL*.

Let me say that again...

You *DO NOT* have to merge your ROM sets in order for the games to work
properly.
You *DO* however have to rename several ROMs and/or ROM sets in order for
the games to work properly.

Having said that, let's take a look at what needs to be done to make MAME
work as expected.

Step One - (ROM renaming)

1a - Audit your ROMs
Use the VerifyROMs feature (Audit ROMs button in Mac MAME) within
MAME to check your existing ROM Collection.
Open and print the audit file with a word processor.

1b - Re download your ROM Sets
Visit your favorite MAME site, audit printout in hand, and Re download
the ROM sets that the MAME audit says you're having problems with.
Replace the old ROM sets with the new ROM sets.

1c - Run the audit again.
By this time, most of your ROM problems should be taken care of. If so,
congratulations! You can skip ahead to step 1j! If you're still having
problems, continue with the next step.

1d - Unzip the problem ROM set(s).
You'll need to do this to work with the individual ROMs within a set.

1e - Print out a ROM List.
Use the ListROMs feature to obtain a list of  current correct ROM sets.
Save and print this list.

1f - Rename your ROMs.
Compare the contents of your ROM set(s) to the list you printed out.
Correct any discrepancies with the names of the individual ROMs.

1g - Re zip your ROM sets.
This step is optional. Mac users will need a utility that can create a
.zip file

1h - Run the audit again.

1i - Repeat steps 1d through 1h until the audit reports no problems.

1j - Thank the administrator of the site from which you obtain your ROM
sets.
Maintaining a site that manages MAME ROM sets can be a thankless job. The
fact that these folks continue to maintain these sites often amazes me.
The administrators of Dave's Classics and Insert Coin for example, have
done an incredible job of making sure that the ROM sets on these sites
are accurate and complete. Somehow, I don't think a virtual pat on the
back is too much to ask in return...

Step Two - (ROM merging)

(I feel compelled to point out again that this step is *OPTIONAL*)

*DO NOT ATTEMPT THIS OPERATION UNLESS YOU HAVE COMPLETED STEP ONE!*

2a - Print the list
Look in your Documentation directory. Find and print out the
merged.txt document

2b - Backup Your ROM set(s)
*THIS IS IMPORTANT!*  If the following steps don't work, you'll have a
backup of your working ROM set(s)

2c - Unzip the ROM set(s) you wish to merge
Use the printout of merged.txt to determine which sets you will be
working with. Don't worry about renaming individual ROMs, you did this in
step one.

2d - Merge the ROMs
Copy the contents of one ROM set into the other. Replace duplicate file
names.

2e - Re zip the ROM set(s)
Again, this step is optional. Mac users will need a utility that can
create a .zip file

2f - Create a place holder for the front-end if necessary.
In the Mac version of MAME, an empty folder or an alias with the name of the
missing ROM set must be placed in the ROM directory so a selection will
appear in the front end. You should check with the author of the front
end you're using to see if this step is necessary.

2g - Run an audit
If all has gone well, you should have no problems, if not, well, that's
why you made a backup in step 2b...

An Example of How You Can Store Your ROMs-

Let's look at how the new loading scheme affects a ROM set, specifically Popeye.
There are 2 Popeye sets: popeye (non-working) and popeyebl (working).

You can store the ROMs for these games in several ways.

Method 1: All the ROMs in both sets.

This method is the most compatible with other emulators. It stores all the files
needed in each directory or zip, even if it is the same for both sets. There is
no merging here, just renaming. If you don't wish to take up space with the
non-working popeye set, this is the way to go.

popeye (main)       popeyebl (clone)
------              --------
c-7a                po1
c-7b                po2
c-7c                po3
c-7e                po4
                    po_d1-e1.bin
v-5n                v-5n
v-1e                v-1e
v-1f                v-1f
v-1j                v-1j
v-1k                v-1k

Method 2: Only the unique ROMs in the clone set.

Using this method, you can delete the duplicate files from the second set, thus
saving space. MAME is smart enough to look in the main set for them. This method
also gives your front-end something to list for the clone sets. This is partial
merging.

Unlike the first method, this method isn't guaranteed to work with other emulators.

popeye (main)       popeyebl (clone)
------              --------
c-7a                po1
c-7b                po2
c-7c                po3
c-7e                po4
                    po_d1-e1.bin
v-5n
v-1e
v-1f
v-1j
v-1k

Method 2: All the ROMs in the Main Set

Using this method, you can place all the unique ROMs in the main set and get
rid of the second set altogether. This is a complete merge. You can split the
ROMs into subdirectories inside the zip if you wish (i.e. "main" and "bootleg").
MAME ignores any and all subdirectory names.

If you keep all the ROMs in the main set and delete the "popeyebl" folder, you
can still start MAME with "mame popeyebl" to play the bootleg set. You might need
a placeholder for your front-end so it lists the bootleg set. Contact your
front-end author for more information.

Unlike the first method, this method isn't guaranteed to work with other emulators.

popeye (main)       popeyebl (clone)
------              --------
c-7a                (no ROMs at all)
c-7b
c-7c
c-7e

v-5n
v-1e
v-1f
v-1j
v-1k

po1
po2
po3
po4
po_d1-e1.bin

Common Misconceptions-

* This new scheme is a waste of time.
It is a pain in the butt, yes, but it's a necessary evil. Having a
standard procedure for naming ROMs is a good thing. Remember, people who
actually own the PCBs use the ROMs too so having consistent names helps
them find what they need to repair a broken board.

* If I merge ROMs, they won't work with other emulators.
That's true. The simple solution is not to merge or delete the ROMs.
Remember, deleting redundant ROMs or placing them into one zip file or folder is
optional. If you anticipate using them with other emulators, then don't
merge or delete anything. You will still have to go through the ROM
renaming process.

* No good will come of this
This is untrue. While Nicola was going through all the ROM sets and
comparing, he found several instances where a set had a bad ROM that has
slipped through the cracks. This whole process has uncovered several bad
ROMs that would have gone unnoticed otherwise.

* It's not worth the space savings.
Maybe it's not worth it for you, but some people appreciate it. There are
two pros to this aspect - you save space, and the downloads for cloned or
derivative sets are much shorter, particularly for large ROM sets like
the CPS1 games. There are no cons to merging - if you don't want to, you
don't have to do it. You can keep your old sets and take up all the space
you want :)

* It goes against MAME's goals as a documentation project.
This isn't true. Since MAME strives to document as many aspects of the
hardware as possible, keeping a list of clones is a natural extension of
that process. MAME isn't forcing anyone to delete ROM files or break up
their ROM sets if they don't want to. Remember, those steps are optional.

* What are color PROMs and how do they fit into all of this?
They are very small (usually 256 bytes or less) ROMs that contain the
color data for a lot of games. In the past, MAME stored the data
hardcoded into it's source. Now, MAME will start looking for these files
with the rest of the ROMs. This is a Good Thing because it means that
other emulators can use the files, as can people who actually own the
arcade boards. Expect to see MAME complain about missing color PROMs in
the future as more drivers are converted to load them from disk.

* This is all a big conspiracy to eliminate the competition
You've got us there. Despite the several compelling benefits (space
savings, download time savings, documentation of clones, finding of bad
ROMs), this is the true reason the changes were made. Yeah, That's it...
(For the sarcasm-impaired, No this is not a big conspiracy to eliminate
the competition...;-) )

That's it!
Feel free to copy this text and post it elsewhere if you should so desire.



merged:
-------
1942/1942 alternate
exedexes/savgbees
commando/commandj
gng/gngcross/gngjap
gunsmoke/gunsmrom/gunsmokj
trojan/trojanj
srumbler/srumblr2
sidearms/sidearjp
1943/1943jap
blktiger/blkdrgon
ghouls/ghoulsj
strider/striderj
willow/willowj
ffight/ffightj <- ffightj wrong, uses LOAD_EVEN/LOAD_ODD for gfx
1941/1941j
mtwins/chikij
msword/mswordj
nemo/nemoj
qbert/qbertjp (RENAME: all qbertjp/qb-XXX.bin -> qbj-XXX.bin)
starforc/megaforc
tutankhm/tutankst
espial/espiale
matmania/excthour (COPY: excthour/E9->matmania/K9-00 which had one bad bit)
marble/marble2/marblea
klax/klaxalt
gauntlet/gauntir1/gauntir2/gaunt2p
crbaloon/crbalon2
panic/panica (RENAME: panica/spcpanic.1->panica.1 spcpanic.7->panica.7)
mrdo/mrdot/mrlo/mrdu (RENAME: all mrlo/XX-NN.bin -> mrloNN.bin)
docastle/docastl2 (EXCHANGE docastle.zip<->docastl2.zip. docastl2 was more complete)
pleiads/pleitek (RENAME: pleiads.zip->pleiadce.zip pleitek.zip->pleiads.zip)
phoenix/phoenixt/phoenix3 (RENAME: all phoenix3/phoenix.NN -> phoenix3.NN)
cclimber/ccjap
ckong and variations (this one is complex - just fetch the new set)
swimmer/swimmera (COPY: swimmera/sw13 and sw14 to swimmer since they were bad there and
                 RENAME all swimmera/swNN -> swaNN)
shaolins/kicker (kicker is the main set, some ROMs in shaolins were bad)
hbarrel/hbarrelj (RENAME hbarrel2.zip -> hbarrelj.zip)
baddudes/drgninja
hippodrm/ffantasy
astrob/astrob1
tempest/tempest1/tempest2 (fetch the new set)
mappy/mappyjp
yard/vsyard (RENAME: vsyard/yf-X-XX -> vyf-X-XX careful about names which look the
            same but are not)
mpatrol/mpatrolw/mranger (RENAME: mpatrolw/mp-X.XX -> mpw-X.XX)
kungfum/kungfub
travrusa/motorace (RENAME:
            travrusa/zippyrac.002 -> mr8.3c
            travrusa/zippyrac.003 -> mr9.3a
            travrusa/zippyrac.004 -> mr10.1a)
firetrap/firetpbl (NOTE: firetpbl/ft09.bin and ft10.bin were bad, however they are
            no longer used)
circusc/circusc2
congo/tiptop
gladiatr/ogonsiro
karnov/karnovj
chelnov/chelnovj
gyruss/gyrussce
gberet/rushatck
atetris/atetrisa/atetrisb
spacfury/spacfura (RENAME spacfury.zip -> spacfura.zip, spacufrc.zip -> spacfury.zip)
rygar/rygarj (RENAME all rygarj/cpu_XX.bin -> cpuj_XX.bin)
pooyan/pootan
gaiden/shadoww
asteroid/asteroi1 (fetch the new set)
llander/llander1 (fetch the new set)
quantum/quantum1 (fetch the new set)
mhavoc/mhavoc2/mhavocrv (fetch the new set)
junglek/jhunt
elevator/elevatob (NOTE: a couple of elevatob ROMs were bad, however they are no
                  longer used)
venture/venture2 (NOTE: venture2/vent_7a.vid was bad, however it is no longer used)
tmnt/tmntj/tmht2p/tmnt2pj (use the tmnt_complete.zip set)
xevious/xeviousa/sxevious (fetch the new set)
superqix/sqixbl
turtles/turpin
bagman/bagmans
robotron/robotryo
joust/joustr/joustwr
sinistar/oldsin
bubbles/bubblesr (RENAME: bubblesr/bubbles.XXX -> bubblesr.XXX)
colony7/colony7a
superpac/superpcn
mspacman/mspacatk
trackfld/hyprolym (RENAME: hyprolym/XXX_YYY-bin -> hyprolym.XXX)
rocnrope/ropeman
slapfigh/slapbtjp/slapbtuk (fetch the new set)
arkanoid/arknoidu/arkbl2/arkatayt
jumpbug/jbugsega
japirem/uniwars
bublbobl/boblbobl/sboblbob
popeye/popeyebl
bosco/bosconm
btime/btimea
bnj/brubber/caractn
timeplt/spaceplt (RENAME: spaceplt/tmX -> spX)
rainbow/rainbowe
chplft/chplftb/chplftbl (RENAME: chplftbl/7124.90 -> 7124bl.90)
centiped/centipd2 (RENAME centipd1.zip -> centipd2.zip)
digdug/digdugnm
ddragon/ddragonb
rastan/rastsaga (RENAME rastsaga/icXX_XX.bin -> rsXX_XX.bin)
pacland/paclandn/paclanda (REPLACE: paclandn/pl1-8/9/10/11 with
            paclanda/pl1_08/09/10/11.bin, note that pl1-10 was bad.
            RENAME: paclandn/pl1-XX -> pln1-XX)
stratgyx/stratgyb
bzone/bzone2 (RENAME: bzone2/036414.01 -> 036414a.01)
dkong/dkongjp
dkongjr/dkjrjp/dkngjrjp/dkjrbl (RENAME: dkjrjp/dkj.5X -> dkjp.5X)
mooncrst/mooncrsg/mooncrsb/fantazia/eagle (RENAME: mooncrsb/eprXXX -> beprXXX)
nemesis/nemesuk (RENAME: nemesuk/XXXX.bin -> XXXX.uk)
frogger/frogsega/frogger2
galaga/galagamw/galagads/gallag/galagab2 (fetch the new set)
galaxian/galmidw/galnamco/superg/galapx/galap1/galap4/galturbo (RENAME:
   galmidw/galaxian.X -> galmidw.X
   galnamco/galaxian.X -> galnamco.X
   superg/galaxian.X -> superg.X
   galturbo/galaxian.X -> galturbo.X)
moonal2/moonal2b
pengo/pengo2/pengo2u/penta
xsleena/solarwar (there were several bad ROMs; fetch the new set)
capbowl/clbowl (RENAME: clbowl/XX -> XX.cl
lwings/lwingsjp
missile/suprmatk (RENAME: suprmatk/XXXXXXXX.02 -> XXXXXXXX.sma)

added PROMs:
------------
vulgus
sonson
1942
exedexes
commando
gunsmoke
1943
1943kai
mrdo (they are in the mrdo set)
docastle (they are in the former docastl2 set, renamed to docastle)
douni (they are in the douni set - different from docastle!!)
nova2001 (they are in the nova20001 set)
pleiads (they are in the former pleitek set, renamed to pleiads)
phoenix (use the plaiads ones)
thepit (they are in the thepit set)
kungfum (they are in the kungfum set)
gyruss (they are in the gyruss set)
bagman/sbagman (they are in the new bagman set)
arkanoid (they are in the arkanoid set)
pacland (they are in the pacland set)
dkongjr (they are in the dkjrbl set)
frogger (they are in the frogger2 set)
froggers (they are in the froggers set)
