foundry.smb3parse.levels package#
Submodules#
foundry.smb3parse.levels.WorldMapPosition module#
foundry.smb3parse.levels.level module#
foundry.smb3parse.levels.level_header module#
foundry.smb3parse.levels.util module#
- find_world_position(rom: Rom, layout_address: int) foundry.smb3parse.levels.WorldMapPosition.WorldMapPosition | None #
foundry.smb3parse.levels.world_map module#
- class WorldMap(layout_address: int, rom: Rom)#
Bases:
LevelBase
Represents the data associated with a world map/overworld. World maps are always 9 blocks high and 16 blocks wide. They can be multiple screens big, which are either not visibly connected or connected horizontally.
- Attributes:
layout_address The point in the ROM of the bytes making up the visual layout of the world map. layout_bytes The actual bytes making up the visual layout
width The width of the world map in blocks across all scenes. height The height of the world map, always 9 blocks.
tileset An Tileset object for the world map object set. screen_count How many screens this world map spans.
- gen_levels()#
Returns a generator, which yields all levels accessible from this world map.
- gen_positions() Generator[WorldMapPosition, None, None] #
Returns a generator, which yield WorldMapPosition objects, one screen at a time, one row at a time.
- is_enterable(tile_index: int) bool #
The tile attributes for the overworld tile set define the minimal value a tile has to have to be enterable. Which of the 4 bytes to check against depends on the “quadrant”, so the 2 MSBs.
- Parameters:
tile_index – Tile index to check.
- Returns:
Whether the tile is enterable.
- property level_count#
- level_for_position(screen: int, point: Point) tuple[int, int, int] | None #
The rom takes the point of the current player, so the world, the screen and the x and y coordinates, and operates on them. First it is checked, whether or not the player is located on a tile, that is able to be entered.
If that is the case, the x and y coordinates are used to look up the object set and address of the level. The object set is necessary to find the right base offset for the level address and to correctly parse its object data.
Using the tile information it should be possible to correctly name almost all levels, for example Level 1 will be located in the list at the offset pointed to by the “Level 1” tile in that world.
That means, that all levels should be able to be collected, by iterating over all possible tiles and following the same procedure as the rom.
- Parameters:
- screenint
The screen index of the level to acquire.
- point: Point
The point the player is located at.
- Returns:
- Any
A tuple of the object set number, the absolute level address, pointing to the objects and the enemy
- address. Or None, if there is no level at the map point.
- level_indexes(point: WorldMapPosition) tuple[foundry.core.geometry.Point, int, int] | None #
Provide the level index from a given screen and point.
- Parameters:
- point: WorldMapPosition
The point inside the world map.
- Returns:
- tuple[Point, int, int] | None
The level indexes, if it exists.
- replace_level_at_position(level_info, point: WorldMapPosition)#
- tile_at(screen: int, point: Point) int #
Returns the tile value at the given coordinates. We define (0, 0) to be the topmost, leftmost tile, under the black border, so we’ll adjust them accordingly, when bound checking.
- property world_index#
- get_all_world_maps(rom: Rom) list[foundry.smb3parse.levels.world_map.WorldMap] #
Module contents#
- COMPLETABLE_LIST_END_MARKER = 0#
A value, that specifies the end of the completable tiles, rather than a set address.
- COMPLETABLE_TILES_LIST = 99415#
A list of tile values, that are completable, like the Toad House.
- ENEMY_BASE_OFFSET = 16#
One additional byte, at the beginning of every enemy data, where I don’t know what does
- FIRST_VALID_ROW = 2#
Tiles in rows before this one are part of the border and not valid overworld tiles.
- LEVELS_IN_WORLD_LIST_OFFSET = 103458#
The memory locations of levels inside a world map are listed in a row. This offset points to the memory locations of these lists for every world. The first 2 bytes following this offset point to the levels in world 1, the next 2 for world 2 etc.
- LEVEL_BASE_OFFSET = 65552#
Offset for level related parsing. Currently only used in Header.
- LEVEL_ENEMY_LIST_OFFSET = 103440#
- LEVEL_X_POS_LISTS = 103422#
This list contains the offsets to the x positions/column indexes of the levels in a world map. They are listed in a row for all 4 screens.
- LEVEL_Y_POS_LISTS = 103404#
This list contains the offsets to the y positions/row indexes of the levels of a world map. Since world maps can have up to 4 screens, the offset could points to 4 consecutive lists, so we need to know the amount of levels per screen, to make sense of them.
- OFFSET_BY_OBJECT_SET_A000 = 246777#
A list of values, which specify which ROM page should be loaded into addresses 0xA000 - 0xBFFF for a given object set. This is necessary, since the ROM is larger then the addressable RAM in the NES. The offsets of levels are always into the RAM, which means, to address levels at different parts in the ROM these parts need to be loaded into the RAM first.
- OFFSET_BY_OBJECT_SET_C000 = 246758#
Same with the ROM page and addresses 0xC000 - 0xFFFF.
- SPECIAL_ENTERABLE_TILES_LIST = 85439#
A list of tile values, that are also enterable, like the castle and the toad house.
- STRUCTURE_DATA_OFFSETS = 103386#
This lists the start of a block of world meta data. 9 worlds means 9 times 2 bytes of offsets. The block starts with a 0x00, so that also marks the end of the block before it.
- TILE_ATTRIBUTES_TS0_OFFSET = 99344#
The first 4 bytes describe minimal indexes an overworld tile must have to be enterable.
- VALID_COLUMNS = range(0, 16)#
A range of column values, where Mario could possibly stand.
- VALID_ROWS = range(2, 11)#
A range of row values, where Mario could possibly stand.
- WORLD_MAP_BASE_OFFSET = 57360#
Offset for a lot of world related parsing.