Super Mario Bros. 2: Level Data
Explanation of Level Data
Level data in the game is made up of two different object types: normal and special. Normal objects includ clouds, hills, vines, etc. Special objects typically dictate how to draw terrain like the ground or caves. If the first byte of an object starts with and F, then it is a special object, otherwise it's a normal object.
Normal objects are stored as two bytes. The first byte is the YX value (Y is the number of tiles down from the preceeding object and X is the number of tiles from the left edge of the page) and the second byte is the object type. For example, the bytes "13 2A" refer to an object type 2A which is located 1 tile down from the preceeding object (or top of the screen, if it's the first object) and 3 tiles from the left edge of the screen.
Special objects are stored a little differently. The first byte is F? where ? is the special object number (0 thru F). Special objects can have 1, 2, or no parameters. The parameter bytes immediately follow the F? byte.
The next object after a door object acts as its pointer and does not show up in the game. This "door pointer" tells the game where the door leads. The next object after a door should always be a regular object, but the special object F5 is also allowed to be a door pointer.
Explanation of Parameters
For objects acting as door pointers, the first parameter (YX coordinate) is what world you go to (0 = World 1, 1 = World 2, etc...), and the second parameter (object type) is what area in the world you go to. I don't know what happens if the first parameter is greater than the number of worlds in the game (ie. greater than 6 since we start counting Worlds as 0 being the first).
Special object F0 affects the ground setting (high, low, pits, etc.). It has one parameter. Different parameter values produce different terrain effects.
Special object F1 affects the ground setting (high, low, pits, etc.). It has one parameter. Different parameter values produce different terrain effects.
Special object F2 means the next object's X coordinate will be skipped forward one page. It has no parameters.
Special object F3 means the next object's X coordinate will be skipped forward two pages. It has no parameters.
Special object F4 means to start a new object layer. The next object will be placed as though it were the first object (i.e. it's YX coordinate byte's reference point will be the top left of the first page. It has no parameters.
Special object F5 is an area pointer. It has two parameters. These parameters act the same way as door parameters do: the first says what world to go to and the second tells what area in the world to go to.
Special object F6 affects the look of the ground (rock, sand, grass, etc.). It has one parameter that dictates which tiles to use to draw the ground.
Special objects F7 thru FE are unused(?)
Special object FF has no parameters. It marks the end of data for the current level.