Skip to content
palaceswitcher edited this page May 29, 2024 · 5 revisions

Levels are well... levels. In this context, they refer to any rooms the player can access. There are 29 main levels accessible from the map and 7 sub-levels that appear within levels. Data pertaining to levels can be found below.

Level Numbering

Levels in this game aren't numbered as straightforwardly as you'd think. Each level on the map has a spot number in increasing order, which is used to determine the world number and level number of each level spot. The world number and level number are then added together (see equation below) to determine the level's ID. The ID itself is used to determine the level's ROM location, tileset, music, etc.

Level ID Equation: (WorldNumber*4)+LevelNumber

Hardcoded Properties

Castles & Ghost Houses

The 4th level of every world is hardcoded to be a castle. Upon completion, castles become inaccessible for the current session and will appear destroyed on the overworld map.

Both Ghost Houses and castles will always load into their cutscene level at first, with the level itself being reached by a warp triggered at the end of the cutscene. The game is programmed to trigger the intro cutscene event if a level's starting tileset is in PRG bank 35.

Yoshi Houses

Whether a level is considered a Yoshi House is determined by whether or not its level spot number is in the list of Yoshi House spots. Levels that are treated as Yoshi houses will have whatever world and level number assigned to them (All of them in this game are set to 1-1.) overridden and will be treated as level 8-1, or level ID 28.

Interestingly enough, there are 7 entries in the Yoshi House table, despite there only being 3 of them used in-game. This could suggest that every world in the game was intended to have a Yoshi House.

Yoshi House Table: 52C86 - 52C8C (Bank 41, $AC86 - $AC8C)


Level Data

Levels are stored as uncompressed screens of raw metatile data, which are arranged by tables in the tileset data (see below). Metadata pertaining to the level, such as music data, its PRG bank, and tileset, are stored separately from the levels in ROM locations below [ADD LINK].

Tileset/Layout Data

Each level has a tileset attached to it, which contains set of metatiles used by the level. The PRG bank of the tileset as well as the tileset number used by each level is stored in a level's metadata, can be found here [ADD LINK].

Format

Each tileset takes up 2048 bytes, or a quarter of its bank. Tileset data is further split into 6 pages, with each page representing data for each of the 256 metatiles in order.

Page Purpose
0 Upper-left tile
1 Upper-right tile
2 Lower-left tile
3 Lower-right tile
4 Tile attribute(s)
5 Tile behavior
6 Level screen layout
7 Unused

Screen layout data is stored a bit differently. It's always found in the first tileset of a PRG bank at address $8600, with 4 64-byte tables for each level of a world. However, some levels, such as Ghost Houses and castles, reuse tilesets, meaning their layout data may be duplicated or in an arbitrary position to compensate for the tileset being used for different level numbers. The screen layout addresses for each level number is precalculated and can be found in the table specified below.

Relevant Locations

Level Screen Layout Pointer: $008C - $008D (RAM)
Level Screen Layout Pointers (Low): 7B5E0 - 7B5E3 (Bank 61, $B5E0 - $B5E3)
Level Screen Layout Pointers (High): 7B5E4 - 7B5E7 (Bank 61, $B5E4 - $B5E7)

Warps

Warps are used to reach levels from the same level. Some examples include bonus rooms, (some) boss rooms, and castle and ghost houses.

Clone this wiki locally