yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
sprite_drawer.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_SPRITE_SPRITE_DRAWER_H
2#define YAZE_APP_EDITOR_SPRITE_SPRITE_DRAWER_H
3
4#include <cstdint>
5#include <vector>
6
10
11namespace yaze {
12namespace editor {
13
28 public:
33 explicit SpriteDrawer(const uint8_t* sprite_gfx_buffer = nullptr);
34
39 void SetGraphicsBuffer(const uint8_t* buffer) { sprite_gfx_ = buffer; }
40
45 void SetPalettes(const gfx::PaletteGroup* palettes) {
46 sprite_palettes_ = palettes;
47 }
48
56 void DrawOamTile(gfx::Bitmap& bitmap, const zsprite::OamTile& tile,
57 int origin_x, int origin_y);
58
66 void DrawFrame(gfx::Bitmap& bitmap, const zsprite::Frame& frame,
67 int origin_x, int origin_y);
68
73 void ClearBitmap(gfx::Bitmap& bitmap);
74
79 bool IsReady() const { return sprite_gfx_ != nullptr; }
80
81 private:
92 void DrawTile8x8(gfx::Bitmap& bitmap, uint16_t tile_id, int x, int y,
93 bool flip_x, bool flip_y, uint8_t palette);
94
109 void DrawTile16x16(gfx::Bitmap& bitmap, uint16_t tile_id, int x, int y,
110 bool flip_x, bool flip_y, uint8_t palette);
111
119 uint8_t GetTilePixel(uint16_t tile_id, int px, int py) const;
120
121 const uint8_t* sprite_gfx_ = nullptr;
123
124 // Graphics buffer layout constants
125 static constexpr int kTilesPerRow = 16;
126 static constexpr int kTileSize = 8;
127 static constexpr int kRowStride = 128; // 16 tiles * 8 pixels
128 static constexpr int kTileRowSize = 1024; // 8 scanlines * 128 bytes
129 static constexpr int kMaxTileId = 1023; // 64 rows * 16 columns - 1
130};
131
132} // namespace editor
133} // namespace yaze
134
135#endif // YAZE_APP_EDITOR_SPRITE_SPRITE_DRAWER_H
Draws sprite OAM tiles to bitmaps for preview rendering.
void SetPalettes(const gfx::PaletteGroup *palettes)
Set the palette group for color mapping.
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
bool IsReady() const
Check if drawer is ready to render.
static constexpr int kTileRowSize
const gfx::PaletteGroup * sprite_palettes_
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 SetGraphicsBuffer(const uint8_t *buffer)
Set the graphics buffer for tile lookup.
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.
Definition bitmap.h:67
Represents a group of palettes.