Super Mario Bros. 2 Disassembly

A project to disassemble and understand everything about Super Mario Bros. 2

View on GitHub

Level Data

Levels are broken down by area. The first four bytes are a level header, specifying things like palettes, music, size, scrolling, and ground type. The rest is level objects. Levels are ended by the $FF special object.

Each “page” of level data is 16×15 tiles.

Note that area 4 is typically used for the common “jar” room, if there are any in a given level.

Level layouts

Level headers are the first 4 bytes of a level:

x are unused bits.

Objects

Ground types

@todo

Enemy layouts

This data is broken down by page (ie. screen), where the first byte indicates the number of bytes for this page. Each enemy is two bytes, where the first byte is the enemy ID, and the second byte is XY position.

Each “page” of enemy data is 16×16 tiles.

Note that this is one tile GREATER than level data. Consequently, level and enemy data becomes increasingly misaligned in vertical areas.

Examples:

In the disassembly, these have been replaced with a macro for readability and ease of editing:

; Page 0
	distTo + ; $03 (1 enemy)
	enemy $3, $8, Enemy_HawkmouthRight

; Page 1
+	distTo + ; $05 (2 enemies)
	enemy $9, $4, Enemy_SnifitPink
	enemy $B, $4, Enemy_SnifitPink

+ ; Additional pages here ...

The first line of each page is distTo +, which automatically fills in the length of the section. The following lines, if any, are enemies for that page.

The format for enemy placement is enemy $X, $Y, Enemy_Name. Each area is terminated by a +, with the section repeating additional distTo macros as needed.