Backstory

The Lemmings computer game needs no introduction: originally released on the Amiga, the green-haired creatures quickly climbed, bashed, and built their way onto most personal computers of the era. My first introduction to it was the MS-DOS port.

After becoming interested in the modding tools and communities for other games of the era (most notably Commander Keen), I turned my sights to Lemmings. At the time, the only tool available was VTM Software's LemEdit [archive.org link], which provided a high-quality level editor, with a patched version of Lemmings, and support for decompressing and compressing the game's levels from the .dat archives.

While the .lvl level format — which was also used uncompressed by the Windows version of the game — was at the time documented by rt, the compressed .dat format was only described as a "proprietary compression format", and some quick poking with a hex editor revealed the basic archive format (with file sizes and offsets), but that the compression algorithm was not byte-aligned, and almost certainly beyond my child self to decode.

So, as one of my earlier Rust experiments, I decided to give it another go. In the meantime, the remaining file formats had been documented by Mindless and ccexplore, including the .dat format's compression. From that, and equally inspired by Andrew Durdin's modkeen tool for commander Keen, I've developed modlem.

modlem is a simple tool for modifying the graphics of the MS-DOS port of Lemmings 1. It can decompress and compress .dat archives, as well as exporting and importing the in-game graphics to .bmp files. It does not support modifying levels (including the graphics for the "special" levels), the Oh No! More Lemmings! games (though it's only a one-line change in the code, so this will come soon), or modifying any of the myriad things which are hardcoded into the game, including some palettes, image sizes, colour-depths, etc (you'll need to patch the executables for those).

As you can see, this is a somewhat unpolished project — and that's before you look at the very amateurish Rust code! Nevertheless, having been beaten to the punch by the excellent Digger Decoder, I'm releasing it as-is for anyone who wants to try their hands at doing some modified Lemmings. Enjoy!


Getting modlem

You can download modlem here, for:

Alternatively, you can grab the source code, and compile it yourself. You'll need a Rust compiler, and can then build with either cargo build or make.

Then, simply drop modlem into the game directory (or somewhere else in your PATH), and follow the instructions below.


Using modlem

Lemmings' graphics can be (roughly) split into two types, level graphics sets (the "themes" for different levels), and the shared "main" graphics, such as the menus, interface, fonts, and the lemmings themselves. modlem can edit both of these (though note that it cannot edit the "special" levels).

Editing "main" graphics

To edit the main graphics, such as lemming animations and menus, you can use the extract-main command:

modlem extract-main
If you're modifying the Christmas/Holiday Lemmings games, you'll need to also pass the --christmas option.

This will create a large number of .bmp files in the current directory, containing all of the graphics. You can edit these in any graphics programme, but make sure not to change the size or palette of the images — these are hardcoded in the game, and cannot be changed by modlem.

The files created are:

lemming_*.bmp
The individual lemming animations. One file per skill and direction. (e.g., lemming_brolly_r.bmp for a lemming carrying an umbrella, facing right.
mask_*.bmp
Terrain masks used by skills. These are the shapes removed from the level when certain skills are used. And the bomber countdown timer, for some reason.
interface_hi_*.bmp
The interface for the High-Performance PCs mode, which uses a different palette. Not used in the Christmas Lemmings versions, as far as I can tell.
menu_*.bmp
The graphics for the main menu.
menuanim_*.bmp
Animations on the main menu (and the difficulty selection).
pcspkr.snd
The raw PC-Speaker sound effects. If you work out how to edit these, let me know!
interface_lo_*.bmp
The normal interface (for non-"High-Performance" PCs).

After modifying these files, you can recreate main.dat with the create-main command:

modlem create-main

Editing graphics sets

In additiona to editing the shared main graphics, modlem can also modify the in-level graphics sets (or themes), which consist of a number of pieces of terrain and animated objects, from which levels are made.

modlem can extract these graphics sets using the extract-set command: this accepts the set number, which are (broadly):

  1. Ground (e.g., "Let's Dig")
  2. Hell (e.g., "We All Fall Down")
  3. Marble and Brick (e.g. "Now use miners and climbers"), and the background of this page.
  4. Ancient (e.g., "Only floaters can survive this"), and
  5. Crystal (e.g., "You need bashers this time")

To extract a graphics set, use

modlem extract-set n

…where n is the set number, as above.

This will produce a script file containing all of the information about the graphics set, called themen.txt, as well as a number of bitmap files, called setn_terrainx.bmp and setn_objx.bmp, which contain all of the graphics. Additionally, mask versions of the bitmaps are created, which contain the transparency information.

For objects, several frames of graphics are stored in each bitmap, in filmstrip format. The number of frames, what the object does, animation details, etc, are stored in the theme script file.

Once the graphics and script have been modified, you can re-create the vgagrn.dat and groundno.dat files with the create-set command, which takes the name of the theme script file as an argument:

modlem create-set themen.txt

Note, though, that modlem does not support extracting or modifying the graphics for the special levels (i.e., the vgaspecn.dat files).

Modifying other files:

Many other .dat files can be compressed and/or decompressed with the extract-dat and create-dat commands. However, modlem can't actually understand any of the other formats, so you'll just get binary files that you'll need to modify with another tool (such as a level editor).

To extract a .dat file, use:

modlem extract-dat filename

This will extract all of the sections of filename.dat as individual files, named filename.000, filename.001, etc…

These can be reconstituted into a .dat file with:

modlem create-dat filename