Slot 2 Mapping Flat Code in $00000 - $0bfff [1]

Palettes

Lemmings uses a single palette for all gameplay. The only places where different palettes are used are the logo screens, the title screen and the ending scene. All of the palettes contain 16 colours which are written to both halves of CRAM.

Main Palette

The 16 bytes of data defining the main palette begin at offset $1be5e. The colours in the main palette are:

Index$00$01$02$03$04$05$06$07$08$09$0a$0b$0c$0d$0e$0f
Value$00$3f$08$24$15$2a$38$20$03$0b$07$04$01$07$02$00

Other Palettes

These are the other palettes used by Lemmings:

Sega Logo Screen

Index$00$01$02$03$04$05$06$07$08$09$0a$0b$0c$0d$0e$0f
Value$00$2b$08$34$15$2a$38$20$03$0b$06$04$01$07$02$00

Lemmings Logo Screen

Index$00$01$02$03$04$05$06$07$08$09$0a$0b$0c$0d$0e$0f
Value$00$3e$3a$35$07$02$01$00$1c$08$04$25$30$0e$10$2b

Title Screen

Index$00$01$02$03$04$05$06$07$08$09$0a$0b$0c$0d$0e$0f
Value$00$3e$2a$15$16$02$01$00$1c$18$04$24$20$0b$10$2b

Ending Scene

Index$00$01$02$03$04$05$06$07$08$09$0a$0b$0c$0d$0e$0f
Value$00$33$3e$2a$15$16$02$00$1c$18$04$34$20$0e$10$27

The data for these palettes are at offsets $1be7e, $1be9e, $1be6e and $1be8e respectively.

Level Descriptors

At $3f7a9 - $3ffa0 there is a 17-byte descriptor for each of the 120 levels (in order). Each descriptor contains the following information:

OffsetLengthContents
01 byteNumber of lemmings
11 byte% to be saved
21 byteRelease rate
31 byteTime (Minutes)
41 byteNumber of climbers
51 byteNumber of floaters
61 byteNumber of bombers
71 byteNumber of blockers
81 byteNumber of builders
91 byteNumber of bashers
101 byteNumber of miners
111 byteNumber of diggers
121 byte% saved per lemming [2]
132 bytesAddress of map descriptor
152 bytesSlot 2 address of level name (Bank 15)

Map Descriptors

Within $0713d - $072c2 there is a 5-byte descriptor for each of the 77 maps [3]. Each descriptor contains the following information:

OffsetLengthContents
01 byteTileset index (0, 1, 2, 3, 4, 6 or 7)
11 byteBank number containing map layout data
22 bytesSlot 2 address of map layout data
41 byteMaximum safe fall distance

Map Layouts

Each of the 77 maps is 112 x 19 tiles in size. Each tile is described by an 8-bit tile index.

In the ROM the indices are compressed using a simple RLE scheme: runs of consecutive zero bytes are stored as a single zero byte followed by a 1-byte length [4]. Any runs of more than 255 zero bytes are split into multiple runs.

During play the indices are decompressed to RAM at $ce00 - $d64f.

Level patches

The game patches many of the level layouts after the data has been decompressed. Some of these are to allow later level repeats to be slightly modified; others are for less obvious reasons. These patches are all implemented in the form of explicit code that writes to the RAM buffer, rather than having data-driven code. This code is between offsets $2246 and 24a1 in the ROM.

Fun 9 "As Long As You Try Your Best"/Tricky 22 "Turn Around Young Lemmings"

The spinner traps in the data are three tiles tall; the lower two (which lemmings can be killed by) are redrawn to be two tiles tall.

Tricky 4 "Here's One I Prepared Earlier"/Taxing 7 "Every Lemming For Himself!!!"

A small obstacle is added, which makes it a little bit more like the original Amiga level.

Tricky 7 "Been There, Seen It, Done It"/Taxing 11 "The Ascending Pillar Scenario"

The lowest pillar is moved one tile to the right. This is so that the lemmings can fall off the left side. All of the pillars are otherwise close enough that the lemmings cannot fall through the gap, which makes the level easier than the original design.

Tricky 21 "Sixes Not!"

This level is known as "All the 6's" in the original game, and is often "censored" due to allusions to The Number of the Beast. The original level data has relatively clear "6" digits, although not in the same style as the original; the game patches over the upper part of the level to make them less obviously sixes - and changes the level title to say they are not!

Tricky 28 "Lost Something?"

The level exit is hidden in this level; the data has black tiles in its location, so the code patches over some dirt. It's not yet understood how the game then draws in the hidden exit.

Taxing 12 "Livin' On The Edge"

The starting brick pillar is moved right one tile.

Taxing 13 "Upside Down World"

A small modification is made to the land as shown below. This seems to make the level more like the Amiga original, without it it is more difficult to win.

Taxing 24 "Take a Running Jump"

The gap in the floor above the exit is made smaller. This makes the level a little easier.

Taxing 29 "How Do I Dig Up The Way?"

This level is a repeat of Tricky 3 "A Ladder Would Be Handy" but the right edge of the pit has been made smooth. It's not clear how this makes the level any harder; in the original game it is unchanged.

Mayhem 13 "Sega Three"

This is a repeat of Tricky 25 "Sega Three", with the pathway blocked to make it more difficult.

Mayhem 23 "Going Up...."

The exit and the floor below it is extended two tiles to the left.

Mayhem 28 "Mind The Step..."

One of the steps is raised; tiles are removed on the sloped ceiling and on the upper right of the pillars, apparently to make the level easier.

ROM Map

This table summarises the contents of the Lemmings ROM (Size: 256KB; CRC32: f369b2d8):

Address RangeContents
$00000 - $04b7cUnknown
$04b7d - $05b9c4bpp Tiles: Font [5]
$04b7c - $062dc4bpp Tiles: HUD (skills, numbers)
$062dd - $0635c4bpp Tiles: Cursor
$0635d - $064dc4bpp Tiles: HUD selection borders?
$064dd - $0713c4bpp Tiles: Pointed lemming skill close-up
$0b564 - $0beceMap Layouts
$0bed1 - $0bfe81bpp Tiles: Title screen text scroller font
  
$0c000 - $0ffff4bpp Tiles: Lemmings
  
$10000 - $10005"PAGE04"
$10006 - $13f1aMap Layouts [6]
$131fb - $13fffUnused
  
$14000 - $14005"PAGE05"
$14006 - $179b0Map Layouts [6]
$179b1 - $17cb0Tile Indices: Sega Logo Screen
$17cb1 - $17df04bpp Tiles: Release Rate Box
$17df1 - $17fffUnused
  
$18000 - $18005"PAGE06"
$18006 - $19a054bpp Tiles: Dirt Tileset (208 Tiles)
$19a06 - $1b9854bpp Tiles: Fire Tileset (252 Tiles)
$1b986 - $1bb5dCompressed 4bpp Tiles: Unknown Data
$1bb5e - $1be5dTile Indices: Green Textured Background
$1be5e - $1be6dPalette: Main
$1be6e - $1be7dPalette: Title Screen
$1be7e - $1be8dPalette: Sega Logo Screen
$1be8e - $1be9dPalette: Ending Scene
$1be9e - $1beadPalette: Lemmings Logo Screen
$1beae - $1bfffUnused
  
$1c000 - $1c005"PAGE07"
$1c006 - $1f136Map Layouts [6]
$1f137 - $1f8b64bpp Tiles: Hatch Opening
$1f8b7 - $1ffd3Compressed 4bpp Tiles: Lemmings Logo Screen Lemming
$1ffd4 - $1ffffUnused
  
$20000 - $20005"PAGE08"
$20006 - $21c854bpp Tiles: Crystal Tileset (228 Tiles)
$21c86 - $23bc54bpp Tiles: Pillar Tileset 1 (250 Tiles)
$23bc6 - $23f96Unknown Data
$23f97 - $23fffUnused
  
$24000 - $24005"PAGE09"
$24006 - $25c054bpp Tiles: Pillar Tileset 2 (224 Tiles)
$25c06 - $278e54bpp Tiles: Marble Tileset (231 Tiles)
$278e6 - $27d6cMap Layout [6]
$27d6d - $27f5dUnknown Data
$27f5e - $27fffUnused
  
$28000 - $28005"PAGE10"
$28006 - $2b9cbMap Layouts [6]
$2b9cc - $2be4b4bpp Tiles: "TIMENOU%0123456789"
$2be4c - $2bfffUnused
  
$2c000 - $2c005"PAGE11"
$2c006 - $2d7e54bpp Tiles: Sega Tileset (191 Tiles)
$2d7e6 - $2defbMap Layouts [6]
$2defc - $2f6b0Compressed 4bpp Tiles: Lemmings Logo Screen [7]
$2f6b1 - $2f7304bpp Tiles: Lemmings Logo Screen I Dot
$2f731 - $2fd30Name Table Entries: Lemmings Logo Screen
$2fd31 - $2ffffUnused
  
$30000 - $30005"PAGE12"
$30006 - $322daMap Layouts [6]
$322db - $3275a4bpp Tiles: Sega Logo Screen Wheel
$3275b - $3365a4bpp Tiles: Sega Logo Screen Lemming
$3365b - $33fbaUnknown Data
$33fbb - $33fffUnused
  
$34000 - $34005"PAGE13"
$34006 - $343c5Level Codes
$343c6 - $35ee54bpp Tiles: traps, water, fire (animations)
$35ee6 - $37851Unknown Data
$37852 - $37efbCompressed 4bpp Tiles: Sega Logo Screen
$37efc - $37fffUnused
  
$38000 - $38005"PAGE14"
$38006 - $38605Name Table Entries: Title Screen
$38606 - $39fb8Compressed 4bpp Tiles: Title Screen
$39fb9 - $3a545Unknown Data
$3a546 - $3aa70Compressed 4bpp Tiles: "Fun", "Tricky", "Taxing", "Mayhem"
$3aa71 - $3ae5dCompressed 4bpp Tiles: "1 Player", "2 Player"
$3ae5e - $3bfffCompressed 4bpp Tiles: Unknown Data
  
$3c000 - $3d901Audio Sample: "Let's Go!"
$3d902 - $3ee23Audio Sample: "Oh No!"
$3ee24 - $3f7a8Level Names
$3f7a9 - $3ffa0Level Descriptors
$3ffa1 - $3ffffUnused

Level Editor

See Lemmings Mappy Convertor

Compression

Much of the tile art is uncompressed in order for the game engine to work. The remainder is compressed using RLE compression.

The compressed data starts with an 8-bit count for the number of tiles, divided by 8. The following data then defines data for that many blocks of 256 bytes, each corresponding to the deinterleaved data for 8 sprite tiles. This data is deinterleaved such that the first 8 bytes are the 8x8 pixels for the least significant bitplane of the tile data, followed by the next three bitplanes. These are decompressed to a buffer at $c500, and then interleaved into the format used by the VDP into another buffer at $c600, before being copied to VRAM.

The data itself consists of flag, length and data runs:

%1nnnnnnn $dd: emit n bytes of RLE value $dd. n = 0 means 256 bytes.
%0nnnnnnn $dd $dd ...: emit n bytes of raw data. n = 0 means 256 bytes.

  1. ^ All address ranges on this page are inclusive.
  2. ^ For each lemming saved, this value is added to the percentage saved. It should therefore be equal to 100 divided by the number of lemmings. Since it must be an integer, the number of lemmings must be 1, 2, 4, 5, 10 or 20.
  3. ^ $0716f - $07173 is unused.
  4. ^ In particular, a single zero byte is stored as $00 $01.
  5. ^ The unusually comprehensive character set is A-Z,0-9,!"#$%&'()*+,-./:;<=>?@[]^
  6. ^ a b c d e f g There are 1 or 2 garbage bytes at the end of each map layout.
  7. ^ There is 1 garbage byte at the end of the tile data.



Return to top
0.195s