bn::regular_bg_item class

Contains the required information to generate regular backgrounds and their maps.

The assets conversion tools generate an object of this type in the build folder for each *.bmp file with regular_bg type.

Tiles, colors and map cells are not copied but referenced, so they should outlive the regular_bg_item to avoid dangling references.

Constructors, destructors, conversion operators

regular_bg_item(const span<const tile>& tiles_ref, const span<const color>& colors_ref, bpp_mode bpp, const regular_bg_map_cell& map_cells_ref, const size& map_dimensions) constexpr
Constructor.
regular_bg_item(const regular_bg_tiles_item& tiles_item, const bg_palette_item& palette_item, const regular_bg_map_item& map_item) constexpr
Constructor.

Public functions

auto tiles_item() const -> const regular_bg_tiles_item& constexpr
Returns the item used to create the tiles of the output regular backgrounds.
auto palette_item() const -> const bg_palette_item& constexpr
Returns the item used to create the color palette of the output regular backgrounds.
auto map_item() const -> const regular_bg_map_item& constexpr
Returns the item used to create the map of the output regular backgrounds.
auto big() const -> bool constexpr
Indicates if backgrounds generated with this item are big or not.
auto uncompress(span<tile> uncompressed_tiles_ref, span<color> uncompressed_colors_ref, regular_bg_map_cell& uncompressed_cells_ref, const size& uncompressed_dimensions) const -> regular_bg_item
Uncompresses the stored data in the tiles referenced by uncompressed_tiles_ref, the colors referenced by uncompressed_colors_ref and the map cells referenced by uncompressed_cells_ref.
auto create_bg(fixed x, fixed y) const -> regular_bg_ptr
Creates a regular_bg_ptr using the information contained in this item.
auto create_bg(const fixed_point& position) const -> regular_bg_ptr
Creates a regular_bg_ptr using the information contained in this item.
auto create_bg_optional(fixed x, fixed y) const -> optional<regular_bg_ptr>
Creates a regular_bg_ptr using the information contained in this item.
auto create_bg_optional(const fixed_point& position) const -> optional<regular_bg_ptr>
Creates a regular_bg_ptr using the information contained in this item.
auto find_map() const -> optional<regular_bg_map_ptr>
Searches for a regular_bg_map_ptr which references the information provided by this item.
auto create_map() const -> regular_bg_map_ptr
Searches for a regular_bg_map_ptr which references the information provided by this item. If it is not found, it creates a regular_bg_map_ptr which references it.
auto create_new_map() const -> regular_bg_map_ptr
Creates a regular_bg_map_ptr which references the information provided by this item.
auto create_map_optional() const -> optional<regular_bg_map_ptr>
Searches for a regular_bg_map_ptr which references the information provided by this item. If it is not found, it creates a regular_bg_map_ptr which references it.
auto create_new_map_optional() const -> optional<regular_bg_map_ptr>
Creates a regular_bg_map_ptr which references the information provided by this item.

Friends

auto operator==(const regular_bg_item& a, const regular_bg_item& b) -> friend bool defaulted constexpr
Default equal operator.

Function documentation

bn::regular_bg_item::regular_bg_item(const span<const tile>& tiles_ref, const span<const color>& colors_ref, bpp_mode bpp, const regular_bg_map_cell& map_cells_ref, const size& map_dimensions) constexpr

Constructor.

Parameters
tiles_ref Reference to regular background tiles.
colors_ref Reference to an array of multiples of 16 colors.
bpp Bits per pixel of referenced colors.
map_cells_ref Regular background map cells to reference.
map_dimensions Size in map cells of the referenced map cells.

The tiles are not copied but referenced, so they should outlive the regular_bg_item to avoid dangling references.

The colors are not copied but referenced, so they should outlive the regular_bg_item to avoid dangling references.

The map cells are not copied but referenced, so they should outlive the regular_bg_item to avoid dangling references.

bn::regular_bg_item::regular_bg_item(const regular_bg_tiles_item& tiles_item, const bg_palette_item& palette_item, const regular_bg_map_item& map_item) constexpr

Constructor.

Parameters
tiles_item It creates the tiles of the output regular backgrounds.
palette_item It creates the color palette of the output regular backgrounds.
map_item It creates the map of the output regular backgrounds.

bool bn::regular_bg_item::big() const constexpr

Indicates if backgrounds generated with this item are big or not.

Big backgrounds are slower CPU wise and don't support wrapping (they can't be moved beyond their boundaries), but can have any width or height multiple of 256 pixels.

regular_bg_item bn::regular_bg_item::uncompress(span<tile> uncompressed_tiles_ref, span<color> uncompressed_colors_ref, regular_bg_map_cell& uncompressed_cells_ref, const size& uncompressed_dimensions) const

Uncompresses the stored data in the tiles referenced by uncompressed_tiles_ref, the colors referenced by uncompressed_colors_ref and the map cells referenced by uncompressed_cells_ref.

Parameters
uncompressed_tiles_ref Destination of the uncompressed tiles.
uncompressed_colors_ref Destination of the uncompressed colors.
uncompressed_cells_ref Destination of the uncompressed map cells.
uncompressed_dimensions Size in map cells of the destination data.
Returns A regular_bg_item pointing to the uncompressed tiles, colors and map cells.

If the source and destination tiles, colors or map cells overlap, the behavior is undefined.

regular_bg_ptr bn::regular_bg_item::create_bg(fixed x, fixed y) const

Creates a regular_bg_ptr using the information contained in this item.

Parameters
x Horizontal position of the regular background.
y Vertical position of the regular background.
Returns The requested regular_bg_ptr.

regular_bg_ptr bn::regular_bg_item::create_bg(const fixed_point& position) const

Creates a regular_bg_ptr using the information contained in this item.

Parameters
position Position of the regular background.
Returns The requested regular_bg_ptr.

optional<regular_bg_ptr> bn::regular_bg_item::create_bg_optional(fixed x, fixed y) const

Creates a regular_bg_ptr using the information contained in this item.

Parameters
x Horizontal position of the regular background.
y Vertical position of the regular background.
Returns The requested regular_bg_ptr if it could be allocated; bn::nullopt otherwise.

optional<regular_bg_ptr> bn::regular_bg_item::create_bg_optional(const fixed_point& position) const

Creates a regular_bg_ptr using the information contained in this item.

Parameters
position Position of the regular background.
Returns The requested regular_bg_ptr if it could be allocated; bn::nullopt otherwise.

optional<regular_bg_map_ptr> bn::regular_bg_item::find_map() const

Searches for a regular_bg_map_ptr which references the information provided by this item.

Returns regular_bg_map_ptr which references the information provided by this item if it has been found; bn::nullopt otherwise.

regular_bg_map_ptr bn::regular_bg_item::create_map() const

Searches for a regular_bg_map_ptr which references the information provided by this item. If it is not found, it creates a regular_bg_map_ptr which references it.

Returns regular_bg_map_ptr which references the information provided by this item if it has been found; otherwise it returns a regular_bg_map_ptr which references it.

The map cells are not copied but referenced, so they should outlive the regular_bg_map_ptr to avoid dangling references.

regular_bg_map_ptr bn::regular_bg_item::create_new_map() const

Creates a regular_bg_map_ptr which references the information provided by this item.

Returns regular_bg_map_ptr which references the information provided by this item.

The map system does not support multiple regular_bg_map_ptr items referencing to the same map cells. If you are not sure if the information provided by this item is already referenced or not, you should use the create_map method instead.

The map cells are not copied but referenced, so they should outlive the regular_bg_map_ptr to avoid dangling references.

optional<regular_bg_map_ptr> bn::regular_bg_item::create_map_optional() const

Searches for a regular_bg_map_ptr which references the information provided by this item. If it is not found, it creates a regular_bg_map_ptr which references it.

Returns regular_bg_map_ptr which references the information provided by this item if it has been found; otherwise it returns a regular_bg_map_ptr which references it if it could be allocated; bn::nullopt otherwise.

The map cells are not copied but referenced, so they should outlive the regular_bg_map_ptr to avoid dangling references.

optional<regular_bg_map_ptr> bn::regular_bg_item::create_new_map_optional() const

Creates a regular_bg_map_ptr which references the information provided by this item.

Returns regular_bg_map_ptr which references the information provided by this item if the regular_bg_map_ptr can be allocated; bn::nullopt otherwise.

The map system does not support multiple regular_bg_map_ptr items referencing to the same map cells. If you are not sure if the information provided by this item is already referenced or not, you should use the create_map_optional method instead.

The map cells are not copied but referenced, so they should outlive the regular_bg_map_ptr to avoid dangling references.