Add BackgroundBuffer class for managing SNES background graphics

Introduce the BackgroundBuffer class to handle tile management and rendering for SNES backgrounds. This includes methods for setting and getting tile values, clearing the buffer, and drawing tiles and backgrounds using provided graphics data. The class is designed to facilitate efficient graphics rendering in the application.
This commit is contained in:
scawful
2025-05-03 23:40:41 -04:00
parent 38b459777d
commit c08386801e
3 changed files with 167 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
#ifndef YAZE_APP_GFX_BACKGROUND_BUFFER_H
#define YAZE_APP_GFX_BACKGROUND_BUFFER_H
#include <cstdint>
#include <vector>
#include "app/gfx/bitmap.h"
#include "app/gfx/snes_tile.h"
namespace yaze {
namespace gfx {
class BackgroundBuffer {
public:
BackgroundBuffer(int width = 512, int height = 512);
// Buffer manipulation methods
void SetTileAt(int x, int y, uint16_t value);
uint16_t GetTileAt(int x, int y) const;
void ClearBuffer();
// Drawing methods
void DrawTile(const TileInfo& tile_info, uint8_t* canvas,
const uint8_t* tiledata, int indexoffset);
void DrawBackground(std::span<uint8_t> gfx16_data);
// Floor drawing methods
void DrawFloor(const std::vector<uint8_t>& rom_data, int tile_address,
int tile_address_floor, uint8_t floor_graphics);
// Accessors
auto buffer() { return buffer_; }
auto& bitmap() { return bitmap_; }
private:
std::vector<uint16_t> buffer_;
gfx::Bitmap bitmap_;
int width_;
int height_;
};
} // namespace gfx
} // namespace yaze
#endif // YAZE_APP_GFX_BACKGROUND_BUFFER_H