11 : sprite_gfx_(sprite_gfx_buffer) {}
18 std::fill(data.begin(), data.end(), 0);
33 int dest_x = origin_x + signed_x;
34 int dest_y = origin_y + signed_y;
48 int origin_x,
int origin_y) {
51 for (
auto it = frame.
Tiles.rbegin(); it != frame.
Tiles.rend(); ++it) {
73 int src_index = base_y + (py *
kRowStride) + base_x + px;
76 if (src_index >= 0x10000)
83 int y,
bool flip_x,
bool flip_y,
92 uint8_t palette_offset = (palette & 0x07) * 16;
95 int src_py = flip_y ? (
kTileSize - 1 - py) : py;
98 int src_px = flip_x ? (
kTileSize - 1 - px) : px;
107 if (dest_x >= 0 && dest_x < bitmap.
width() && dest_y >= 0 &&
108 dest_y < bitmap.
height()) {
109 int dest_index = dest_y * bitmap.
width() + dest_x;
110 if (dest_index >= 0 &&
111 dest_index <
static_cast<int>(bitmap.
mutable_data().size())) {
114 bitmap.
mutable_data()[dest_index] = pixel + palette_offset;
123 int y,
bool flip_x,
bool flip_y,
141 uint16_t tl = tile_id;
142 uint16_t tr = tile_id + 1;
143 uint16_t bl = tile_id + 16;
144 uint16_t br = tile_id + 17;
157 DrawTile8x8(bitmap, tl, x, y, flip_x, flip_y, palette);
158 DrawTile8x8(bitmap, tr, x + 8, y, flip_x, flip_y, palette);
159 DrawTile8x8(bitmap, bl, x, y + 8, flip_x, flip_y, palette);
160 DrawTile8x8(bitmap, br, x + 8, y + 8, flip_x, flip_y, palette);
const uint8_t * sprite_gfx_
void ClearBitmap(gfx::Bitmap &bitmap)
Clear the bitmap with transparent color.
uint8_t GetTilePixel(uint16_t tile_id, int px, int py) const
Get pixel value from graphics buffer.
void DrawFrame(gfx::Bitmap &bitmap, const zsprite::Frame &frame, int origin_x, int origin_y)
Draw all tiles in a ZSM frame.
static constexpr int kRowStride
static constexpr int kTileRowSize
void DrawOamTile(gfx::Bitmap &bitmap, const zsprite::OamTile &tile, int origin_x, int origin_y)
Draw a single ZSM OAM tile to bitmap.
static constexpr int kMaxTileId
static constexpr int kTilesPerRow
void DrawTile16x16(gfx::Bitmap &bitmap, uint16_t tile_id, int x, int y, bool flip_x, bool flip_y, uint8_t palette)
Draw a 16x16 tile (4 8x8 tiles) to bitmap.
static constexpr int kTileSize
void DrawTile8x8(gfx::Bitmap &bitmap, uint16_t tile_id, int x, int y, bool flip_x, bool flip_y, uint8_t palette)
Draw an 8x8 tile to bitmap.
SpriteDrawer(const uint8_t *sprite_gfx_buffer=nullptr)
Construct a SpriteDrawer with graphics buffer.
Represents a bitmap image optimized for SNES ROM hacking.
std::vector< uint8_t > & mutable_data()
int OffsetX(const zsprite::OamTile &tile)
int OffsetY(const zsprite::OamTile &tile)
std::vector< OamTile > Tiles