Addresses are vanilla and traced in the SMW disassembly's bank 04 unless a section says otherwise. Lunar Magic facts come from LM's help on the overworld editor [LM-DOC], restated in plain words, and from controlled before/after saves in LM and several LM-edited ROMs compared against vanilla.
Two maps, each 32x32 16x16 tiles (512x512 px). The main map is index 0x000-0x3FF. The six submaps share one second map, index 0x400-0x7FF, two columns by three rows; a "submap" ($1F11: 1 Yoshi's Island, 2 Vanilla Dome, 3 Forest, 4 Valley, 5 Special, 6 Star) is a fixed camera plus a palette, not separate storage. Cameras at $049A0C: 1 (-17,-40), 2 (-17,128), 3 (-17,296), 4 (240,-40), 5 (240,128), 6 (240,296) px.
Lunar Magic draws both on one canvas: the main map at tile Y 0-0x1F, the submap map at Y 0x20-0x3F, with the submap map rotated 16px right and 8px down (two 8x8 cells and one row). Its tilemap's last two columns and last row wrap round to the lower map's left edge and top, as a hardware scroll would show them, and layer 1 rides the same shift. The game itself shows both layers on the plain grid; the rotation is only LM's canvas layout [MEASURED, aligning LM's window and an emulator frame of the game against a raw render].
Layer 1 index ($049885): (X&0xF) | (X&0x10)<<4 | (Y&0xF)<<4 | (Y&0x10 ? 0x200 : 0), i.e. four 16x16-tile screens TL TR BL BR of 0x100 each, +0x400 on the submap map.
vhopppcc tttttttt. LM expands this to two pages (0x200 tiles).
Two RLE streams: tile numbers $04A533, property bytes $04C02B (decoded at $04DABA). Header byte n: bit 7 clear = copy n+1 literal bytes, set = repeat the next byte (n&0x7F)+1 times; each stream fills one byte of every word until 0x2000 words. The result is two 64x64 8x8 tilemaps in SNES screen order (four 32x32 screens of 0x400 words, TL TR BL BR), main map then submap map, DMA'd to VRAM $3000. Layer 2 scrolls with layer 1 (no parallax); layer 3 is the static border.
Layer-2 event tiles (LM's 6x6 and 2x2 "pieces"): tile bytes $0C8000 (0x900 bytes of 6x6 pieces, then 2x2), property bytes RLE at $0C8D00 in the same encoding as layer 2's streams, so the two bytes join into an 8x8 word. 0xD00 cells in all: 64 pieces of 6x6, then 256 of 2x2. A step writes piece src at dst ($04E4D0 for 2x2 if src >= 0x900, $04E520 for 6x6).
$1931 = 0x11 + submap selects ObjectGfxList $00A92B rows 0x11-0x17 = GFX1C 1D 08 1E on every submap in vanilla (the rows exist so LM can bypass per submap). Sprite set 0x11 selects SpriteGfxList $00A8C3 = GFX10 0F 1C 1D. Layer 3 = GFX28-2B.
0x7F is skip this slot, the same convention as a level's.
14 00 7F 00 7F 00 7F 00 1E 00 08 00 1D 00 1C 00 1D 00 1C 00 0F 00 10 00 2B 00 2A 00 29 00 28 00) and leaves w0 bit 15 clear; the loader reads a submap's record unconditionally. Read back both ways: bytes written into a table LM installed appear in LM's dialog (a hand-patched LM save showed FG1 = 0F and SP1 = 0C on the Forest of Illusion), and LM's dialog writes exactly these words.
STA $20 : SEP #$20 at $00A140 (the last thing before the JSR UploadSpriteGFX at $00A9DA, whose tail at $00AA50 carries the bypass loader) becomes JSL $0FFAB0, and the LDY #$14 : JSL $00BA28 at $00A147 keeps the LDY but has the JSL NOPped, because the record's AN2 slot now supplies that file. LM's stub at $0FFAB0 is STA $20 : TXA : ASL×4 : CLC : ADC #<record low16> : STA $7FC006 : SEP #$20 : LDA #<bank> : STA $7FC008 : LDA #$42 : STA $7FC009 : LDA #$00 : STA $7FC00B : RTL. The submap comes in as X = submap*2 from vanilla's own LDX $0DB3 : LDA $1F11,X : ASL : TAX at $00A12A, the same place LM's overworld ExAnimation setup reads it (EXANIMATION §10), and $7FC009 = #$42 is what tells LM's loader this is the overworld rather than a level (#$41).
4C 4D 03 01 at $0FF15C, and the record address in the two operand fields LM parses the stub for (ADC #imm at $0FFAB0+9/+10, LDA #imm at +18). A ROM carrying the 35-byte stub with a record address in those fields (even with only its closing RTL replaced) and the stamp in place has LM read the seven records, write an edited slot into that table, and install none of its own loader [MEASURED in both directions; LM_PARITY §2 has the experiments and the negatives].
0x2B it showed LG1=02B for Yoshi's Island and 028 for the other six. No stamp beyond the one above is needed; the layer-3 dialog reads the same table.
2F for LG1 left the record at w0 = 0x4014 (bit 14 set, AN2 untouched) and w15 = 0x002F.
0x2B, the layer-3 VRAM page changed on the map in an emulator.
LDA #$02 : STA $420B : RTL at $04D73F: it sets VRAM word $3000 and DMAs 0x2000 bytes there from $7F4000, or $7F6000 when $1F11 says the player is on a submap (DMA parameters at $04DAB3 = 01 18 00 40 7F 00 20). Found in the disassembly and confirmed by mutation: changing that source byte moved VRAM $6000-$7FFF on the map, so the routine runs on the path a new game takes and word $3000 really is the overworld's layer-3 tilemap [CONFIRMED]. The record word and its encoding are a level's, because that is what LM writes: w0 bit 13 enables, w1 = file (bits 0-11) | size index (bits 12-13) | destination index (bits 14-15). The one difference is the window base: a level's layer 3 starts at word $5000, the overworld's at $3000. Ticking "Enable bypass of standard Layer 3 tilemap for this submap" in LM and choosing file 28 left the record at w0 = 0x2014, w1 = 0x6028, and LM's overworld save does not touch $04D730-$04D7A0 (checked against a control save) [MEASURED].
$0A = $FF00 filter), so every drawn pixel of those files lands in colours 8-F of its row. The castles, the level stars and the SNES logo are painted for those colours, and the 3bpp files hold indices 1-7 that never show. The two file numbers are operands of those compares; LM's 4bpp mode bakes the plane into its files and points both compares at GFX32.
LoadPalette first, with whatever header bytes the last level left (a new game arrives with the intro level 0xC7's), then $00AD25 lays the overworld's colours over it:
Both layers draw in rows 0-7; what a layer 1 tile from GFX1E or GFX08 shows is colours 8-F of its row (plane 3 above), so rows 0-3 colours 1-7 (the level loader's leftovers) hardly matter, and LM's palette editor shows them black. Path fading borrows rows 0-3 and C-F colours 1-7 during a reveal. LM's Overworld Palette Editor agrees with this derivation row for row on every submap [MEASURED].
JSL over STY $00 : LDA $1931 at $00AD32 with an RTS at $00AD36, so the vanilla loads never run, and a hook that copies one whole 0x200-byte palette per submap over the CGRAM mirror with one MVN: TAX : LDA $1931 : AND #$0F : DEC : CLC : TXY : BPL + : ADC #7 : + XBA : ASL : ADC #table : TAX : LDY #$0703 : LDA #$01FF : PHB : MVN $00,bank : PLB : SEP #$30 : RTL, then LM 00 01, in a RATS block of 0x30. The table is a RATS block of 0x1C00: submaps 0-6, then the same seven once the special world is passed (X still holds the flag $00AD2B read; which flag is the hack's own setting: one LM-edited ROM reads $1F00, vanilla $1EEA). LM's -TransferOverworld from an LM-edited ROM onto a clean one gives a hook byte-identical to the source's bar the table address. LM keeps the hook where it finds it and rewrites its operands, but frees the table and allocates a new one on each save, so nothing may hold the table's address across an LM save [MEASURED].
0000 everywhere else (the level loader's leftovers, which is why LM's editor shows rows 0-3 colours 0-7 black), and Mario's ten colours from $00B2C8 at 0x86-0x8F (the game uploads the player's palette there every frame regardless). Checked against 33 distinct LM tables: one differs from that rule in 3 of 3584 colours, another in 4, and the rest only in land colours their authors recoloured. -TransferOverworld from a ROM without the table installs nothing, so LM converts only on a palette save [MEASURED].
Per translevel (0-0x5F): exit directions $04D678 (bits 7-6 normal, 5-4/3-2/1-0 secret 1-3; 0 up, 1 down, 2 left, 3 right); base event $05D608 ($FF none; secret exit N fires base+N); level name $04A0FC (word giving three string offsets into $049AC5). Flags RAM $1EA2: bit 7 passed, 6 midway, 3-0 directions enabled (LM adds 5 "no entry if passed", 4 "save prompt"); new-game pairs at $009EE0; Mario/Luigi start $009EF0 = submap 1, tile (6,7). Reveal list $04DA1D to $04DA33 (22 pairs); event N reveals the layer-1 cell at $04D85D[N]. No-auto-move levels $04906C (6). Music per submap $048D8A.
Walkability is the layer-1 tile at the next cell (path < 0x56 or level tile) and the direction bit at the level Mario stands on. What a path tile does is its pose byte at $049FEB (read at $0495EF): bit 3 swims (tiles 28-3E, 50), bit 4 climbs (3F-41, the ladders; also sets $1B80 for the ladder speed table $049414), anything else walks; bit 2 only picks Mario's front-facing walk frames. Exit tiles are the ten in $049426 (25, 40, 42-48, 4D). Fish jump on 4E-50, Koopa Kids trigger on 49-4B. Level tiles 56-82 enter; 83-86 stop Mario without entering.
[CONFIRMED] against Lunar Magic's "Layer 1 Mario Paths" view on a ROM whose layer 1 was a grid of every tile 01-86: LM draws exactly those sets as green / blue / rungs / red / X. LM stores no bitmap for these pictures: its exe resources hold the level editor's slope outlines and the message font, not these.
Step vectors $049058; corner tiles $04A03C; per-tile speed and animation $049EA7. Five hardcoded paths ($049078, $04910E, $0490CA, $049086) that LM cannot display, only disable. Layer-1 paths are static; "a path revealed by an event" is a layer-2 change.
0x78 events (bitfield $1F02-$1F10; vanilla tables sized 0x70). Layer-2 standard steps: cumulative index $04E35B (event N = steps E35B[N-1]..E35B[N]-1), 4 bytes per step at $04DD8D [src word][dst word], animated one per frame with a sound. Silent steps (layer 1, and layer 2 on other maps): events $04E8E4, flags $04E910 (bit 0 = layer-2 piece), dst $04E93C, tile/piece $04E994 (0x2C each); applied all at once on load. Destroy (castle, switch palace): events $04E5D6 (0x18), offsets $04E5B6, source tiles $04E5A7, replacements $04E5AC/$04E5B1.
submap<<8 | tileX) and $048467[i] (tileY); destination $04849D[i] (bits 0-8 X px, 9-12 dest submap) and $0484D3[i] (Y px). LM's "destination index" is derived by matching a destination to another entry's source; LM grows the table to 0x100 and reuses it for level "Location teleports". Every destination vanilla stores is the tile's CENTRE (tile*16 + 8), and every source sits on a star or pipe tile: 0x5A, 0x5B, 0x5F or 0x82 [MEASURED against all 27]. The four arrays are butted together ($048431 + 0x36 is $048467), and vanilla fills all 27 entries, so there is no spare slot without relocating them. A source of $FFFF is a free slot, the shape the game's own search walks past.
$1F19/$1F17 and his submap $13C3, then writes the destination into all three plus his tile $1F21/$1F1F. The three tables are contiguous ($049964 + 0x46 is $0499AA, and + 0x46 again is $0499F0).
The position carries the direction. Mario is centred on the axis he is not moving along and a tile short on the one he is, so an entry is a tile AND a way of travelling through it: moving down (x*16+8, y*16), up (x*16+8, y*16+16), right (x*16, y*16+8), left (x*16+16, y*16+8). The same bytes therefore read as "tile 20 walking down" or "tile 21 walking up"; the one of the two that is an exit tile settles it. This is the "side to enter from" LM's link dialog asks for, and the destination is the partner tile written the same way, since the player keeps travelling as he was [CONFIRMED against all 14 vanilla entries; decoding and re-encoding them reproduces the ROM's own bytes].
The map already knows the side: an exit tile is the end of a path, so the player leaves by the side the path does not use, which can be read off the four neighbours. All 13 vanilla entries that sit on an exit tile agree with it (the fourteenth, entry 04, sits on a plain walk tile). A tile with other than exactly one walkable neighbour is ambiguous.
13 slots x 5 bytes at $04F625: type, X lo/hi, Y lo/hi. Types in LM's list order (Lakitu, bird, fish x3, piranha, cloud, Koopa kid x3, smoke x2, sign, Bowser, ghost x2). Mario's and Luigi's start positions are edited as sprites in LM.
One canvas; left click selects, right click pastes, Ctrl+Right always pastes the selector's tile, left-drag lassos, dragging a selection moves it, Ctrl+Left on a selection edge resizes it as a repeating pattern. Five edit modes:
View toggles: Layer 1, Layer 2, Sprites, Show Level Numbers, Show Event Numbers, Show Star/Pipe/Location Numbers, Show Exit Path Numbers, Layer 1 Mario Paths (green walk, black climb, blue swim, red exit), Future Layer 1 Tiles, Tile Grid, Special World Passed Palette. "Modify Level Tile Settings" holds: level number, base event, direction per exit, reveal-on-events, and the eight initial flags. Gotchas LM warns about [LM-DOC]: test on a fresh save slot (directions live in SRAM); never reuse a level number on two tiles; paths must not dead-end, gap or cross; one destroy and one reveal per event; star/pipe at X=0 on the submap map do not work.
Lunar Magic's Layer 2 8x8 mode is wider than the two maps. The cells below are the 8x8 grid LM counts in:
| area | cols | rows | what a cell is |
|---|---|---|---|
| main map | 0-63 | 0-63 | a layer 2 word |
| submap map | 0-63 | 64-127 | a layer 2 word (rotated 2 right, 1 down, §1) |
| event pieces, 6x6 | 64-111 | 0-47 | a byte of $0C8000: 8 pieces across, 36 bytes each, row-major |
| event pieces, 2x2 | 112-159 | 0-21 | a byte from $0C8900: 24 pieces across, 4 bytes each |
| layer 1 tiles | 0-31 | 128+ | a word of the Map16 defs $05D000: 16 tiles across, TL BL TR BR |
Measured by hovering LM and reading its status bar: canvas (0x41,1) is the 6x6 pieces' byte 7 (0x11 in a vanilla ROM, which is what LM shows there), the 2x2 index steps by 1 across and 0x18 down (so 24 across), and (2,0x82) is "Map16 11" whose top-left word is 8x8 tile 0x1D9.
The filler. A cell no table reaches gets LM's filler tile rather than a hole: 8x8 tile 0x7A, a black cross on blue, in palette row 5 (LM's status bar reports "7A" out there, and 0x7A's pixels are colours 1 and 4, which row 5 paints black on the sea's blue). 0x7A is one of the cycling animated slots (0x78-0x7F, §4), so on the map it shows whichever GFX14 frame is up.
LM paints that same X over piece slots a vanilla ROM fills with tile 0xBA (a dither texture), so its event area looks emptier than the ROM's bytes, which are what the game would draw if a step used the piece. LM is showing its own normalised copy, which it writes on its first overworld save.
LM's Alt+Right dialog on a level tile has five groups. Where each lives [MEASURED, by changing each in LM's own dialog and diffing]:
| field | where it lives |
|---|---|
| base event | $05D608 + translevel, in place on every ROM |
| direction per exit (normal + 3 secret) | $04D678 + translevel, 2 bits each, on a ROM LM has not saved the overworld of. LM's overworld save jumps the copy loop and reads a packed block of its own instead, so after that the vanilla table is not read |
| level number | vanilla: the scan order of §2. LM: its per-tile table, the LZ2 blob behind the scan's operands (below) |
| eight initial flags | vanilla: eight (translevel, flags) pairs at $009EE0, written by the new-game loop at $009F0E. LM replaces the loop with a table at $05DDA0 + translevel when it saves [INFERRED; not checked against an LM-saved ROM] |
| reveal on event | LM's layer 1 event data (§7, and the silent-events row below) |
LM saves an overworld by moving a few tables and leaving the vanilla bytes in place, so a reader that trusts the vanilla addresses shows vanilla land under the hack's level tiles. What moves, and where the loader says so. Example addresses are from two of the ROMs, called A and B:
| table | vanilla | LM | read from |
|---|---|---|---|
| layer 2 tile stream | $04A533 | anywhere (A $12B1D3, B $139F8E) | LDA #$addr at $04DC71; bank LDA #$bb at $04DC78, shared by both streams |
| layer 2 property stream | $04C02B | packed right after the tile stream (A $12B259, B $13B2D6) | LDA #$addr at $04DC8C |
| layer 1 Map16 | $05D000, 0xC1 tiles | 0x200 tiles, LM's STAR marker right after (A $15A42C; B kept vanilla) | LDX #$addr at $04DCBB, LDA #$bb at $04DCBF; also at $04DC3B |
| layer 1 low bytes | $0CF7DF | in place | none |
| layer 1 high bytes | none | LZ2 blob, decompressed to $7FC800 at load (all zero in both ROMs) | second LDX #$addr : STX $8A : LDA #$bb : STA $8C in LM's rewrite of the $04D7F2 block |
| translevel per tile | the scan at $04D7F2 | LZ2 blob, decompressed to $7ED000 (0x1000 bytes): this is "level number to use for this tile"; ROM B numbers 81 tiles differently from the scan | first LDX/STX $8A/LDA/STA $8C in the same block; the decompressor is vanilla $00B8DE, called by PHK : PER : PEA : JML |
| standard event steps | $04DD8D | A $138C38, B $10F144 (vanilla bytes left behind) | long operands at $04E49E/$04E4A3 and $04E708/$04E70F |
| step index $04E35B | in place | none | |
| event piece tiles | $0C8000 | A $148000, B $10E1E3 | bank LDA #$bb at $04E4AF, address LDA #$addr at $04E4BA |
| event piece properties | $0C8D00 | A $148B4C, B $138080 | LDY #$addr at $04DD44, bank LDA #$bb at $04DD49 |
| silent events | $04E8E4/$04E910/$04E93C/$04E994 | LM's own block, 16-bit tiles; vanilla tables stale | JSL at $04E9F1 to a hook (A $129353). Its four long operands in order: event-to-step index (words, 0x79), flags (byte per step, bit 0 = layer 2 piece), tile (word: layer 1 tile, or piece index with >= 0x900 = 2x2), destination (word: layer 1 index or layer 2 tilemap offset). Layer 2 pieces still go through vanilla $04E4A9 |
| destroy events | $04E5D6, $04E5B6... | A $12A0B5/$12A045, B $10F880/$10F810 | long operands at $04E67C, $04E69C |
| reveal list | $04D85D | A $129C37, B $10EF1D | long operands at $04DA73, $04EC8B, $04ED96 |
| $04E587 table (level-tile flags) | A $12A07D, B $10F848 | operand at $04EEC8, behind a JSL at $04EEC3 that indexes it by LM's translevel | |
| star/pipe warps | 27 entries at $048431... | in place; the entry count is the LDX #$n*2 at hook+$11 behind the JSL at $048509 (A 0, B 26) | hook operand |
| base events $05D608, exit dirs $04D678, exit tiles $049964..., Koopa teleports $048E49, sprites $04F625, music $048D8A, no-auto-move $04906C... | edited in place (ROM B changed music there) | vanilla addresses hold | |
| OW palettes $00B3D8, $00B528, $00B57C, $00B5EC | in place until LM's first overworld palette save; then a whole palette per submap in LM's table (B $13A9B9), the vanilla tables unread (§4) | JSL at $00AD32 to a hook; table address at hook+$12 (word) and hook+$1E (bank) | |
| level names $049AC5 | ROM B only: JMP $04FFB1 at $049882/$049AC2, LM's names rewrite, not traced |
Also hooked and not yet traced: $04DBB9 and $04DCA5 (the latter replaces INC $0F : LDA $0F in the load loop and replays passed events' silent steps from LM's tables), $04DCFA (to $06F5E4), $04E5F1 (to $05DCB0), $04E6C5, $04EDDD, $04EEF1, $05D7B9, $05D979, $05D9A1, $05D9E3 (the level-number / base-event code of bank 05), $0C9436. On SA-1 ROMs all of this moves to bank $40 and $6D-mirrored RAM; not traced here.