Add ModifyTile16 function to handle composition of Tile16 graphics and update tile information management
This commit is contained in:
@@ -84,6 +84,30 @@ void Tilesheet::ComposeTile16(const std::vector<uint8_t>& graphics_buffer,
|
|||||||
num_tiles_++;
|
num_tiles_++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void 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) {
|
||||||
|
sheet_offset_ = sheet_offset;
|
||||||
|
// Calculate the base position for this Tile16 in the full-size bitmap
|
||||||
|
int tiles_per_row = bitmap_->width() / tile_width_;
|
||||||
|
int tile16_row = tile_id / tiles_per_row;
|
||||||
|
int tile16_column = tile_id % tiles_per_row;
|
||||||
|
int base_x = tile16_column * tile_width_;
|
||||||
|
int base_y = tile16_row * tile_height_;
|
||||||
|
|
||||||
|
// Compose and place each part of the Tile16
|
||||||
|
ComposeAndPlaceTilePart(graphics_buffer, top_left, base_x, base_y);
|
||||||
|
ComposeAndPlaceTilePart(graphics_buffer, top_right, base_x + 8, base_y);
|
||||||
|
ComposeAndPlaceTilePart(graphics_buffer, bottom_left, base_x, base_y + 8);
|
||||||
|
ComposeAndPlaceTilePart(graphics_buffer, bottom_right, base_x + 8,
|
||||||
|
base_y + 8);
|
||||||
|
|
||||||
|
tile_info_[tile_id] = {top_left, top_right, bottom_left, bottom_right};
|
||||||
|
}
|
||||||
|
|
||||||
void Tilesheet::ComposeAndPlaceTilePart(
|
void Tilesheet::ComposeAndPlaceTilePart(
|
||||||
const std::vector<uint8_t>& graphics_buffer, const TileInfo& tile_info,
|
const std::vector<uint8_t>& graphics_buffer, const TileInfo& tile_info,
|
||||||
int base_x, int base_y) {
|
int base_x, int base_y) {
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ namespace gfx {
|
|||||||
|
|
||||||
enum class TileType { Tile8, Tile16 };
|
enum class TileType { Tile8, Tile16 };
|
||||||
|
|
||||||
|
struct InternalTile16 {
|
||||||
|
std::array<TileInfo, 4> tiles;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class Tilesheet
|
* @class Tilesheet
|
||||||
* @brief Represents a tilesheet, which is a collection of tiles stored in a
|
* @brief Represents a tilesheet, which is a collection of tiles stored in a
|
||||||
@@ -39,6 +43,10 @@ class Tilesheet {
|
|||||||
const TileInfo& top_left, const TileInfo& top_right,
|
const TileInfo& top_left, const TileInfo& top_right,
|
||||||
const TileInfo& bottom_left, const TileInfo& bottom_right,
|
const TileInfo& bottom_left, const TileInfo& bottom_right,
|
||||||
int sheet_offset = 0);
|
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,
|
void ComposeAndPlaceTilePart(const std::vector<uint8_t>& graphics_buffer,
|
||||||
const TileInfo& tile_info, int baseX, int baseY);
|
const TileInfo& tile_info, int baseX, int baseY);
|
||||||
@@ -113,18 +121,16 @@ class Tilesheet {
|
|||||||
tileDataOffset);
|
tileDataOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::SnesPalette palette_;
|
|
||||||
std::vector<uint8_t> internal_data_;
|
|
||||||
std::shared_ptr<Bitmap> bitmap_;
|
|
||||||
struct InternalTile16 {
|
|
||||||
std::array<TileInfo, 4> tiles;
|
|
||||||
};
|
|
||||||
std::vector<InternalTile16> tile_info_;
|
|
||||||
int num_tiles_ = 0;
|
int num_tiles_ = 0;
|
||||||
int tile_width_ = 0;
|
int tile_width_ = 0;
|
||||||
int tile_height_ = 0;
|
int tile_height_ = 0;
|
||||||
int sheet_offset_ = 0;
|
int sheet_offset_ = 0;
|
||||||
|
|
||||||
TileType tile_type_;
|
TileType tile_type_;
|
||||||
|
SnesPalette palette_;
|
||||||
|
std::vector<uint8_t> internal_data_;
|
||||||
|
std::vector<InternalTile16> tile_info_;
|
||||||
|
std::shared_ptr<Bitmap> bitmap_;
|
||||||
};
|
};
|
||||||
|
|
||||||
absl::StatusOr<Tilesheet> CreateTilesheetFromGraphicsBuffer(
|
absl::StatusOr<Tilesheet> CreateTilesheetFromGraphicsBuffer(
|
||||||
|
|||||||
Reference in New Issue
Block a user