SMW level data format
This article contains information about how levels are stored in Super Mario World.
Pointer tables
Address | Usage | Amount | Bytes per level | Total bytes |
---|---|---|---|---|
x2E200/$05E000 | Layer 1 data | 0x200 levels | 3 bytes | 1,536 bytes |
x2E800/$05E600 | Layer 2 data | 0x200 levels | 3* bytes | 1,536 bytes |
x2EE00/$05EC00 | Sprite data | 0x200 levels | 2** bytes | 1,024 bytes |
*) Layer 2 BG only uses the two lower bytes. The upper byte should be FF. The backgrounds are stored in bank 0C.
**) The sprite data is located in bank 07.
Primary level header
The first five bytes of the Layer 1 data is the primary level header.
First | Second | Third | Fourth | Last |
---|---|---|---|---|
BBBLLLLL | CCCOOOOO | 3MMMSSSS | TTPPPFFF | IIVVZZZZ |
Bits | Description |
---|---|
BBB | BG palette |
LLLLL | Length of level (amount of screens) |
CCC | BG color |
OOOOO | Level mode |
3 | Layer 3 Priority |
MMM | Music |
SSSS | Sprite set |
TT | Time |
PPP | Sprite palette |
FFF | FG palette |
II | Item memory |
VV | Vertical scroll |
ZZZZ | Tile set |
Secondary level header
The secondary level header consists of four bytes (These four bytes are not stored together):
- Location of Byte 1: x2F200/$05F000 + level number
- Location of Byte 2: x2F400/$05F200 + level number
- Location of Byte 3: x2F600/$05F400 + level number
- Location of Byte 4: x2F800/$05F600 + level number
Byte 1 | Byte 2 | Byte 3 | Byte 4 |
---|---|---|---|
SSSSYYYY | 33TTTXXX | MMMMFFBB | IUVEEEEE |
Bits | Description |
---|---|
SSSS | Layer 2 scroll settings |
YYYY | Level entrance Y position |
33 | Layer 3 settings |
TTT | Level entrance type |
XXX | Level entrance X position |
MMMM | Level entrance midway screen |
FF | Level entrance FG init position |
BB | Level entrance BG init position |
I | Disable no-Yoshi intro flag |
U | Unknown vertical position flag |
V | Vertical positioning flag |
EEEEE | Level entrance screen number |
Sprite header
The sprite header is the first byte of sprite data.
Byte |
---|
SBMMMMMM |
Bits | Header text |
---|---|
S | Sprite buoyancy |
B | Sprite buoyancy (no sprite-L2 interaction) |
MMMMMM | Sprite memory* |
*) Values up to 0x3F are possible, but only up to 0x12 are valid according to Lunar Magic.
Layer 1
(Note that Direct Map16 is not documented, as it's a feature added by Lunar Magic)
The Layer 1 data begins with the primary level header, followed by the actual Layer 1 data. Each block is three bytes long, with the exception of the screen exit objects.
Standard objects
First | Second | Last |
---|---|---|
NBBYYYYY | bbbbXXXX | SSSSSSSS |
Bits | Descripton |
---|---|
N | New Screen flag |
BBbbbb | Object number |
YYYYY | Y position |
XXXX | X position |
SSSSSSSS | Settings byte |
(Note: The first byte being FF marks the end of the data)
Num | Descripton | Settings Byte |
---|---|---|
00 | (Extended Objects) | Extended object number |
01 | Water (Blue) | {Height},{Width} |
02 | Invisible coin blocks | {Height},{Width} |
03 | Invisible note blocks | {Height},{Width} |
04 | Invisible POW coins | {Height},{Width} |
05 | Coins | {Height},{Width} |
06 | Walk-through dirt | {Height},{Width} |
07 | Water (Other color) | {Height},{Width} |
08 | Note blocks | {Height},{Width} |
09 | Turn blocks | {Height},{Width} |
0A | Coin ? blocks | {Height},{Width} |
0B | Throw blocks | {Height},{Width} |
0C | Black piranha plants | {Height},{Width} |
0D | Cement blocks | {Height},{Width} |
0E | Brown blocks | {Height},{Width} |
0F | Vertical pipes | {Height},{Type} |
10 | Horizontal pipes | {Type},{Width} |
11 | Bullet shooter | {Height},{Unused} |
12 | Slopes | {Height},{Type} |
13 | Ledge edges | {Height},{Type} |
14 | Ground ledge | {Height},{Width} |
15 | Midway/Goal point | {Height},{Type} |
16 | Blue coins | {Height},{Width} |
17 | Rope/Clouds | {Type},{Width} |
18 | Water surface (ani) | {Height},{Width} |
19 | Water surface (not ani) | {Height},{Width} |
1A | Lava surface (ani) | {Height},{Width} |
1B | Net top edge | {Height},{Width} |
1C | Donut bridge | {Unused},{Width} |
1D | Net bottom edge | {Height},{Width} |
1E | Net vertical edge | {Height},{Type} |
1F | Vert. Pipe/Bone/Log | {Height},{Unused} |
20 | Horiz. Pipe/Bone/Log | {Unused},{Width} |
21 | Long ground ledge | Width |
22 | Special - Used by LM | |
23 | Special - Used by LM | |
24 | Special - Used by LM | |
25 | Special - Used by LM | |
26 | Special - Used by LM | |
27 | Special - Used by LM | |
28 | Special - Used by LM | |
29 | Special - Reserved | |
2A | Special - Reserved | |
2B | Special - Reserved | |
2C | Special - Reserved | |
2D | Special - Used by LM | |
2E | Tileset Specific 1 | |
2F | Tileset Specific 2 | |
30 | Tileset Specific 3 | |
31 | Tileset Specific 4 | |
32 | Tileset Specific 5 | |
33 | Tileset Specific 6 | |
34 | Tileset Specific 7 | |
35 | Tileset Specific 8 | |
36 | Tileset Specific 9 | |
37 | Tileset Specific 10 | |
38 | Tileset Specific 11 | |
39 | Tileset Specific 12 | |
3A | Tileset Specific 13 | |
3B | Tileset Specific 14 | |
3C | Tileset Specific 15 | |
3D | Tileset Specific 16 | |
3E | Tileset Specific 17 | |
3F | Tileset Specific 18 |
Note: Most objects separate their nibbles into upper and lower bytes with separate functions. They're specified as {Upper Nibble},{Lower Nibble} in this table.
Extended objects
(Standard object 00)
First | Second | Last |
---|---|---|
N00YYYYY | 0000XXXX | BBBBBBBB |
Bits | Description |
---|---|
N | New Screen flag |
YYYYY | Y position |
XXXX | X position |
BBBBBBBB | Extended object number |
Num | Desc |
---|---|
00 | Special - Screen Exit |
01 | Special - Screen Jump |
02-0F | Unused? |
10 | Small door |
11 | Invisible ? block (1-UP) |
12 | Invisible note block |
13 | Top left corner edge tile 1 |
14 | Top right corner edge tile 1 |
15 | Small POW door |
16 | Invisible POW ? block |
17 | Green star block |
18 | 3-UP moon |
19 | Invisible 1-UP #1 |
1A | Invisible 1-UP #2 |
1B | Invisible 1-UP #3 |
1C | Invisible 1-UP #4 |
1D | Red berry |
1E | Pink berry |
1F | Green berry |
20 | Always turning block |
21 | Bottom right of midway point (unused) |
22 | Bottom right of midway point (unused) |
23 | Note block (flower/feather/star) |
24 | ON/OFF block |
25 | Direction coins ? block |
26 | Note block |
27 | Note block, bounce on all sides |
28 | Turn block (Flower) |
29 | Turn block (Feather) |
2A | Turn block (Star) |
2B | Turn block (Star 2/1-UP/Vine) |
2C | Turn block (Multiple coins) |
2D | Turn block (Coin) |
2E | Turn block (Nothing) |
2F | Turn block (POW) |
30 | ? block (Flower) |
31 | ? block (Feather) |
32 | ? block (Star) |
33 | ? block (Star 2) |
34 | ? block (Multiple coins) |
35 | ? block (Key/Wings/Balloon/Shell) |
36 | ? block (Yoshi) |
37 | ? block (Shell) |
38 | ? block (Shell) |
39 | Turn block, unbreakable (Feather) |
3A | Top left corner edge tile 2 |
3B | Top right corner edge tile 2 |
3C | Top left corner edge tile 3 |
3D | Top right corner edge tile 3 |
3E | Top left corner edge tile 4 |
3F | Top right corner edge tile 4 |
40 | Transculent block |
41 | Yoshi Coin |
42 | Top left slope |
43 | Top right slope |
44 | Purple triangle, left |
45 | Purple triangle, right |
46 | Midway point rope |
47 | Door |
48 | Invisible POW door |
49 | Ghost house exit |
4A | Climbing net door |
4B | Conveyor end tile 1 |
4C | Conveyor end tile 2 |
4D | Line guide, top left 1/4 large circle |
4E | Line guide, top right 1/4 large circle |
4F | Line guide, bottom left 1/4 large circle |
50 | Line guide, bottom right 1/4 large circle |
51 | Line guide, top left 1/4 small circle |
52 | Line guide, top right 1/4 small circle |
53 | Line guide, bottom left 1/4 small circle |
54 | Line guide, bottom right 1/4 small circle |
55 | Line guide end, for horizontal line |
56 | Line guide end, for vertical line |
57 | Switch palace bottom right corner tile |
58 | Switch palace bottom left corner tile |
59 | Switch palace top right corner tile |
5A | Switch palace top left corner tile |
5B | Bit of brick background tile 1 |
5C | Bit of brick background tile 2 |
5D | Bit of brick background tile 3 |
5E | Bit of brick background tile 4 |
5F | Large background area |
60 | Lava/mud top right corner edge |
61 | Ghost house clock |
62 | Ghost house top left to bottom right beam 1 |
63 | Ghost house top right to bottom left beam 1 |
64 | Ghost house cobweb, top right |
65 | Ghost house cobweb, top left |
66 | Ghost house top right to bottom left beam 2 |
67 | Ghost house top left to bottom right beam 2 |
68 | Cloud fringe, bottom and right edge |
69 | Cloud fringe, bottom and left edge |
6A | Cloud fringe, bottom right |
6B | Cloud fringe, bottom left |
6C | Cloud fringe on white, bottom and right edge |
6D | Cloud fringe on white, bottom and left edge |
6E | Cloud fringe on white, bottom right |
6F | Cloud fringe on white, bottom left |
70 | Bit of canvass 1 |
71 | Canvass 1 |
72 | Canvass 2 |
73 | Canvass 3 |
74 | Canvass 4 |
75 | Canvass tile 1 |
76 | Canvass tile 2 |
77 | Canvass tile 3 |
78 | Canvass tile 4 |
79 | Canvass tile 5 |
7A | Canvass tile 6 |
7B | Canvass tile 7 |
7C | Bit of canvas 2 |
7D | Bit of canvas 3 |
7E | Bit of canvas 4 |
7F | Torpedo launcher |
80 | Ghost house entrance |
81 | Water weed |
82 | Big bush 1 |
83 | Big bush 2 |
84 | Castle entrance |
85 | Yoshi's house |
86 | Arrow sign |
87 | ! block, green |
88 | Tree branch, left |
89 | Tree branch, right |
8A | Switch, green |
8B | Switch, yellow |
8C | Switch, blue |
8D | Switch, red |
8E | ! block, yellow |
8F | Ghost house window |
90 | Boss door |
91 | Steep left slope (vert. lev.) |
92 | Steep right slope (vert. lev.) |
93 | Normal left slope (vert. lev.) |
94 | Normal right slope (vert. lev.) |
95 | Very steep left slope (vert. lev.) |
96 | Very steep right slope (vert. lev.) |
97 | Switch palace right and bottom edge tile |
98-FF | Unused? |
Screen exits
(Extended object 00)
First | Second | Third | Last |
---|---|---|---|
000PPPPP | 0000WUSH | 00000000 | DDDDDDDD |
Bits | Page number |
---|---|
PPPPP | Example |
W | Water (secondary exit) |
U | Secondary Exit? * |
S | Secondary Exit |
H | Unused ** |
DDDDDDDD | Lower 8 bits of destination level |
Creates a screen exit. Should be placed right before the end of the level.
*) Used by a Lunar Magic ASM hack: If set, the H bit will be used
**) Used by a Lunar Magic ASM hack: High bit of destination level (only if the U bit is set)
Screen jump
(Extended object 01)
First | Second | Last |
---|---|---|
000PPPPP | 0000???? | 00000001 |
Bit | Description |
---|---|
PPPPP | Page to jump to |
???? | Unused? |
The loading routine jumps to another screen.
Layer 2
Background
Layer 2 backgrounds are compressed using a simple RLE system.
A background consists of any number of "lines". There are two types: Normal line and RLE line
Each line begins with a start byte. The highest bit decides what kind of line it is (0 = Normal, 1 = RLE). The other 7 bits are the "length" setting, which is the amount of tiles in the line minus 1.
A normal line is then followed by (length+1) bytes, each being a tile in the background. An RLE line is only followed by a single byte which is repeated (length+1) times.
The entire left half of the background is stored first, followed by the entire right half.
The line "FFFF" marks the end of the data.
Level
Layer 2 levels are stored in exactly the same way as Layer 1. The five byte header is there as well, but doesn't seem to be used.
Sprites
The first byte of the sprite data is the sprite header. Each sprite is three bytes long.
First | Second | Last |
---|---|---|
YYYYEEsy | XXXXSSSS | NNNNNNNN |
Bits | Description |
---|---|
yYYYY | Y position |
EE | Extra bits |
XXXX | X position |
sSSSS | Screen number |
NNNNNNNN | Enemy number |
(Note: The first byte being FF marks the end of the data)
Secondary entrances
(Not yet documented.)