1#ifndef YAZE_APP_ZELDA3_DUNGEON_OBJECT_DRAWER_H
2#define YAZE_APP_ZELDA3_DUNGEON_OBJECT_DRAWER_H
5#include <unordered_map>
8#include "absl/status/status.h"
39 const uint8_t* room_gfx_buffer =
nullptr);
108 absl::Status
DrawObjectList(
const std::vector<RoomObject>& objects,
114 bool reset_chest_index =
true);
145 int pixel_x,
int pixel_y,
const uint8_t* tiledata);
164 uint16_t room_draw_object_data_offset,
186 bool trace_only =
false);
198 std::span<const gfx::TileInfo> tiles,
202 std::span<const gfx::TileInfo> tiles,
205 std::span<const gfx::TileInfo> tiles,
208 std::span<const gfx::TileInfo> tiles,
212 std::span<const gfx::TileInfo> tiles,
217 std::span<const gfx::TileInfo> tiles,
int width,
222 std::span<const gfx::TileInfo> tiles,
233 std::span<const gfx::TileInfo> tiles,
256 int pixel_width,
int pixel_height);
260 int start_py,
int pixel_width,
int pixel_height);
264 int width,
int height,
DoorType type,
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Represents a bitmap image optimized for SNES ROM hacking.
SNES 16-bit tile metadata container.
static std::pair< int, int > PositionToTileCoords(uint8_t position, DoorDirection direction)
Convert encoded position to tile coordinates.
Interface for accessing dungeon game state.
Draws dungeon objects to background buffers using game patterns.
int GetDrawRoutineId(int16_t object_id) const
Get draw routine ID for an object.
void WriteTile8(gfx::BackgroundBuffer &bg, int tile_x, int tile_y, const gfx::TileInfo &tile_info)
void DrawTileToBitmap(gfx::Bitmap &bitmap, const gfx::TileInfo &tile_info, int pixel_x, int pixel_y, const uint8_t *tiledata)
Draw a single tile directly to bitmap.
void InitializeDrawRoutines()
Initialize draw routine registry Must be called before drawing objects.
TraceContext trace_context_
void DrawRightwards4x4_1to16(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles, const DungeonState *state=nullptr)
int GetDrawRoutineCount() const
Get the total number of registered draw routines.
std::vector< TileTrace > * trace_collector_
std::vector< DrawRoutine > draw_routines_
void DrawUsingRegistryRoutine(int routine_id, const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles, const DungeonState *state)
void MarkBg1RectTransparent(gfx::BackgroundBuffer &bg1, int start_px, int start_py, int pixel_width, int pixel_height)
std::pair< int, int > CalculateObjectDimensions(const RoomObject &object)
Calculate the dimensions (width, height) of an object in pixels.
void SetTraceContext(const RoomObject &object, RoomObject::LayerType layer)
const uint8_t * room_gfx_buffer_
static bool RoutineDrawsToBothBGs(int routine_id)
void DrawNothing(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles, const DungeonState *state=nullptr)
bool allow_track_corner_aliases_
void DrawDoor(const DoorDef &door, int door_index, gfx::BackgroundBuffer &bg1, gfx::BackgroundBuffer &bg2, const DungeonState *state=nullptr)
Draw a door to background buffers.
std::function< void( ObjectDrawer *, const RoomObject &, gfx::BackgroundBuffer &, std::span< const gfx::TileInfo >, const DungeonState *)> DrawRoutine
void DrawPotItem(uint8_t item_id, int x, int y, gfx::BackgroundBuffer &bg)
Draw a pot item visualization.
void DrawDoorIndicator(gfx::BackgroundBuffer &bg, int tile_x, int tile_y, int width, int height, DoorType type, DoorDirection direction)
void DrawLargeCanvasObject(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles, int width, int height)
void PushTrace(int tile_x, int tile_y, const gfx::TileInfo &tile_info)
static void TraceHookThunk(int tile_x, int tile_y, const gfx::TileInfo &tile_info, void *user_data)
void DrawCustomObject(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles, const DungeonState *state=nullptr)
void DrawRightwardsDecor4x3spaced4_1to16(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles, const DungeonState *state=nullptr)
static constexpr int kMaxTilesX
absl::Status DrawObjectList(const std::vector< RoomObject > &objects, gfx::BackgroundBuffer &bg1, gfx::BackgroundBuffer &bg2, const gfx::PaletteGroup &palette_group, const DungeonState *state=nullptr, gfx::BackgroundBuffer *layout_bg1=nullptr, bool reset_chest_index=true)
Draw all objects in a room.
void MarkBG1Transparent(gfx::BackgroundBuffer &bg1, int tile_x, int tile_y, int pixel_width, int pixel_height)
Mark BG1 pixels as transparent where BG2 overlay objects are drawn.
void DrawChest(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles, const DungeonState *state=nullptr)
void CustomDraw(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles, const DungeonState *state=nullptr)
bool routines_initialized_
void DrawMissingCustomObjectPlaceholder(gfx::BackgroundBuffer &bg, int tile_x, int tile_y)
ObjectDrawer(Rom *rom, int room_id, const uint8_t *room_gfx_buffer=nullptr)
void ClearTraceCollector()
absl::Status DrawObject(const RoomObject &object, gfx::BackgroundBuffer &bg1, gfx::BackgroundBuffer &bg2, const gfx::PaletteGroup &palette_group, const DungeonState *state=nullptr, gfx::BackgroundBuffer *layout_bg1=nullptr)
Draw a room object to background buffers.
static constexpr int kMaxTilesY
absl::Status DrawRoomDrawObjectData2x2(uint16_t object_id, int tile_x, int tile_y, RoomObject::LayerType layer, uint16_t room_draw_object_data_offset, gfx::BackgroundBuffer &bg1, gfx::BackgroundBuffer &bg2)
Draw a fixed 2x2 (16x16) tile pattern from RoomDrawObjectData.
void SetTraceCollector(std::vector< TileTrace > *collector, bool trace_only=false)
void SetAllowTrackCornerAliases(bool allow)
bool IsValidTilePosition(int tile_x, int tile_y) const
constexpr DoorDimensions GetDoorDimensions(DoorDirection dir)
Get door dimensions based on direction.
DoorType
Door types from ALTTP.
DoorDirection
Door direction on room walls.
Represents a group of palettes.
Door dimensions in tiles (8x8 pixel tiles)
std::pair< int, int > GetTileCoords() const
DoorDimensions GetDimensions() const