Hello, you. /waves
So, I've been busy for the last week or so. I've been trying to understand the technical stuff that makes 3D Lemmings work. I've made a good amount of progress, but I'm going to have to cut it short for now as I must focus on my university studies for the next few weeks.
I'll dump what I've learned so far in this thread. I've even made a level that you can try out, which
I've posted in the level design forum. The level was planned using Minecraft because imagining a puzzle in 3D was a lot harder than I expected. Also, the level was made solely through hex editing, so I needed something to reference as I was going along.
Anyway, here's what I know so far. These aren't particularly tidy notes since these were made on the go, but I'm hoping that if you squint your eyes, you can make some sense of them.
[Edit 2019] This post has been updated with notes compiled by me and namida. More detailed notes have been put up in the L3DEdit repository, and may be more up to date than what's listed here.===Technical overload begins here===LEVEL.###This file is in the LEVELS folder, and is where almost all of the level data is stored. Normally, this file is compressed using the
RNC compression algorithm version 1. It's a common enough algorithm, so any tool that can decompress RNC1 files will work here. Also, the file will load whether it's compressed or not. The uncompressed file size is around 65Kb, which is not a lot these days.
Level InformationIntegers are stored in little endian.
0000 Byte Timer (Seconds)
0001 Byte Timer (Minutes)
000A-001B Struct (2 members) Skill ID? (Byte), Number of this skill (Byte)
0022-???? Struct (3 members) LandVertexX (Byte), LandVertexY (Byte), ??? (Byte)
00E2 Int16 Release Rate
00E4 Int16 No. of Lemmings
00E6-00E7 Int16 To Be Saved
00E8 Byte Texture Set
00E9 Byte Land Graphic
00F0-010F String Level name (String requires null termination)
0110 Byte Non-interactive object set
0111 Byte Sign Set
0112 Byte Sea Graphic
0113 Byte Animated non-interactive object set
0114 Byte Interactive object type (e.g. traps)
0115 Byte Sky Graphic
0117 Byte Walls Set
011D-013C String Comment (Not used in game, often used to store level author)
0143 Byte Theme index (see “Music & Wallpaper” section)
0151 Byte Music index
0153-0156 Array (4 elements) Level border definition (kills lemmings that leave the border). Order: -X, -Z, +X, +Z
0159 Byte Preview Camera Pivot Y
015A Byte Preview Camera Pivot Z
015B Byte Preview Camera Pivot X
015C Byte Kill ceiling (level border definition for +Y)
015D-017C Struct (5 members) Initial camera positions (see "Camera Positions" section)
0200-7DFF Level Block Data
8200-FDFF Objects Data
Refer to the attached image to see how some of these relate to the objects seen in the game.
You'll notice there are gaps in there. There are plenty of things I couldn't figure out. For example, I don't know why the water moves the way it does. In level 2, the water is animated. I couldn't work out how this could be done.
Camera Positions (015D-017C)There are four cameras. Data for each camera is stored in 8 bytes of data as follows.
Integers are stored in little endian
+00 Signed Int16 Camera Y Position
+02 Signed Int16 Camera Z Position
+04 Signed Int16 Camera X Position
+06 Byte Camera rotation. 4 values.
+07 Byte Unknown
Level Block Data (0200-7DFF)Each level block data element is stored as a single 16-bit integer in little endian.
[MSB] XXXXXXYYYYZZWWWW [LSB]
X 6 bits Block graphic ID (refer to BLK file)
Y 4 bits Block type
Z 2 bits Rotation. The block will rotate counterclockwise (90 degrees * Z)
W 4 bits Block segments (blocks are split into 4 vertical segments from top to bottom, and all true bits must be consecutive)
The order in which the blocks are stored are along the Z axis (blue), Y axis (green), and then the X axis (red). The level size is stored in memory as 32 blocks long, 32 blocks wide, and 16 blocks tall. However, there are glitches in the game that prevent the full field from being used.
Objects Data (8200-FDFF)The objects data also uses 2 bytes to store data, and the order in which the game objects are stored are exactly the same as the level blocks. The definition of the two bytes, however, are different. Editing the second byte has done nothing as far as I've seen, so the following information relates only to the first byte.
00 Draw nothing
01-1F Static Object (from OBJ.xxx)
20-3F Signs (from SIGNS.xxx, first 6 bits = type, last 2 bits = rotation)
40-4F Unknown
50 Animated Object (from ANIMOBJ.xxx)
51 Animated Object using four large Static Object frames (scrolling through frames 05-08)
60-67 Interactive Object (from TRAP.xxx)
70-C7 Wall (7#-C# represents the direction)
D0-E7 Half Wall (D#-E# represents the direction)
F0-F7 glitchy wall
Music & WallpaperMemory address 0143 is where the music and the wallpaper data is stored per level. The wallpaper refers to the image that you see before you start the level. If you've played the PlayStation and Saturn versions of the game, this image will also appear after you finish the level (win or lose).
01 Castle
02 Egypt
03 Space
04 Sweets
05 Golf
06 Computer
07 Army
08 Maze
09 Circus
0A Lemgo (coloured blocks)
The alternative songs for each theme can be chosen at the memory address 0151. From what I've seen, values from 00-03 are accepted. Other values can result in some strange glitches.
BLK FilesThese files are also stored in the LEVELS folder, and are linked to the level with the same file extension, e.g. LEVEL.000 is linked with BLK.000. This file represents a dictionary of blocks that can be placed in the level. There are 64 block definitions per level.
Some block indexes have special rules.
Block 0 Entrance. This requires the top two segments to be solid and the bottom two segments to be empty. There is an effective limit of 4 entrances per level.
Block 1 Exit. The lemmings interact with the +Z face unless the block is rotated.
Block 2 Splitter block.
Blocks 3-5 Unknown
Block 6 One-way block. It does not automatically put in any one-way block graphics, and they must be implemented using the Face Data below.
Blocks 7-8 Unknown
In official levels, normal block data begins from index 09.
Each block consists of 22 bytes.
00-01 Unknown
02 Block flags
03 Unknown
04-06 Data for +Z face
07-09 Data for -Z face
0A-0C Data for +X face
0D-0F Data for -X face
10-12 Data for +Y face
13-15 Data for -Y face
Block Flags (offset +02)01 Double-sided rendering. The inside of the block will be rendered with the same textures as the outside of it (example: bridge in level 10).
02 Steel. The block is indestructible.
04 Liquid. Lemmings will drown if standing on this block.
08 Unknown
10 Non-solid for lemmings. The camera interacts with this block, but the lemmings pass through it.
20 Unknown
40 Slippery. Lemmings will slide on the top of this block.
80 Non-solid for camera. The lemmings interact with this block, but the camera passes through it.
Face Data (Offset +04-15)These represent the graphics that each face of the block will use.
+00 Texture Index
+01 Texture Modifier Flags
+02 Shading
The graphics used by each face is stored in the level's texture file. The offset for each graphic is set to the value of the Texture Index multiplied by 4096 (0x1000). However, if any of the flags below are set, this can change the behavior in a currently unknown way.
Texture Modifier Flags01-10 Unknown
20 Face will animate between 4 consecutive face textures.
40 Face will animate using special rules (see below).
80 Face will treat colour 0 as transparent.
The special rules of 40 depend on the value given for the Texture Index. Any indexes not listed below are unknown.
00 Four-frame animation from frame 12-15
02 Eight-frame animation from frame 00-07
06 Seems identical to 02
ShadingThis byte reduces the brightness of the face texture.
Palette DataThe in-game palette is stored in a file called GFX/LM3D.PAL. The file consists of 256 RGB triplets. The colour values range between 00-3F.
Other files in the GFX folder (*.000, *.001, etc.)Other files in the folder are stored as a single channel image. By linking these files to the palette, you'll get the graphics as they're seen in-game. The width of each type of graphics file are as follows:
AnimObject 64
Bgrd 320 (it’s the “3D Lemmings” background that you can see in the main menu)
Land 128
Obj 64
Sea 64 (not confirmed)
Signs 64
Sky 1024
Texture 64
Traps 64
Walls 64
The contents of each file is described below.
AnimObject000 Egyptian Torches
001 Flag bearing the Clockwork Games logo
002 Flashing lightposts
003 Rings of fire
004 Lemming flag
005 Another lemming flag (different from 004)
006 Chequered flag
007 Candy cane torches
008 Neon exit sign
009 Exit flag
011 Pillar torches
013 Juggling lemmings
022 Rocket flame
023 Duplicate of 001
090 "Block Here"
091 "Turn Here"
092 "Bomb Here"
093 "Build Here"
094 Duplicate of 093
095 "Bash Here"
096 "Mine Here"
097 "Dig Here"
098 "Climb Here"
099 "Float Here"
Land000 Dirt / sand
001 Grass
002 Black diagonal tiles
003 Red and yellow triangle tiles
004 Lemgo Red
007 Chocolate
008 Circuit board
009 Grass 2
015 Grass 3
017 Chocolate 2
018 Dirt / sand 2
028 Blue
038 Solid blue
Obj000 Pyramid
001 Castle
002 Maze
003 Circus
004 Lemgo
005 Maze
006 Army
007 Candy
008 Maze 2
009 Golf
010 Pyramid 2
015 Maze 3
016 Army 2 (Snowy)
018 Computer
038 Pacman Ghosts
095 Warning Signs
OverlayThis file stores the cracks that you see when a lemming is bashing, mining or digging through terrain. It also masks the terrain debris that appear during these processes so that they don't appear so blocky. These are both stored as 1 bit-per-pixel images.
0x0000 - 0x1FFFF Terrain cracks
0x2000 - 0x2FFFF Debris masks
Sea000 Quicksand
001 Dark blue water
002 Normal blue water
003 Green slime
004 Lemgo water - blue
005 Lemgo water - red
006 Icy water
007 Liquid chocolate
Signs000 Pyramid Splitter, Credit Signs ("One Giant Step", "Oh No", "Lemmings 3D") - front only
001 Castle
002 Credit Signs ("Programming By" x2, "Graphics By", "Raytracing By") - front and back
003 Credit Signs ("Produced By", "Eclipse", "Sony", "Playstation") - front and back
004 "Paradise This Way" replaces "Keep Off Grass", Credit Signs ("Hi Ho", Waterski, "Oh No" (dup), Juggle) - front and back
005 Maze
006 Army
007 Candy
008 Duplicate of 04
009 Castle 2, also has a LemLab-looking splitter entrance?
011 Castle 3, mostly identical to 09 but "Keep Off The Grass" isn't replaced and has Castle splitter instead of LemLab-y
095 Maze 2
Sky000 Pyramids
001 Castles
002 Space
003 Trees
004 Lemgo constructs
005 Stone wall with arches
006 Ruins? (usually used with Army theme in official levels)
007 Plain sky
008 Space Red
009 Golf course
012 Space, bigger stars
016 Snowy trees
017 Chocolate mountains
018 Space (blue)
027 Pinkish sky
Texture000 Pyramid
001 Castle (???)
002 Spaceship
003 Circus
004 Lemgo
005 Maze
006 Army
007 Confectionary
008 Computer
009 Golf
010 Pyramid 2
011 Castle 2
012 Spaceship 2 (/ Lemlab?)
013 Circus 2
015 Maze 2
016 Army 2 (Snowy)
018 Computer 2
019 Combination of Pyramid and Golf?
021 Castle 3 (???)
022 Space 3 (Dot to Dot)
028 Computer 3 (Breakout?)
036 Army 3 (Corkscrew Digger)
038 Computer 4 (Lemmtris?)
046 Golf 2 (Land Ahoy)
048 Computer 5 (Lemmtris?)
095 Maze 3
Traps000 Flame blower
001 Squasher
002 Bear trap
003 Trampoline
004 Spring
005 Teleporter
006 Grabby slime trap
007 Laser trap
008 Rope slide
Walls000 Pyramid
001 Castle
002 Space
005 Maze
007 Pyramid 2 (seems identical to 1)
008 Computer
011 Castle 2 (???)
018 Digits
BombNumb.gfxThis file contains the graphics for the bomber counter, the camera number label, the ‘?’ when a lemming runs out of builder bricks, and the highlight lemming cursor. It is arranged in this format:
12
34
5?
↓
Cogs.gfxThe cogs appear when the game is loading. I think the image width is 88 pixels, but I’m not certain. Also, I’m not sure where the palette data for this comes from.
Lemmings.fntThis 32 pixel-wide file is where the animated lemmings used in the password screen comes from.
Minilemm.gfxThis file is also 32 pixels wide, but this file represents the lemming icons at the bottom of the game screen.