1#ifndef YAZE_ZELDA3_DUNGEON_DRAW_ROUTINES_DRAW_ROUTINE_TYPES_H
2#define YAZE_ZELDA3_DUNGEON_DRAW_ROUTINES_DRAW_ROUTINE_TYPES_H
6#include <initializer_list>
18class CustomObjectRenderSnapshot;
31 std::span<const gfx::TileInfo>
tiles;
91namespace DrawRoutineUtils {
102 return bg.
GetTileAt(tile_x, tile_y) & 0x03FF;
107 std::initializer_list<uint16_t> tile_ids) {
108 const uint16_t existing_tile_id =
TileIdAt(bg, tile_x, tile_y);
109 for (
const uint16_t tile_id : tile_ids) {
110 if (existing_tile_id == tile_id) {
120 const auto& bitmap = bg.
bitmap();
121 if (coverage.empty() || bitmap.width() <= 0 || bitmap.height() <= 0) {
125 const int start_x = tile_x * 8;
126 const int start_y = tile_y * 8;
127 if (start_x < 0 || start_y < 0 || start_x >= bitmap.width() ||
128 start_y >= bitmap.height()) {
135 const size_t index =
static_cast<size_t>(start_y * bitmap.width() + start_x);
136 return index < coverage.size() && coverage[index] != 0;
141 std::initializer_list<uint16_t> tile_ids) {
154 return tile_x >= 0 && tile_x < DrawContext::kMaxTilesX && tile_y >= 0 &&
173 std::span<const gfx::TileInfo> tiles,
int offset = 0);
179 std::span<const gfx::TileInfo> tiles,
int offset = 0);
185 std::span<const gfx::TileInfo> tiles,
int offset = 0);
191 std::span<const gfx::TileInfo> tiles,
int offset = 0);
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
const std::vector< uint8_t > & coverage_data() const
uint16_t GetTileAt(int x, int y) const
SNES 16-bit tile metadata container.
Interface for accessing dungeon game state.
void DrawBlock2x2(gfx::BackgroundBuffer &bg, int tile_x, int tile_y, std::span< const gfx::TileInfo > tiles, int offset)
Draw a 2x2 block of tiles (16x16 pixels)
bool TileHasObjectCoverage(const gfx::BackgroundBuffer &bg, int tile_x, int tile_y)
void DrawBlock2x4(gfx::BackgroundBuffer &bg, int tile_x, int tile_y, std::span< const gfx::TileInfo > tiles, int offset)
Draw a 2x4 block of tiles (16x32 pixels)
void SetTraceHook(TraceHookFn hook, void *user_data, bool trace_only)
void DrawBlock4x2(gfx::BackgroundBuffer &bg, int tile_x, int tile_y, std::span< const gfx::TileInfo > tiles, int offset)
Draw a 4x2 block of tiles (32x16 pixels)
uint16_t TileIdAt(const gfx::BackgroundBuffer &bg, int tile_x, int tile_y)
bool ExistingTileMatchesAny(const gfx::BackgroundBuffer &bg, int tile_x, int tile_y, std::initializer_list< uint16_t > tile_ids)
bool IsValidTilePosition(int tile_x, int tile_y)
Check if tile position is within canvas bounds.
void(*)(gfx::BackgroundBuffer *bg, int tile_x, int tile_y, const gfx::TileInfo &tile_info, void *user_data) TraceHookFn
void WriteTile8(gfx::BackgroundBuffer &bg, int tile_x, int tile_y, const gfx::TileInfo &tile_info)
Write an 8x8 tile to the background buffer.
void DrawBlock4x4(gfx::BackgroundBuffer &bg, int tile_x, int tile_y, std::span< const gfx::TileInfo > tiles, int offset)
Draw a 4x4 block of tiles (32x32 pixels)
std::function< void(const DrawContext &ctx)> DrawRoutineFn
Function signature for a draw routine.
Context passed to draw routines containing all necessary state.
static constexpr int kMaxTilesY
std::span< const gfx::TileInfo > tiles
gfx::BackgroundBuffer & target_bg
bool HasSecondaryBG() const
const CustomObjectRenderSnapshot * custom_objects
const gfx::BackgroundBuffer * target_layout_bg
const RoomObject & object
static constexpr int kMaxTilesX
gfx::BackgroundBuffer * secondary_bg
const uint8_t * room_gfx_buffer
const DungeonState * state
Metadata about a draw routine.