The 1942 Map Project

How It Was Made

I was playing around with the MAME source from http://www.mame.net in an attempt to obtain a better understanding of how MAME works.

I've always had a penchant for creating game maps. A couple of years ago a friend and I created the Star Force map the hard way - by delving into the heart of the game roms and working out how the Z80 was generating the tilemaps and colour palette. See The Star Force Map for the results.

I wondered if it would be easier to generate such a map by using a modified version of MAME. In the case of fixed scrolling games like shoot-em-up's where the video scenes are not determined by gameplay - you can't go backwards or stop etc., it seemed like it would be quite straightforward. All I needed to do was find out how many frames make up 1 screen, make MAME take an automatic snapshot each screen and turn off undesirable foregrounds and sprites - like the game score and P1's character (a plane in this case). Then afterwards I only needed to join the resulting snapshots together using a suitable program. So based on the MAME 0.80 source tree I

  1. hacked in a few new keyboard functions in inptport.[ch] (for enabling / disabling snapshots, fg, bg and sprites),
  2. introduced a few global toggles in usrintrf.[ch] for the snapshots, fg, bg and sprites,
  3. wired in the automatic taking of snapshots every 512 frames in mame.c in the updatescreen function,
  4. placed some conditionals in the vidhrdw section for 1942.c and turned off the sprites for the P1's aeroplane.

Then the procedure for generating the map was thus:

  1. Run my altered MAME: mame -noafs -fs 0 -nosound -c 1942 - i.e. no autoframeskip, frameskip=0, sound off with cheats enabled. You can leave all other options default. Sound off is just for performance, after all we're ripping video not sound :-)
  2. Enable invincibility cheat for 1942. Even though the plane is invisible it still can take damage!
  3. Toggle off the foreground tiles by typing U.
  4. Insert virtual coin, and start the game and start autosaving screenshots by typing T.
  5. Hit F10 so you don't have to wait forever.
  6. You will need to shoot down the 4 big planes in order to keep the game progressing.
  7. Take special start/end screenshots in a separate game pass.
  8. Use your favourite program to join all the images together. I did the following:
    • I used ImageMagick's batch convert utility to convert the png's to true colour (24 bit) bitmaps.
    • I then ran a joining program that I wrote that takes the first bitmap header and modifies appropriately and then appends all data from the bitmaps one after the other.
    • Finally used ImageMagick to convert the resulting bmp back to fully compressed png format with colour depth reduced back to 256.
  9. You can disable all sprites by pressing I if you don't like them cluttering up the map. Sometimes sprites don't show up correctly because
    • a screenshot is taken when sprites are half on/off the screen, resulting in cutoff sprites or
    • a sprite appears more than once because it 'lives' for time longer than the time between successive screenshots.
  10. Pressing Y is supposed to turn off the background tiles but it doesn't work properly.
  11. By pressing tab you can redefine the 4 new key functions I added to MAME. Under input (general) look for 'Save Toggle', 'BG Toggle', 'FG Toggle' and 'Sprite Toggle'.

Note that the above method can be used (with modifications) for other fixed scrolling games. If you find a way to get better results using other methods or source changes, please let me know.

The Source Code

What I did was quick and dirty, so don't expect clean code. All my variables start with tjm so should be easy to find. In line with the MAME license I've included my modified source here. To use it you need to download the Official MAME 0.80 source and then apply my source changes over the top before compiling.

I've also included my bitmap join program (joinbitmaps.cpp) in the above source pack. The program is extremely limited in that it can only join true colour bitmaps (i.e. bmp's with no colour map). Furthermore it can only join vertically from the first image up to the last. You may be better off finding other tools.

The Map

Here it is! The map is large. I don't have the webspace to offer both a unzipped and zipped version. You can view the map here and then download it by right clicking and saving the picture (or steal it from your Internet cache). Note it takes some time to load (1.63 MB in size) and you'll get to exercise the vertical scroll bar quite a bit since the map has dimensions 224 x 118016 x 256.

Be warned that many applications will have trouble viewing this image. Your browser is probably one of the few apps that will present it properly. This is because of its large size and a multitude of poor programming by developers not choosing their datatypes properly in imaging applications.