yaze 0.2.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::gfx::Tilesheet Class Reference

Represents a tilesheet, which is a collection of tiles stored in a bitmap. More...

#include <tilesheet.h>

Collaboration diagram for yaze::gfx::Tilesheet:

Public Member Functions

 Tilesheet ()=default
 
 Tilesheet (std::shared_ptr< Bitmap > bitmap, int tileWidth, int tileHeight, TileType tile_type)
 
void Init (int width, int height, TileType tile_type)
 
void ComposeTile16 (const std::vector< uint8_t > &graphics_buffer, const TileInfo &top_left, const TileInfo &top_right, const TileInfo &bottom_left, const TileInfo &bottom_right, int sheet_offset=0)
 
void ModifyTile16 (const std::vector< uint8_t > &graphics_buffer, const TileInfo &top_left, const TileInfo &top_right, const TileInfo &bottom_left, const TileInfo &bottom_right, int tile_id, int sheet_offset=0)
 
void ComposeAndPlaceTilePart (const std::vector< uint8_t > &graphics_buffer, const TileInfo &tile_info, int baseX, int baseY)
 
Bitmap GetTile (int tileX, int tileY, int bmp_width, int bmp_height)
 
Bitmap GetTile16 (int tile_id)
 
void CopyTile (int srcX, int srcY, int destX, int destY, bool mirror_x=false, bool mirror_y=false)
 
auto bitmap () const
 
auto mutable_bitmap ()
 
auto num_tiles () const
 
auto tile_width () const
 
auto tile_height () const
 
auto set_palette (gfx::SnesPalette &palette)
 
auto palette () const
 
auto tile_type () const
 
auto tile_info () const
 
auto mutable_tile_info ()
 
void clear ()
 

Private Member Functions

int CalculateTileIndex (int x, int y)
 
std::vector< uint8_t > FetchTileDataFromGraphicsBuffer (const std::vector< uint8_t > &graphics_buffer, int tile_id)
 
void MirrorTileDataVertically (std::vector< uint8_t > &tileData)
 
void MirrorTileDataHorizontally (std::vector< uint8_t > &tileData)
 
void MirrorTileData (std::vector< uint8_t > &tileData, bool mirror_x, bool mirror_y)
 
void WriteTile (int x, int y, const std::vector< uint8_t > &tileData)
 

Private Attributes

int num_tiles_ = 0
 
int tile_width_ = 0
 
int tile_height_ = 0
 
int sheet_offset_ = 0
 
TileType tile_type_
 
SnesPalette palette_
 
std::vector< uint8_t > internal_data_
 
std::vector< InternalTile16tile_info_
 
std::shared_ptr< Bitmapbitmap_
 

Detailed Description

Represents a tilesheet, which is a collection of tiles stored in a bitmap.

The Tilesheet class provides methods to manipulate and extract tiles from the tilesheet. It also supports copying and mirroring tiles within the tilesheet.

Definition at line 28 of file tilesheet.h.

Constructor & Destructor Documentation

◆ Tilesheet() [1/2]

yaze::gfx::Tilesheet::Tilesheet ( )
default

◆ Tilesheet() [2/2]

yaze::gfx::Tilesheet::Tilesheet ( std::shared_ptr< Bitmap > bitmap,
int tileWidth,
int tileHeight,
TileType tile_type )
inline

Definition at line 31 of file tilesheet.h.

References bitmap(), bitmap_, tile_height_, tile_type(), tile_type_, and tile_width_.

Here is the call graph for this function:

Member Function Documentation

◆ Init()

void yaze::gfx::Tilesheet::Init ( int width,
int height,
TileType tile_type )

Definition at line 46 of file tilesheet.cc.

References bitmap_, internal_data_, yaze::gfx::Tile8, tile_height_, tile_type(), tile_type_, and tile_width_.

Referenced by yaze::gfx::CreateTilesheetFromGraphicsBuffer().

Here is the call graph for this function:

◆ ComposeTile16()

void yaze::gfx::Tilesheet::ComposeTile16 ( const std::vector< uint8_t > & graphics_buffer,
const TileInfo & top_left,
const TileInfo & top_right,
const TileInfo & bottom_left,
const TileInfo & bottom_right,
int sheet_offset = 0 )

Definition at line 59 of file tilesheet.cc.

References bitmap_, ComposeAndPlaceTilePart(), num_tiles_, sheet_offset_, tile_height_, tile_info_, and tile_width_.

Here is the call graph for this function:

◆ ModifyTile16()

void yaze::gfx::Tilesheet::ModifyTile16 ( const std::vector< uint8_t > & graphics_buffer,
const TileInfo & top_left,
const TileInfo & top_right,
const TileInfo & bottom_left,
const TileInfo & bottom_right,
int tile_id,
int sheet_offset = 0 )

Definition at line 84 of file tilesheet.cc.

References bitmap_, ComposeAndPlaceTilePart(), sheet_offset_, tile_height_, tile_info_, and tile_width_.

Here is the call graph for this function:

◆ ComposeAndPlaceTilePart()

void yaze::gfx::Tilesheet::ComposeAndPlaceTilePart ( const std::vector< uint8_t > & graphics_buffer,
const TileInfo & tile_info,
int baseX,
int baseY )

Definition at line 108 of file tilesheet.cc.

References bitmap_, FetchTileDataFromGraphicsBuffer(), internal_data_, MirrorTileDataHorizontally(), MirrorTileDataVertically(), and tile_info().

Referenced by ComposeTile16(), and ModifyTile16().

Here is the call graph for this function:

◆ GetTile()

Bitmap yaze::gfx::Tilesheet::GetTile ( int tileX,
int tileY,
int bmp_width,
int bmp_height )
inline

Definition at line 53 of file tilesheet.h.

References bitmap_, CalculateTileIndex(), tile_height_, and tile_width_.

Referenced by CopyTile().

Here is the call graph for this function:

◆ GetTile16()

Bitmap yaze::gfx::Tilesheet::GetTile16 ( int tile_id)
inline

Definition at line 61 of file tilesheet.h.

References bitmap_, tile_height_, and tile_width_.

◆ CopyTile()

void yaze::gfx::Tilesheet::CopyTile ( int srcX,
int srcY,
int destX,
int destY,
bool mirror_x = false,
bool mirror_y = false )
inline

Definition at line 72 of file tilesheet.h.

References GetTile(), MirrorTileData(), tile_height_, tile_width_, and WriteTile().

Here is the call graph for this function:

◆ bitmap()

auto yaze::gfx::Tilesheet::bitmap ( ) const
inline

Definition at line 80 of file tilesheet.h.

References bitmap_.

Referenced by Tilesheet().

◆ mutable_bitmap()

auto yaze::gfx::Tilesheet::mutable_bitmap ( )
inline

Definition at line 81 of file tilesheet.h.

References bitmap_.

Referenced by yaze::gfx::CreateTilesheetFromGraphicsBuffer().

◆ num_tiles()

auto yaze::gfx::Tilesheet::num_tiles ( ) const
inline

Definition at line 82 of file tilesheet.h.

References num_tiles_.

◆ tile_width()

auto yaze::gfx::Tilesheet::tile_width ( ) const
inline

Definition at line 83 of file tilesheet.h.

References tile_width_.

Referenced by FetchTileDataFromGraphicsBuffer().

◆ tile_height()

auto yaze::gfx::Tilesheet::tile_height ( ) const
inline

Definition at line 84 of file tilesheet.h.

References tile_height_.

Referenced by FetchTileDataFromGraphicsBuffer().

◆ set_palette()

auto yaze::gfx::Tilesheet::set_palette ( gfx::SnesPalette & palette)
inline

Definition at line 85 of file tilesheet.h.

References palette(), and palette_.

Here is the call graph for this function:

◆ palette()

auto yaze::gfx::Tilesheet::palette ( ) const
inline

Definition at line 86 of file tilesheet.h.

References palette_.

Referenced by set_palette().

◆ tile_type()

auto yaze::gfx::Tilesheet::tile_type ( ) const
inline

Definition at line 87 of file tilesheet.h.

References tile_type_.

Referenced by Init(), and Tilesheet().

◆ tile_info()

auto yaze::gfx::Tilesheet::tile_info ( ) const
inline

Definition at line 88 of file tilesheet.h.

References tile_info_.

Referenced by ComposeAndPlaceTilePart().

◆ mutable_tile_info()

auto yaze::gfx::Tilesheet::mutable_tile_info ( )
inline

Definition at line 89 of file tilesheet.h.

References tile_info_.

◆ clear()

void yaze::gfx::Tilesheet::clear ( )
inline

Definition at line 90 of file tilesheet.h.

References bitmap_, internal_data_, num_tiles_, palette_, and tile_info_.

Referenced by yaze::zelda3::LoadDungeonMapGfxFromBinary().

◆ CalculateTileIndex()

int yaze::gfx::Tilesheet::CalculateTileIndex ( int x,
int y )
inlineprivate

Definition at line 99 of file tilesheet.h.

References bitmap_, and tile_width_.

Referenced by GetTile(), and WriteTile().

◆ FetchTileDataFromGraphicsBuffer()

std::vector< uint8_t > yaze::gfx::Tilesheet::FetchTileDataFromGraphicsBuffer ( const std::vector< uint8_t > & graphics_buffer,
int tile_id )
private

Definition at line 135 of file tilesheet.cc.

References sheet_offset_, tile_height(), and tile_width().

Referenced by ComposeAndPlaceTilePart().

Here is the call graph for this function:

◆ MirrorTileDataVertically()

void yaze::gfx::Tilesheet::MirrorTileDataVertically ( std::vector< uint8_t > & tileData)
private

Definition at line 173 of file tilesheet.cc.

Referenced by ComposeAndPlaceTilePart(), and MirrorTileData().

◆ MirrorTileDataHorizontally()

void yaze::gfx::Tilesheet::MirrorTileDataHorizontally ( std::vector< uint8_t > & tileData)
private

Definition at line 185 of file tilesheet.cc.

Referenced by ComposeAndPlaceTilePart(), and MirrorTileData().

◆ MirrorTileData()

void yaze::gfx::Tilesheet::MirrorTileData ( std::vector< uint8_t > & tileData,
bool mirror_x,
bool mirror_y )
private

Definition at line 197 of file tilesheet.cc.

References MirrorTileDataHorizontally(), and MirrorTileDataVertically().

Referenced by CopyTile().

Here is the call graph for this function:

◆ WriteTile()

void yaze::gfx::Tilesheet::WriteTile ( int x,
int y,
const std::vector< uint8_t > & tileData )
inlineprivate

Definition at line 111 of file tilesheet.h.

References bitmap_, and CalculateTileIndex().

Referenced by CopyTile().

Here is the call graph for this function:

Member Data Documentation

◆ num_tiles_

int yaze::gfx::Tilesheet::num_tiles_ = 0
private

Definition at line 118 of file tilesheet.h.

Referenced by clear(), ComposeTile16(), and num_tiles().

◆ tile_width_

int yaze::gfx::Tilesheet::tile_width_ = 0
private

◆ tile_height_

int yaze::gfx::Tilesheet::tile_height_ = 0
private

◆ sheet_offset_

int yaze::gfx::Tilesheet::sheet_offset_ = 0
private

Definition at line 121 of file tilesheet.h.

Referenced by ComposeTile16(), FetchTileDataFromGraphicsBuffer(), and ModifyTile16().

◆ tile_type_

TileType yaze::gfx::Tilesheet::tile_type_
private

Definition at line 123 of file tilesheet.h.

Referenced by Init(), tile_type(), and Tilesheet().

◆ palette_

SnesPalette yaze::gfx::Tilesheet::palette_
private

Definition at line 124 of file tilesheet.h.

Referenced by clear(), palette(), and set_palette().

◆ internal_data_

std::vector<uint8_t> yaze::gfx::Tilesheet::internal_data_
private

Definition at line 125 of file tilesheet.h.

Referenced by clear(), ComposeAndPlaceTilePart(), and Init().

◆ tile_info_

std::vector<InternalTile16> yaze::gfx::Tilesheet::tile_info_
private

Definition at line 126 of file tilesheet.h.

Referenced by clear(), ComposeTile16(), ModifyTile16(), mutable_tile_info(), and tile_info().

◆ bitmap_

std::shared_ptr<Bitmap> yaze::gfx::Tilesheet::bitmap_
private

The documentation for this class was generated from the following files: