yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::zelda3::ObjectDrawer Class Reference

Draws dungeon objects to background buffers using game patterns. More...

#include <object_drawer.h>

Collaboration diagram for yaze::zelda3::ObjectDrawer:

Classes

struct  DoorDef
 
struct  TileTrace
 
struct  TraceContext
 

Public Member Functions

 ObjectDrawer (Rom *rom, int room_id, const uint8_t *room_gfx_buffer=nullptr, const CustomObjectRenderSnapshot *custom_objects=nullptr)
 
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, gfx::BackgroundBuffer *layout_bg2=nullptr)
 Draw a room object to background buffers.
 
absl::Status DrawLayerMaskFull (const RoomObject &object, gfx::BackgroundBuffer &target_bg, RoomObject::LayerType layer)
 
absl::Status DrawLampCones (const RoomObject &object, gfx::BackgroundBuffer &bg2)
 
absl::Status DrawAgahnimsWindows (const RoomObject &object, gfx::BackgroundBuffer &bg1, gfx::BackgroundBuffer &bg2, gfx::BackgroundBuffer *layout_bg1, gfx::BackgroundBuffer *layout_bg2)
 
absl::Status DrawBigDecor10x8 (const RoomObject &object, gfx::BackgroundBuffer &target_bg, RoomObject::LayerType layer, int data_pc)
 
absl::Status DrawVitreousGoo (const RoomObject &object, gfx::BackgroundBuffer &bg2)
 
void DrawChestHoleOverlay (int tag1, int tag2, const DungeonState *state, gfx::BackgroundBuffer &bg1)
 
void ResetChestIndex ()
 
void SetBG1RevealMaskSource (gfx::BG1RevealMaskSource source)
 
void SetRoomTag2 (int tag2)
 
void SetRoomFloorGraphics (uint8_t floor1, uint8_t floor2)
 
void DrawDoor (const DoorDef &door, int door_index, gfx::BackgroundBuffer &bg1, gfx::BackgroundBuffer &bg2, const DungeonState *state=nullptr, gfx::BackgroundBuffer *layout_bg1=nullptr, gfx::BackgroundBuffer *layout_bg2=nullptr)
 Draw a door to background buffers.
 
void DrawPotItem (uint8_t item_id, int x, int y, gfx::BackgroundBuffer &bg)
 Draw a pot item visualization.
 
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_room_event_indices=true, gfx::BackgroundBuffer *layout_bg2=nullptr)
 Draw all objects in a room.
 
int GetDrawRoutineId (int16_t object_id) const
 Get draw routine ID for an object.
 
int GetDrawRoutineCount () const
 Get the total number of registered draw routines.
 
void InitializeDrawRoutines ()
 Initialize draw routine registry Must be called before drawing objects.
 
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.
 
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.
 
std::pair< int, int > CalculateObjectDimensions (const RoomObject &object)
 Calculate the dimensions (width, height) of an object in pixels.
 
void SetTraceCollector (std::vector< TileTrace > *collector, bool trace_only=false)
 
void ClearTraceCollector ()
 
bool TraceOnly () const
 

Protected Types

using DrawRoutine
 

Protected Member Functions

void DrawChest (const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles, const DungeonState *state=nullptr)
 
void DrawBigChest (const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles, const DungeonState *state=nullptr)
 
void DrawBigKeyLock (const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles, const DungeonState *state=nullptr)
 
void DrawNothing (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)
 
void DrawRightwards4x4_1to16 (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)
 
void DrawLargeCanvasObject (const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles, int width, int height)
 
void DrawCustomObject (const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles, const DungeonState *state=nullptr)
 
void DrawMissingCustomObjectPlaceholder (gfx::BackgroundBuffer &bg, int tile_x, int tile_y)
 
void DrawUsingRegistryRoutine (int routine_id, const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles, const DungeonState *state)
 
void WriteTile8 (gfx::BackgroundBuffer &bg, int tile_x, int tile_y, const gfx::TileInfo &tile_info)
 
bool IsValidTilePosition (int tile_x, int tile_y) const
 
void MarkBg1RectRevealed (gfx::BackgroundBuffer &bg1, int start_px, int start_py, int pixel_width, int pixel_height)
 
void MarkBg1OpaqueTilePixelsRevealed (gfx::BackgroundBuffer &bg1, const gfx::TileInfo &tile_info, int pixel_x, int pixel_y, const uint8_t *tiledata)
 
void DrawDoorIndicator (gfx::BackgroundBuffer &bg, int tile_x, int tile_y, int width, int height, DoorType type, DoorDirection direction)
 
void SetTraceContext (const RoomObject &object, RoomObject::LayerType layer)
 
void PushTrace (int tile_x, int tile_y, const gfx::TileInfo &tile_info)
 

Static Protected Member Functions

static bool RoutineDrawsToBothBGs (int routine_id)
 
static bool RequiresRectangularBg1Mask (const RoomObject &object)
 
static void TraceHookThunk (gfx::BackgroundBuffer *bg, int tile_x, int tile_y, const gfx::TileInfo &tile_info, void *user_data)
 

Protected Attributes

std::vector< DrawRoutine > draw_routines_
 
bool routines_initialized_ = false
 
TraceContext trace_context_ {}
 
std::vector< TileTrace > * trace_collector_ = nullptr
 
bool trace_only_ = false
 
const CustomObjectRenderSnapshot * custom_objects_ = nullptr
 
Rom * rom_
 
int room_id_
 
int current_chest_index_ = 0
 
int current_room_event_index_ = 0
 
bool has_room_floor_graphics_ = false
 
int room_tag2_ = -1
 
uint8_t floor1_graphics_ = 0
 
uint8_t floor2_graphics_ = 0
 
gfx::BackgroundBuffer * registry_secondary_bg_ = nullptr
 
gfx::BackgroundBuffer * registry_bg2_ = nullptr
 
const gfx::BackgroundBuffer * registry_primary_layout_bg_ = nullptr
 
RoomObject::LayerType registry_primary_layer_ = RoomObject::LayerType::BG1
 
RoomObject::LayerType registry_secondary_layer_ = RoomObject::LayerType::BG2
 
gfx::BackgroundBuffer * active_object_bg1_mask_ = nullptr
 
gfx::BackgroundBuffer * active_layout_bg1_mask_ = nullptr
 
gfx::BackgroundBuffer * active_mask_source_bg_ = nullptr
 
gfx::BG1RevealMaskSource bg1_reveal_mask_source_
 
const uint8_t * room_gfx_buffer_
 

Static Protected Attributes

static constexpr int kMaxTilesX = 64
 
static constexpr int kMaxTilesY = 64
 

Detailed Description

Draws dungeon objects to background buffers using game patterns.

This class interprets object IDs and draws them to BG1/BG2 buffers using the patterns extracted from the game's drawing routines. Based on ZScream's DungeonObjectData.cs and Subtype1_Draw.cs patterns.

Architecture:

  1. Load tile data from ROM for the object
  2. Look up draw routine ID from object ID mapping
  3. Execute appropriate draw routine with size/orientation
  4. Write tiles to BackgroundBuffer according to pattern
  5. Handle palette coordination and graphics sheet access

Definition at line 36 of file object_drawer.h.

Member Typedef Documentation

◆ DrawRoutine

Initial value:
std::function<void(
ObjectDrawer*, const RoomObject&, gfx::BackgroundBuffer&,
std::span<const gfx::TileInfo>, const DungeonState*)>
ObjectDrawer(Rom *rom, int room_id, const uint8_t *room_gfx_buffer=nullptr, const CustomObjectRenderSnapshot *custom_objects=nullptr)

Definition at line 254 of file object_drawer.h.

Constructor & Destructor Documentation

◆ ObjectDrawer()

yaze::zelda3::ObjectDrawer::ObjectDrawer ( Rom * rom,
int room_id,
const uint8_t * room_gfx_buffer = nullptr,
const CustomObjectRenderSnapshot * custom_objects = nullptr )
explicit

Definition at line 119 of file object_drawer.cc.

References InitializeDrawRoutines().

Here is the call graph for this function:

Member Function Documentation

◆ DrawObject()

absl::Status yaze::zelda3::ObjectDrawer::DrawObject ( const RoomObject & object,
gfx::BackgroundBuffer & bg1,
gfx::BackgroundBuffer & bg2,
const gfx::PaletteGroup & palette_group,
const DungeonState * state = nullptr,
gfx::BackgroundBuffer * layout_bg1 = nullptr,
gfx::BackgroundBuffer * layout_bg2 = nullptr )

Draw a room object to background buffers.

Parameters
objectThe object to draw
bg1Background layer 1 buffer (object buffer)
bg2Background layer 2 buffer (object buffer)
palette_groupCurrent palette group for color mapping
layout_bg1Optional upper layout owner for fixed-tilemap mutations
layout_bg2Optional lower layout owner for fixed-tilemap mutations
Returns
Status of the drawing operation

Definition at line 273 of file object_drawer.cc.

References active_layout_bg1_mask_, active_mask_source_bg_, active_object_bg1_mask_, yaze::zelda3::RoomObject::BG1, yaze::zelda3::RoomObject::BG2, yaze::zelda3::DrawRoutineUtils::ClearTraceHook(), custom_objects_, yaze::gfx::DecodeDungeonFloorTilePattern(), draw_routines_, DrawAgahnimsWindows(), DrawBigDecor10x8(), DrawCustomObject(), DrawLampCones(), DrawLayerMaskFull(), DrawVitreousGoo(), yaze::zelda3::CustomObjectRenderSnapshot::enabled(), floor1_graphics_, floor2_graphics_, yaze::zelda3::CustomObjectManager::Get(), yaze::zelda3::DimensionService::Get(), yaze::zelda3::DrawRoutineRegistry::Get(), yaze::zelda3::ObjectDimensionTable::Get(), GetDrawRoutineId(), yaze::zelda3::CustomObjectRenderSnapshot::GetObject(), yaze::zelda3::DrawRoutineRegistry::GetRoutineInfo(), yaze::zelda3::DimensionService::GetSelectionBoundsPixels(), yaze::zelda3::CustomObjectManager::GetTilePatterns(), has_room_floor_graphics_, yaze::zelda3::HasActiveCustomObjectOverride(), yaze::Rom::is_loaded(), yaze::zelda3::object_render_routing::IsMixedStraightInterroomObject(), yaze::zelda3::object_render_routing::IsNorthMixedStraightInterroomObject(), yaze::zelda3::DrawRoutineIds::kAgahnimsAltar, yaze::zelda3::DrawRoutineIds::kAutoStairs, yaze::zelda3::DrawRoutineIds::kDamFloodGate, yaze::zelda3::DrawRoutineIds::kFortuneTellerRoom, yaze::zelda3::kRoomObjectSubtype3, yaze::zelda3::kRoomObjectTileAddress, yaze::zelda3::kRoomObjectTileAddressFloor, yaze::zelda3::DrawRoutineIds::kSanctuaryWall, yaze::zelda3::DrawRoutineIds::kSpiralStairsGoingDownLower, yaze::zelda3::DrawRoutineIds::kSpiralStairsGoingDownUpper, yaze::zelda3::DrawRoutineIds::kSpiralStairsGoingUpLower, yaze::zelda3::DrawRoutineIds::kSpiralStairsGoingUpUpper, yaze::zelda3::DrawRoutineIds::kStraightInterRoomStairs, yaze::zelda3::DrawRoutineIds::kWaterOverlay8x8_1to16, yaze::zelda3::ObjectDimensionTable::LoadFromRom(), LOG_DEBUG, LOG_WARN, MarkBg1RectRevealed(), yaze::zelda3::DrawRoutineInfo::min_tiles, yaze::zelda3::DrawRoutineInfo::name, yaze::zelda3::ObjectParser::ParseObject(), registry_bg2_, registry_primary_layer_, registry_primary_layout_bg_, registry_secondary_bg_, registry_secondary_layer_, RequiresRectangularBg1Mask(), rom_, room_id_, RoutineDrawsToBothBGs(), routines_initialized_, yaze::zelda3::RoomObject::SetRom(), SetTraceContext(), yaze::zelda3::DrawRoutineUtils::SetTraceHook(), yaze::zelda3::CustomObjectRenderSnapshot::tile_patterns(), trace_collector_, trace_only_, TraceHookThunk(), yaze::Rom::vector(), and WriteTile8().

Referenced by yaze::editor::anonymous_namespace{dungeon_canvas_issue_report.cc}::BuildObjectTraceReport(), yaze::zelda3::ObjectTileEditor::CaptureObjectLayout(), yaze::zelda3::ComputeObjectTileOwners(), DrawObjectList(), yaze::emu::render::EmulatorRenderService::RenderDungeonObjectStatic(), yaze::editor::TileObjectHandler::RenderGhostPreviewBitmap(), and yaze::zelda3::anonymous_namespace{room_links.cc}::ScanDrawnTiles().

◆ DrawLayerMaskFull()

absl::Status yaze::zelda3::ObjectDrawer::DrawLayerMaskFull ( const RoomObject & object,
gfx::BackgroundBuffer & target_bg,
RoomObject::LayerType layer )

Definition at line 3119 of file object_drawer.cc.

References yaze::zelda3::DrawContext::kMaxTilesX, yaze::zelda3::DrawContext::kMaxTilesY, SetTraceContext(), yaze::gfx::WordToTileInfo(), and WriteTile8().

Referenced by DrawObject().

Here is the call graph for this function:

◆ DrawLampCones()

absl::Status yaze::zelda3::ObjectDrawer::DrawLampCones ( const RoomObject & object,
gfx::BackgroundBuffer & bg2 )

Definition at line 3139 of file object_drawer.cc.

References yaze::zelda3::RoomObject::BG2, yaze::zelda3::kRoomObjectTileAddress, rom_, SetTraceContext(), yaze::Rom::vector(), yaze::gfx::WordToTileInfo(), and WriteTile8().

Referenced by DrawObject().

Here is the call graph for this function:

◆ DrawAgahnimsWindows()

absl::Status yaze::zelda3::ObjectDrawer::DrawAgahnimsWindows ( const RoomObject & object,
gfx::BackgroundBuffer & bg1,
gfx::BackgroundBuffer & bg2,
gfx::BackgroundBuffer * layout_bg1,
gfx::BackgroundBuffer * layout_bg2 )

◆ DrawBigDecor10x8()

absl::Status yaze::zelda3::ObjectDrawer::DrawBigDecor10x8 ( const RoomObject & object,
gfx::BackgroundBuffer & target_bg,
RoomObject::LayerType layer,
int data_pc )

Definition at line 3277 of file object_drawer.cc.

References rom_, SetTraceContext(), yaze::Rom::vector(), yaze::gfx::WordToTileInfo(), and WriteTile8().

Referenced by DrawObject().

Here is the call graph for this function:

◆ DrawVitreousGoo()

absl::Status yaze::zelda3::ObjectDrawer::DrawVitreousGoo ( const RoomObject & object,
gfx::BackgroundBuffer & bg2 )

Definition at line 3304 of file object_drawer.cc.

References yaze::zelda3::RoomObject::BG2, yaze::zelda3::kRoomObjectTileAddress, rom_, SetTraceContext(), yaze::Rom::vector(), yaze::gfx::WordToTileInfo(), and WriteTile8().

Referenced by DrawObject().

Here is the call graph for this function:

◆ DrawChestHoleOverlay()

void yaze::zelda3::ObjectDrawer::DrawChestHoleOverlay ( int tag1,
int tag2,
const DungeonState * state,
gfx::BackgroundBuffer & bg1 )

◆ ResetChestIndex()

void yaze::zelda3::ObjectDrawer::ResetChestIndex ( )
inline

Definition at line 111 of file object_drawer.h.

References current_chest_index_, and current_room_event_index_.

Referenced by DrawObjectList().

◆ SetBG1RevealMaskSource()

◆ SetRoomTag2()

void yaze::zelda3::ObjectDrawer::SetRoomTag2 ( int tag2)
inline

Definition at line 122 of file object_drawer.h.

References room_tag2_.

Referenced by yaze::zelda3::Room::RenderObjectsToBackground().

◆ SetRoomFloorGraphics()

◆ DrawDoor()

void yaze::zelda3::ObjectDrawer::DrawDoor ( const DoorDef & door,
int door_index,
gfx::BackgroundBuffer & bg1,
gfx::BackgroundBuffer & bg2,
const DungeonState * state = nullptr,
gfx::BackgroundBuffer * layout_bg1 = nullptr,
gfx::BackgroundBuffer * layout_bg2 = nullptr )

Draw a door to background buffers.

Parameters
doorDoor definition (type, direction, position)
bg1Background layer 1 object buffer
bg2Background layer 2 object buffer
layout_bg1Optional upper-layer layout buffer. Door priority promotion is applied to both BG1 owners without repainting pixels.
layout_bg2Optional lower-layer layout buffer for door routines that mutate existing BG2 priority.

Definition at line 1704 of file object_drawer.cc.

References bg1_reveal_mask_source_, yaze::zelda3::BigKeyDoor, yaze::gfx::BackgroundBuffer::bitmap(), yaze::zelda3::BottomShutterLower, yaze::zelda3::BottomSidedShutter, yaze::zelda3::CaveExit, yaze::gfx::BackgroundBuffer::ClearBG1RevealMaskRect(), yaze::zelda3::CurtainDoor, yaze::Rom::data(), yaze::zelda3::ObjectDrawer::DoorDef::direction, yaze::zelda3::DoubleSidedShutter, yaze::zelda3::DoubleSidedShutterLower, DrawDoorIndicator(), DrawTileToBitmap(), yaze::zelda3::DungeonSwapMarker, yaze::zelda3::East, yaze::zelda3::ExitLower, yaze::zelda3::ExitMarker, yaze::zelda3::ExplicitRoomDoor, yaze::zelda3::ExplodingWall, yaze::zelda3::EyeWatchDoor, yaze::zelda3::FancyDungeonExit, yaze::zelda3::FancyDungeonExitLower, yaze::zelda3::ObjectDrawer::DoorDef::GetDimensions(), yaze::zelda3::GetDoorDimensions(), yaze::zelda3::GetDoorDirectionName(), yaze::zelda3::GetDoorTypeName(), yaze::zelda3::ObjectDrawer::DoorDef::GetTileCoords(), yaze::Rom::is_loaded(), yaze::zelda3::DungeonState::IsDoorOpen(), yaze::zelda3::DungeonState::IsDoorSwitchActive(), yaze::zelda3::kDoorGfxDown, yaze::zelda3::kDoorGfxLeft, yaze::zelda3::kDoorGfxRight, yaze::zelda3::kDoorGfxUp, yaze::zelda3::LayerSwapMarker, yaze::zelda3::LitCaveExitLower, LOG_DEBUG, yaze::gfx::BackgroundBuffer::mutable_coverage_data(), yaze::gfx::BackgroundBuffer::mutable_priority_data(), yaze::zelda3::NormalDoor, yaze::zelda3::NormalDoorLower, yaze::zelda3::NormalDoorOneSidedShutter, yaze::zelda3::North, yaze::zelda3::ObjectDrawer::DoorDef::position, yaze::zelda3::DoorPositionManager::PositionToRenderTileCoords(), yaze::zelda3::DoorPositionManager::PositionToTileCoords(), rom_, room_gfx_buffer_, room_id_, yaze::gfx::BackgroundBuffer::SetPriorityAt(), yaze::gfx::BackgroundBuffer::SetTileAt(), yaze::Rom::size(), yaze::zelda3::SmallKeyStairsDown, yaze::zelda3::SmallKeyStairsDownLower, yaze::zelda3::SmallKeyStairsUp, yaze::zelda3::SmallKeyStairsUpLower, yaze::zelda3::South, yaze::zelda3::TopShutterLower, yaze::zelda3::TopSidedShutter, yaze::zelda3::ObjectDrawer::DoorDef::type, yaze::zelda3::UnusedCaveExit, yaze::zelda3::WaterfallDoor, yaze::zelda3::West, yaze::zelda3::DoorDimensions::width_tiles, and yaze::gfx::WordToTileInfo().

Referenced by yaze::zelda3::Room::RenderObjectsToBackground().

◆ DrawPotItem()

void yaze::zelda3::ObjectDrawer::DrawPotItem ( uint8_t item_id,
int x,
int y,
gfx::BackgroundBuffer & bg )

Draw a pot item visualization.

Parameters
item_idItem ID
xX coordinate (pixels)
yY coordinate (pixels)
bgBackground buffer

Definition at line 3568 of file object_drawer.cc.

References yaze::gfx::BackgroundBuffer::bitmap(), yaze::gfx::BackgroundBuffer::ClearBG1RevealMaskRect(), and yaze::gfx::BackgroundBuffer::mutable_coverage_data().

Referenced by yaze::zelda3::Room::RenderObjectsToBackground().

Here is the call graph for this function:

◆ DrawObjectList()

absl::Status yaze::zelda3::ObjectDrawer::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_room_event_indices = true,
gfx::BackgroundBuffer * layout_bg2 = nullptr )

Draw all objects in a room.

Parameters
objectsVector of room objects
bg1Background layer 1 buffer (object buffer)
bg2Background layer 2 buffer (object buffer)
palette_groupCurrent palette group for color mapping
layout_bg1Optional upper layout owner for fixed-tilemap mutations
reset_room_event_indicesIf true, reset the chest-only and shared chest/lock counters before drawing (set false on subsequent USDASM list passes; see Room::RenderObjectsToBackground)
layout_bg2Optional lower layout owner for fixed-tilemap mutations. Kept after reset_room_event_indices for source compatibility with existing positional callers.
Returns
Status of the drawing operation

Definition at line 629 of file object_drawer.cc.

References yaze::gfx::BackgroundBuffer::bitmap(), DrawObject(), yaze::zelda3::GetEffectiveObjectLayerSemantics(), yaze::zelda3::kBg1, yaze::zelda3::kBg2, yaze::zelda3::kBothBg1Bg2, LOG_DEBUG, and ResetChestIndex().

Referenced by yaze::zelda3::RoomLayout::Draw(), and yaze::zelda3::Room::RenderObjectsToBackground().

Here is the call graph for this function:

◆ GetDrawRoutineId()

int yaze::zelda3::ObjectDrawer::GetDrawRoutineId ( int16_t object_id) const

Get draw routine ID for an object.

Parameters
object_idThe object ID to look up
Returns
Draw routine ID (0-24) based on ZScream mapping

Definition at line 1692 of file object_drawer.cc.

References custom_objects_, yaze::zelda3::CustomObjectRenderSnapshot::enabled(), and yaze::zelda3::DrawRoutineRegistry::Get().

Referenced by DrawObject(), and yaze::editor::DungeonObjectSelector::DrawObjectAssetBrowser().

Here is the call graph for this function:

◆ GetDrawRoutineCount()

int yaze::zelda3::ObjectDrawer::GetDrawRoutineCount ( ) const
inline

Get the total number of registered draw routines.

Definition at line 188 of file object_drawer.h.

References draw_routines_.

◆ InitializeDrawRoutines()

void yaze::zelda3::ObjectDrawer::InitializeDrawRoutines ( )

Initialize draw routine registry Must be called before drawing objects.

Definition at line 688 of file object_drawer.cc.

References draw_routines_, DrawBigKeyLock(), DrawChest(), DrawCustomObject(), DrawNothing(), DrawUsingRegistryRoutine(), yaze::zelda3::RoomObject::id_, yaze::zelda3::DrawRoutineIds::kActual4x4, yaze::zelda3::DrawRoutineIds::kAgahnimsAltar, yaze::zelda3::DrawRoutineIds::kArcheryGameTargetDoor, yaze::zelda3::DrawRoutineIds::kBed4x5, yaze::zelda3::DrawRoutineIds::kBigGrayRock, yaze::zelda3::DrawRoutineIds::kBigLightBeam, yaze::zelda3::DrawRoutineIds::kBigWallDecor, yaze::zelda3::DrawRoutineIds::kBossShell4x4, yaze::zelda3::DrawRoutineIds::kDamFloodGate, yaze::zelda3::DrawRoutineIds::kDownwardsEdge1x1_1to16plus7, yaze::zelda3::DrawRoutineIds::kFloorLight, yaze::zelda3::DrawRoutineIds::kFortuneTellerRoom, yaze::zelda3::DrawRoutineIds::kGanonTriforceFloorDecor, yaze::zelda3::DrawRoutineIds::kHorizontalTurtleRockPipe, yaze::zelda3::DrawRoutineIds::kLightBeam, yaze::zelda3::DrawRoutineIds::kMagicBatAltar, yaze::zelda3::DrawRoutineIds::kRightwards3x6, yaze::zelda3::DrawRoutineIds::kRupeeFloor, yaze::zelda3::DrawRoutineIds::kSanctuaryWall, yaze::zelda3::DrawRoutineIds::kSingle2x2, yaze::zelda3::DrawRoutineIds::kSingle4x3, yaze::zelda3::DrawRoutineIds::kSingle4x4, yaze::zelda3::DrawRoutineIds::kSmithyFurnace, yaze::zelda3::DrawRoutineIds::kSolidWallDecor3x4, yaze::zelda3::DrawRoutineIds::kTableBowl, yaze::zelda3::DrawRoutineIds::kUtility3x5, yaze::zelda3::DrawRoutineIds::kUtility6x3, yaze::zelda3::DrawRoutineIds::kVerticalTurtleRockPipe, yaze::zelda3::DrawRoutineIds::kVitreousGooDamage, yaze::zelda3::DrawRoutineIds::kWaterfall47, yaze::zelda3::DrawRoutineIds::kWaterfall48, yaze::zelda3::DrawRoutineIds::kWaterHopStairsA, yaze::zelda3::DrawRoutineIds::kWaterHopStairsB, yaze::zelda3::DrawRoutineIds::kWeird2x4_1to16, and routines_initialized_.

Referenced by ObjectDrawer(), yaze::emu::render::EmulatorRenderService::RenderDungeonObjectStatic(), and yaze::editor::TileObjectHandler::RenderGhostPreviewBitmap().

◆ DrawTileToBitmap()

void yaze::zelda3::ObjectDrawer::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.

Parameters
bitmapTarget bitmap to draw to
tile_infoTile information (ID, palette, mirroring)
pixel_xX pixel coordinate in bitmap
pixel_yY pixel coordinate in bitmap
tiledataSource graphics data from ROM

Definition at line 3010 of file object_drawer.cc.

References yaze::gfx::Bitmap::height(), yaze::gfx::TileInfo::horizontal_mirror_, yaze::gfx::TileInfo::id_, yaze::gfx::Bitmap::is_active(), LOG_DEBUG, yaze::gfx::Bitmap::mutable_data(), yaze::gfx::TileInfo::palette_, yaze::gfx::Bitmap::set_modified(), yaze::gfx::TileInfo::vertical_mirror_, and yaze::gfx::Bitmap::width().

Referenced by yaze::zelda3::ObjectTileEditor::BuildTile8Atlas(), DrawDoor(), yaze::zelda3::ObjectTileEditor::RenderLayoutToBitmap(), and WriteTile8().

◆ DrawRoomDrawObjectData2x2()

absl::Status yaze::zelda3::ObjectDrawer::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.

USDASM uses hardcoded offsets into RoomDrawObjectData for certain special objects that are NOT part of the room object stream (e.g. pushable blocks and lightable torches). See bank_01.asm: RoomDraw_PushableBlock and RoomDraw_LightableTorch.

Parameters
object_idIdentifier used only for tracing/debugging (not used for routine lookup)
tile_xTop-left X position in tiles
tile_yTop-left Y position in tiles
layerTarget layer (BG1/BG2)
room_draw_object_data_offsetOffset from RoomDrawObjectData base (not an absolute PC address)

Definition at line 3403 of file object_drawer.cc.

References yaze::zelda3::RoomObject::BG2, yaze::Rom::is_loaded(), yaze::zelda3::kRoomObjectTileAddress, rom_, SetTraceContext(), yaze::Rom::vector(), yaze::gfx::WordToTileInfo(), and WriteTile8().

Referenced by yaze::zelda3::Room::RenderObjectsToBackground().

◆ CalculateObjectDimensions()

std::pair< int, int > yaze::zelda3::ObjectDrawer::CalculateObjectDimensions ( const RoomObject & object)

Calculate the dimensions (width, height) of an object in pixels.

Parameters
objectThe object to calculate dimensions for
Returns
Pair of (width, height) in pixels

Definition at line 3473 of file object_drawer.cc.

References yaze::zelda3::DimensionService::Get(), and yaze::zelda3::DimensionService::GetPixelDimensions().

Here is the call graph for this function:

◆ SetTraceCollector()

◆ ClearTraceCollector()

void yaze::zelda3::ObjectDrawer::ClearTraceCollector ( )

◆ TraceOnly()

bool yaze::zelda3::ObjectDrawer::TraceOnly ( ) const
inline

Definition at line 250 of file object_drawer.h.

References trace_only_.

◆ DrawChest()

void yaze::zelda3::ObjectDrawer::DrawChest ( const RoomObject & obj,
gfx::BackgroundBuffer & bg,
std::span< const gfx::TileInfo > tiles,
const DungeonState * state = nullptr )
protected

◆ DrawBigChest()

void yaze::zelda3::ObjectDrawer::DrawBigChest ( const RoomObject & obj,
gfx::BackgroundBuffer & bg,
std::span< const gfx::TileInfo > tiles,
const DungeonState * state = nullptr )
protected

◆ DrawBigKeyLock()

void yaze::zelda3::ObjectDrawer::DrawBigKeyLock ( const RoomObject & obj,
gfx::BackgroundBuffer & bg,
std::span< const gfx::TileInfo > tiles,
const DungeonState * state = nullptr )
protected

◆ DrawNothing()

void yaze::zelda3::ObjectDrawer::DrawNothing ( const RoomObject & obj,
gfx::BackgroundBuffer & bg,
std::span< const gfx::TileInfo > tiles,
const DungeonState * state = nullptr )
protected

Definition at line 2771 of file object_drawer.cc.

References yaze::zelda3::RoomObject::id_, and LOG_DEBUG.

Referenced by InitializeDrawRoutines().

◆ CustomDraw()

void yaze::zelda3::ObjectDrawer::CustomDraw ( const RoomObject & obj,
gfx::BackgroundBuffer & bg,
std::span< const gfx::TileInfo > tiles,
const DungeonState * state = nullptr )
protected

Definition at line 2781 of file object_drawer.cc.

References WriteTile8(), yaze::zelda3::RoomObject::x_, and yaze::zelda3::RoomObject::y_.

Here is the call graph for this function:

◆ DrawRightwards4x4_1to16()

void yaze::zelda3::ObjectDrawer::DrawRightwards4x4_1to16 ( const RoomObject & obj,
gfx::BackgroundBuffer & bg,
std::span< const gfx::TileInfo > tiles,
const DungeonState * state = nullptr )
protected

◆ DrawRightwardsDecor4x3spaced4_1to16()

void yaze::zelda3::ObjectDrawer::DrawRightwardsDecor4x3spaced4_1to16 ( const RoomObject & obj,
gfx::BackgroundBuffer & bg,
std::span< const gfx::TileInfo > tiles,
const DungeonState * state = nullptr )
protected

Definition at line 2827 of file object_drawer.cc.

References yaze::zelda3::RoomObject::size_, WriteTile8(), yaze::zelda3::RoomObject::x_, and yaze::zelda3::RoomObject::y_.

Here is the call graph for this function:

◆ DrawLargeCanvasObject()

void yaze::zelda3::ObjectDrawer::DrawLargeCanvasObject ( const RoomObject & obj,
gfx::BackgroundBuffer & bg,
std::span< const gfx::TileInfo > tiles,
int width,
int height )
protected

Definition at line 3456 of file object_drawer.cc.

References WriteTile8(), yaze::zelda3::RoomObject::x_, and yaze::zelda3::RoomObject::y_.

Here is the call graph for this function:

◆ DrawCustomObject()

◆ DrawMissingCustomObjectPlaceholder()

void yaze::zelda3::ObjectDrawer::DrawMissingCustomObjectPlaceholder ( gfx::BackgroundBuffer & bg,
int tile_x,
int tile_y )
protected

◆ DrawUsingRegistryRoutine()

◆ WriteTile8()

◆ IsValidTilePosition()

bool yaze::zelda3::ObjectDrawer::IsValidTilePosition ( int tile_x,
int tile_y ) const
protected

Definition at line 3005 of file object_drawer.cc.

References kMaxTilesY.

Referenced by WriteTile8().

◆ RoutineDrawsToBothBGs()

bool yaze::zelda3::ObjectDrawer::RoutineDrawsToBothBGs ( int routine_id)
staticprotected

Definition at line 679 of file object_drawer.cc.

References yaze::zelda3::DrawRoutineRegistry::Get(), and yaze::zelda3::DrawRoutineRegistry::RoutineDrawsToBothBGs().

Referenced by DrawObject().

Here is the call graph for this function:

◆ MarkBg1RectRevealed()

void yaze::zelda3::ObjectDrawer::MarkBg1RectRevealed ( gfx::BackgroundBuffer & bg1,
int start_px,
int start_py,
int pixel_width,
int pixel_height )
protected

Definition at line 2857 of file object_drawer.cc.

References bg1_reveal_mask_source_, and yaze::gfx::BackgroundBuffer::SetBG1RevealMaskRect().

Referenced by DrawObject().

Here is the call graph for this function:

◆ MarkBg1OpaqueTilePixelsRevealed()

void yaze::zelda3::ObjectDrawer::MarkBg1OpaqueTilePixelsRevealed ( gfx::BackgroundBuffer & bg1,
const gfx::TileInfo & tile_info,
int pixel_x,
int pixel_y,
const uint8_t * tiledata )
protected

◆ RequiresRectangularBg1Mask()

bool yaze::zelda3::ObjectDrawer::RequiresRectangularBg1Mask ( const RoomObject & object)
staticprotected

Definition at line 613 of file object_drawer.cc.

Referenced by DrawObject().

◆ DrawDoorIndicator()

◆ SetTraceContext()

◆ PushTrace()

◆ TraceHookThunk()

void yaze::zelda3::ObjectDrawer::TraceHookThunk ( gfx::BackgroundBuffer * bg,
int tile_x,
int tile_y,
const gfx::TileInfo & tile_info,
void * user_data )
staticprotected

Definition at line 172 of file object_drawer.cc.

References yaze::zelda3::DrawContext::kMaxTilesY, and PushTrace().

Referenced by DrawObject().

Here is the call graph for this function:

Member Data Documentation

◆ draw_routines_

std::vector<DrawRoutine> yaze::zelda3::ObjectDrawer::draw_routines_
protected

Definition at line 326 of file object_drawer.h.

Referenced by DrawObject(), GetDrawRoutineCount(), and InitializeDrawRoutines().

◆ routines_initialized_

bool yaze::zelda3::ObjectDrawer::routines_initialized_ = false
protected

Definition at line 327 of file object_drawer.h.

Referenced by DrawObject(), and InitializeDrawRoutines().

◆ trace_context_

TraceContext yaze::zelda3::ObjectDrawer::trace_context_ {}
protected

Definition at line 340 of file object_drawer.h.

Referenced by PushTrace(), and SetTraceContext().

◆ trace_collector_

std::vector<TileTrace>* yaze::zelda3::ObjectDrawer::trace_collector_ = nullptr
protected

Definition at line 341 of file object_drawer.h.

Referenced by ClearTraceCollector(), DrawObject(), PushTrace(), and SetTraceCollector().

◆ trace_only_

bool yaze::zelda3::ObjectDrawer::trace_only_ = false
protected

◆ custom_objects_

const CustomObjectRenderSnapshot* yaze::zelda3::ObjectDrawer::custom_objects_ = nullptr
protected

Definition at line 345 of file object_drawer.h.

Referenced by DrawObject(), DrawUsingRegistryRoutine(), and GetDrawRoutineId().

◆ rom_

◆ room_id_

int yaze::zelda3::ObjectDrawer::room_id_
protected

◆ current_chest_index_

int yaze::zelda3::ObjectDrawer::current_chest_index_ = 0
mutableprotected

Definition at line 348 of file object_drawer.h.

Referenced by DrawBigChest(), DrawChest(), and ResetChestIndex().

◆ current_room_event_index_

int yaze::zelda3::ObjectDrawer::current_room_event_index_ = 0
mutableprotected

Definition at line 349 of file object_drawer.h.

Referenced by DrawBigChest(), DrawBigKeyLock(), DrawChest(), and ResetChestIndex().

◆ has_room_floor_graphics_

bool yaze::zelda3::ObjectDrawer::has_room_floor_graphics_ = false
protected

Definition at line 350 of file object_drawer.h.

Referenced by DrawObject(), and SetRoomFloorGraphics().

◆ room_tag2_

int yaze::zelda3::ObjectDrawer::room_tag2_ = -1
protected

Definition at line 351 of file object_drawer.h.

Referenced by DrawUsingRegistryRoutine(), and SetRoomTag2().

◆ floor1_graphics_

uint8_t yaze::zelda3::ObjectDrawer::floor1_graphics_ = 0
protected

Definition at line 352 of file object_drawer.h.

Referenced by DrawObject(), and SetRoomFloorGraphics().

◆ floor2_graphics_

uint8_t yaze::zelda3::ObjectDrawer::floor2_graphics_ = 0
protected

Definition at line 353 of file object_drawer.h.

Referenced by DrawObject(), and SetRoomFloorGraphics().

◆ registry_secondary_bg_

gfx::BackgroundBuffer* yaze::zelda3::ObjectDrawer::registry_secondary_bg_ = nullptr
protected

Definition at line 354 of file object_drawer.h.

Referenced by DrawObject(), and DrawUsingRegistryRoutine().

◆ registry_bg2_

gfx::BackgroundBuffer* yaze::zelda3::ObjectDrawer::registry_bg2_ = nullptr
protected

Definition at line 356 of file object_drawer.h.

Referenced by DrawObject(), and DrawUsingRegistryRoutine().

◆ registry_primary_layout_bg_

const gfx::BackgroundBuffer* yaze::zelda3::ObjectDrawer::registry_primary_layout_bg_ = nullptr
protected

Definition at line 357 of file object_drawer.h.

Referenced by DrawObject(), and DrawUsingRegistryRoutine().

◆ registry_primary_layer_

RoomObject::LayerType yaze::zelda3::ObjectDrawer::registry_primary_layer_ = RoomObject::LayerType::BG1
protected

Definition at line 358 of file object_drawer.h.

Referenced by DrawObject(), and DrawUsingRegistryRoutine().

◆ registry_secondary_layer_

RoomObject::LayerType yaze::zelda3::ObjectDrawer::registry_secondary_layer_ = RoomObject::LayerType::BG2
protected

Definition at line 359 of file object_drawer.h.

Referenced by DrawObject(), and DrawUsingRegistryRoutine().

◆ active_object_bg1_mask_

gfx::BackgroundBuffer* yaze::zelda3::ObjectDrawer::active_object_bg1_mask_ = nullptr
protected

Definition at line 360 of file object_drawer.h.

Referenced by DrawObject(), and WriteTile8().

◆ active_layout_bg1_mask_

gfx::BackgroundBuffer* yaze::zelda3::ObjectDrawer::active_layout_bg1_mask_ = nullptr
protected

Definition at line 361 of file object_drawer.h.

Referenced by DrawObject(), and WriteTile8().

◆ active_mask_source_bg_

gfx::BackgroundBuffer* yaze::zelda3::ObjectDrawer::active_mask_source_bg_ = nullptr
protected

Definition at line 362 of file object_drawer.h.

Referenced by DrawObject(), and WriteTile8().

◆ bg1_reveal_mask_source_

◆ room_gfx_buffer_

const uint8_t* yaze::zelda3::ObjectDrawer::room_gfx_buffer_
protected

Definition at line 366 of file object_drawer.h.

Referenced by DrawDoor(), DrawUsingRegistryRoutine(), and WriteTile8().

◆ kMaxTilesX

constexpr int yaze::zelda3::ObjectDrawer::kMaxTilesX = 64
staticconstexprprotected

Definition at line 369 of file object_drawer.h.

◆ kMaxTilesY

constexpr int yaze::zelda3::ObjectDrawer::kMaxTilesY = 64
staticconstexprprotected

Definition at line 370 of file object_drawer.h.

Referenced by IsValidTilePosition().


The documentation for this class was generated from the following files: