bn::affine_bg_tiles_ptr class

std::shared_ptr like smart pointer that retains shared ownership of the tiles of an affine background.

Several affine_bg_tiles_ptr objects may own the same background tiles.

The background tiles are released when the last remaining affine_bg_tiles_ptr owning them is destroyed.

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

Public static functions

static auto find(const affine_bg_tiles_item& tiles_item) -> optional<affine_bg_tiles_ptr>
Searches for an affine_bg_tiles_ptr which references the given tiles.
static auto create(const affine_bg_tiles_item& tiles_item) -> affine_bg_tiles_ptr
Searches for an affine_bg_tiles_ptr which references the given tiles. If it is not found, it creates an affine_bg_tiles_ptr which references them.
static auto create_new(const affine_bg_tiles_item& tiles_item) -> affine_bg_tiles_ptr
Creates an affine_bg_tiles_ptr which references the given tiles.
static auto allocate(int tiles_count) -> affine_bg_tiles_ptr
Creates an affine_bg_tiles_ptr which references a chunk of VRAM tiles not visible on the screen.
static auto create_optional(const affine_bg_tiles_item& tiles_item) -> optional<affine_bg_tiles_ptr>
Searches for an affine_bg_tiles_ptr which references the given tiles. If it is not found, it creates an affine_bg_tiles_ptr which references them.
static auto create_new_optional(const affine_bg_tiles_item& tiles_item) -> optional<affine_bg_tiles_ptr>
Creates an affine_bg_tiles_ptr which references the given tiles.
static auto allocate_optional(int tiles_count) -> optional<affine_bg_tiles_ptr>
Creates an affine_bg_tiles_ptr which references a chunk of VRAM tiles not visible on the screen.

Constructors, destructors, conversion operators

affine_bg_tiles_ptr(const affine_bg_tiles_ptr& other)
Copy constructor.
affine_bg_tiles_ptr(affine_bg_tiles_ptr&& other) noexcept
Move constructor.
~affine_bg_tiles_ptr()
Releases the referenced background tiles if no more affine_bg_tiles_ptr objects reference to them.

Public functions

auto operator=(const affine_bg_tiles_ptr& other) -> affine_bg_tiles_ptr&
Copy assignment operator.
auto operator=(affine_bg_tiles_ptr&& other) -> affine_bg_tiles_ptr& noexcept
Move assignment operator.
auto id() const -> int
Returns the internal id.
auto cbb() const -> int
Returns the character base block of the referenced tiles.
auto tiles_count() const -> int
Returns the referenced number of tiles.
auto compression() const -> compression_type
Returns the compression of the referenced tiles.
auto tiles_ref() const -> optional<span<const tile>>
Returns the referenced tiles unless it was created with allocate or allocate_optional. In that case, it returns bn::nullopt.
void set_tiles_ref(const affine_bg_tiles_item& tiles_item)
Sets the tiles to handle.
void reload_tiles_ref()
Uploads the referenced tiles to VRAM again to make visible the possible changes in them.
auto vram() -> optional<span<tile>>
Returns the allocated memory in VRAM if this affine_bg_tiles_ptr was created with allocate or allocate_optional; bn::nullopt otherwise.
auto handle() const -> int
Returns the internal handle.
void swap(affine_bg_tiles_ptr& other)
Exchanges the contents of this affine_bg_tiles_ptr with those of the other one.

Friends

void swap(affine_bg_tiles_ptr& a, affine_bg_tiles_ptr& b)
Exchanges the contents of an affine_bg_tiles_ptr with those of another one.
auto operator==(const affine_bg_tiles_ptr& a, const affine_bg_tiles_ptr& b) -> bool defaulted
Default equal operator.

Function documentation

static optional<affine_bg_tiles_ptr> bn::affine_bg_tiles_ptr::find(const affine_bg_tiles_item& tiles_item)

Searches for an affine_bg_tiles_ptr which references the given tiles.

Parameters
tiles_item affine_bg_tiles_item which references the tiles to search.
Returns affine_bg_tiles_ptr which references tiles_item.graphics_tiles_ref() if it has been found; bn::nullopt otherwise.

static affine_bg_tiles_ptr bn::affine_bg_tiles_ptr::create(const affine_bg_tiles_item& tiles_item)

Searches for an affine_bg_tiles_ptr which references the given tiles. If it is not found, it creates an affine_bg_tiles_ptr which references them.

Parameters
tiles_item affine_bg_tiles_item which references the tiles to search or handle.
Returns affine_bg_tiles_ptr which references tiles_item.graphics_tiles_ref() if it has been found; otherwise it returns an affine_bg_tiles_ptr which references them.

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

static affine_bg_tiles_ptr bn::affine_bg_tiles_ptr::create_new(const affine_bg_tiles_item& tiles_item)

Creates an affine_bg_tiles_ptr which references the given tiles.

Parameters
tiles_item affine_bg_tiles_item which references the tiles to handle.
Returns affine_bg_tiles_ptr which references tiles_item.graphics_tiles_ref().

The background tiles system does not support multiple affine_bg_tiles_ptr items referencing to the same tiles. If you are not sure if the given tiles are already referenced or not, you should use the static create methods instead.

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

static affine_bg_tiles_ptr bn::affine_bg_tiles_ptr::allocate(int tiles_count)

Creates an affine_bg_tiles_ptr which references a chunk of VRAM tiles not visible on the screen.

Parameters
tiles_count Number of tiles to allocate.
Returns affine_bg_tiles_ptr which references a chunk of VRAM tiles not visible on the screen.

static optional<affine_bg_tiles_ptr> bn::affine_bg_tiles_ptr::create_optional(const affine_bg_tiles_item& tiles_item)

Searches for an affine_bg_tiles_ptr which references the given tiles. If it is not found, it creates an affine_bg_tiles_ptr which references them.

Parameters
tiles_item affine_bg_tiles_item which references the tiles to search or handle.
Returns affine_bg_tiles_ptr which references tiles_item.graphics_tiles_ref() if it has been found; otherwise it returns an affine_bg_tiles_ptr which references them if it could be allocated; bn::nullopt otherwise.

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

static optional<affine_bg_tiles_ptr> bn::affine_bg_tiles_ptr::create_new_optional(const affine_bg_tiles_item& tiles_item)

Creates an affine_bg_tiles_ptr which references the given tiles.

Parameters
tiles_item affine_bg_tiles_item which references the tiles to handle.
Returns affine_bg_tiles_ptr which references tiles_item.graphics_tiles_ref() if it could be allocated; bn::nullopt otherwise.

The background tiles system does not support multiple affine_bg_tiles_ptr items referencing to the same tiles. If you are not sure if the given tiles are already referenced or not, you should use the static create_optional methods instead.

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

static optional<affine_bg_tiles_ptr> bn::affine_bg_tiles_ptr::allocate_optional(int tiles_count)

Creates an affine_bg_tiles_ptr which references a chunk of VRAM tiles not visible on the screen.

Parameters
tiles_count Number of tiles to allocate.
Returns affine_bg_tiles_ptr which references a chunk of VRAM tiles not visible on the screen if it could be allocated; bn::nullopt otherwise.

bn::affine_bg_tiles_ptr::affine_bg_tiles_ptr(const affine_bg_tiles_ptr& other)

Copy constructor.

Parameters
other affine_bg_tiles_ptr to copy.

bn::affine_bg_tiles_ptr::affine_bg_tiles_ptr(affine_bg_tiles_ptr&& other) noexcept

Move constructor.

Parameters
other affine_bg_tiles_ptr to move.

affine_bg_tiles_ptr& bn::affine_bg_tiles_ptr::operator=(const affine_bg_tiles_ptr& other)

Copy assignment operator.

Parameters
other affine_bg_tiles_ptr to copy.
Returns Reference to this.

affine_bg_tiles_ptr& bn::affine_bg_tiles_ptr::operator=(affine_bg_tiles_ptr&& other) noexcept

Move assignment operator.

Parameters
other affine_bg_tiles_ptr to move.
Returns Reference to this.

void bn::affine_bg_tiles_ptr::set_tiles_ref(const affine_bg_tiles_item& tiles_item)

Sets the tiles to handle.

Parameters
tiles_item affine_bg_tiles_item which references the tiles to handle.

Remember that the background tiles system does not support multiple affine_bg_tiles_ptr items referencing to the same tiles.

Remember also that the tiles are not copied but referenced, so they should outlive the affine_bg_tiles_ptr to avoid dangling references.

void bn::affine_bg_tiles_ptr::swap(affine_bg_tiles_ptr& other)

Exchanges the contents of this affine_bg_tiles_ptr with those of the other one.

Parameters
other affine_bg_tiles_ptr to exchange the contents with.

void swap(affine_bg_tiles_ptr& a, affine_bg_tiles_ptr& b)

Exchanges the contents of an affine_bg_tiles_ptr with those of another one.

Parameters
a First affine_bg_tiles_ptr to exchange the contents with.
b Second affine_bg_tiles_ptr to exchange the contents with.