bn::affine_bg_item class

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

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

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

Constructors, destructors, conversion operators

affine_bg_item(const span<const tile>& tiles_ref, const span<const color>& colors_ref, const affine_bg_map_cell& map_cells_ref, const size& map_dimensions) constexpr
Constructor.
affine_bg_item(const affine_bg_tiles_item& tiles_item, const bg_palette_item& palette_item, const affine_bg_map_item& map_item) constexpr
Constructor.

Public functions

auto tiles_item() const -> const affine_bg_tiles_item& constexpr
Returns the item used to create the tiles of the output affine backgrounds.
auto palette_item() const -> const bg_palette_item& constexpr
Returns the item used to create the color palette of the output affine backgrounds.
auto map_item() const -> const affine_bg_map_item& constexpr
Returns the item used to create the map of the output affine backgrounds.
auto big() const -> bool constexpr
Indicates if backgrounds generated with this item are big or not.
auto decompress(span<tile> decompressed_tiles_ref, span<color> decompressed_colors_ref, span<affine_bg_map_cell> decompressed_cells_ref) const -> affine_bg_item
Decompresses the stored data in the tiles referenced by decompressed_tiles_ref, the colors referenced by decompressed_colors_ref and the map cells referenced by decompressed_cells_ref.
auto create_bg(fixed x, fixed y) const -> affine_bg_ptr
Creates an affine_bg_ptr using the information contained in this item.
auto create_bg(fixed x, fixed y, int map_index) const -> affine_bg_ptr
Creates an affine_bg_ptr using the information contained in this item.
auto create_bg(const fixed_point& position) const -> affine_bg_ptr
Creates an affine_bg_ptr using the information contained in this item.
auto create_bg(const fixed_point& position, int map_index) const -> affine_bg_ptr
Creates an affine_bg_ptr using the information contained in this item.
auto create_bg_optional(fixed x, fixed y) const -> optional<affine_bg_ptr>
Creates an affine_bg_ptr using the information contained in this item.
auto create_bg_optional(fixed x, fixed y, int map_index) const -> optional<affine_bg_ptr>
Creates an affine_bg_ptr using the information contained in this item.
auto create_bg_optional(const fixed_point& position) const -> optional<affine_bg_ptr>
Creates an affine_bg_ptr using the information contained in this item.
auto create_bg_optional(const fixed_point& position, int map_index) const -> optional<affine_bg_ptr>
Creates an affine_bg_ptr using the information contained in this item.
auto find_map() const -> optional<affine_bg_map_ptr>
Searches for an affine_bg_map_ptr which references the information provided by this item.
auto find_map(int map_index) const -> optional<affine_bg_map_ptr>
Searches for an affine_bg_map_ptr which references the information provided by this item.
auto create_map() const -> affine_bg_map_ptr
Searches for an affine_bg_map_ptr which references the information provided by this item. If it is not found, it creates an affine_bg_map_ptr which references it.
auto create_map(int map_index) const -> affine_bg_map_ptr
Searches for an affine_bg_map_ptr which references the information provided by this item. If it is not found, it creates an affine_bg_map_ptr which references it.
auto create_new_map() const -> affine_bg_map_ptr
Creates an affine_bg_map_ptr which references the information provided by this item.
auto create_new_map(int map_index) const -> affine_bg_map_ptr
Creates an affine_bg_map_ptr which references the information provided by this item.
auto create_map_optional() const -> optional<affine_bg_map_ptr>
Searches for an affine_bg_map_ptr which references the information provided by this item. If it is not found, it creates an affine_bg_map_ptr which references it.
auto create_map_optional(int map_index) const -> optional<affine_bg_map_ptr>
Searches for an affine_bg_map_ptr which references the information provided by this item. If it is not found, it creates an affine_bg_map_ptr which references it.
auto create_new_map_optional() const -> optional<affine_bg_map_ptr>
Creates an affine_bg_map_ptr which references the information provided by this item.
auto create_new_map_optional(int map_index) const -> optional<affine_bg_map_ptr>
Creates an affine_bg_map_ptr which references the information provided by this item.

Friends

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

Function documentation

bn::affine_bg_item::affine_bg_item(const span<const tile>& tiles_ref, const span<const color>& colors_ref, const affine_bg_map_cell& map_cells_ref, const size& map_dimensions) constexpr

Constructor.

Parameters
tiles_ref Reference to affine background tiles.
colors_ref Reference to an array of multiples of 16 colors.
map_cells_ref affine 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 affine_bg_item to avoid dangling references.

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

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

bn::affine_bg_item::affine_bg_item(const affine_bg_tiles_item& tiles_item, const bg_palette_item& palette_item, const affine_bg_map_item& map_item) constexpr

Constructor.

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

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

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

Big backgrounds are slower CPU wise, but can have any width or height multiple of 256 pixels.

affine_bg_item bn::affine_bg_item::decompress(span<tile> decompressed_tiles_ref, span<color> decompressed_colors_ref, span<affine_bg_map_cell> decompressed_cells_ref) const

Decompresses the stored data in the tiles referenced by decompressed_tiles_ref, the colors referenced by decompressed_colors_ref and the map cells referenced by decompressed_cells_ref.

Parameters
decompressed_tiles_ref Destination of the decompressed tiles.
decompressed_colors_ref Destination of the decompressed colors.
decompressed_cells_ref Destination of the decompressed map cells.
Returns An affine_bg_item pointing to the decompressed tiles, colors and map cells.

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

affine_bg_ptr bn::affine_bg_item::create_bg(fixed x, fixed y) const

Creates an affine_bg_ptr using the information contained in this item.

Parameters
x Horizontal position of the affine background.
y Vertical position of the affine background.
Returns The requested affine_bg_ptr.

affine_bg_ptr bn::affine_bg_item::create_bg(fixed x, fixed y, int map_index) const

Creates an affine_bg_ptr using the information contained in this item.

Parameters
x Horizontal position of the affine background.
y Vertical position of the affine background.
map_index Index of the map to reference in map_item().
Returns The requested affine_bg_ptr.

affine_bg_ptr bn::affine_bg_item::create_bg(const fixed_point& position) const

Creates an affine_bg_ptr using the information contained in this item.

Parameters
position Position of the affine background.
Returns The requested affine_bg_ptr.

affine_bg_ptr bn::affine_bg_item::create_bg(const fixed_point& position, int map_index) const

Creates an affine_bg_ptr using the information contained in this item.

Parameters
position Position of the affine background.
map_index Index of the map to reference in map_item().
Returns The requested affine_bg_ptr.

optional<affine_bg_ptr> bn::affine_bg_item::create_bg_optional(fixed x, fixed y) const

Creates an affine_bg_ptr using the information contained in this item.

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

optional<affine_bg_ptr> bn::affine_bg_item::create_bg_optional(fixed x, fixed y, int map_index) const

Creates an affine_bg_ptr using the information contained in this item.

Parameters
x Horizontal position of the affine background.
y Vertical position of the affine background.
map_index Index of the map to reference in map_item().
Returns The requested affine_bg_ptr if it could be allocated; bn::nullopt otherwise.

optional<affine_bg_ptr> bn::affine_bg_item::create_bg_optional(const fixed_point& position) const

Creates an affine_bg_ptr using the information contained in this item.

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

optional<affine_bg_ptr> bn::affine_bg_item::create_bg_optional(const fixed_point& position, int map_index) const

Creates an affine_bg_ptr using the information contained in this item.

Parameters
position Position of the affine background.
map_index Index of the map to reference in map_item().
Returns The requested affine_bg_ptr if it could be allocated; bn::nullopt otherwise.

optional<affine_bg_map_ptr> bn::affine_bg_item::find_map() const

Searches for an affine_bg_map_ptr which references the information provided by this item.

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

optional<affine_bg_map_ptr> bn::affine_bg_item::find_map(int map_index) const

Searches for an affine_bg_map_ptr which references the information provided by this item.

Parameters
map_index Index of the referenced map to search.
Returns affine_bg_map_ptr which references the information provided by this item if it has been found; bn::nullopt otherwise.

affine_bg_map_ptr bn::affine_bg_item::create_map() const

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

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

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

affine_bg_map_ptr bn::affine_bg_item::create_map(int map_index) const

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

Parameters
map_index Index of the referenced map to search or handle.
Returns affine_bg_map_ptr which references the information provided by this item if it has been found; otherwise it returns an affine_bg_map_ptr which references it.

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

affine_bg_map_ptr bn::affine_bg_item::create_new_map() const

Creates an affine_bg_map_ptr which references the information provided by this item.

Returns affine_bg_map_ptr which references the information provided by this item.

The map system does not support multiple affine_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 affine_bg_map_ptr to avoid dangling references.

affine_bg_map_ptr bn::affine_bg_item::create_new_map(int map_index) const

Creates an affine_bg_map_ptr which references the information provided by this item.

Parameters
map_index Index of the referenced map to handle.
Returns affine_bg_map_ptr which references the information provided by this item.

The map system does not support multiple affine_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 affine_bg_map_ptr to avoid dangling references.

optional<affine_bg_map_ptr> bn::affine_bg_item::create_map_optional() const

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

Returns affine_bg_map_ptr which references the information provided by this item if it has been found; otherwise it returns an affine_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 affine_bg_map_ptr to avoid dangling references.

optional<affine_bg_map_ptr> bn::affine_bg_item::create_map_optional(int map_index) const

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

Parameters
map_index Index of the referenced map to search or handle.
Returns affine_bg_map_ptr which references the information provided by this item if it has been found; otherwise it returns an affine_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 affine_bg_map_ptr to avoid dangling references.

optional<affine_bg_map_ptr> bn::affine_bg_item::create_new_map_optional() const

Creates an affine_bg_map_ptr which references the information provided by this item.

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

The map system does not support multiple affine_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 affine_bg_map_ptr to avoid dangling references.

optional<affine_bg_map_ptr> bn::affine_bg_item::create_new_map_optional(int map_index) const

Creates an affine_bg_map_ptr which references the information provided by this item.

Parameters
map_index Index of the referenced map to handle.
Returns affine_bg_map_ptr which references the information provided by this item if the affine_bg_map_ptr can be allocated; bn::nullopt otherwise.

The map system does not support multiple affine_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 affine_bg_map_ptr to avoid dangling references.