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

Direct ROM parser for dungeon objects. More...

#include <object_parser.h>

Collaboration diagram for yaze::zelda3::ObjectParser:

Public Member Functions

 ObjectParser (Rom *rom)
 
absl::StatusOr< std::vector< gfx::TileInfo > > ParseObject (int16_t object_id)
 Parse object data directly from ROM.
 
absl::StatusOr< std::vector< ObjectTileReadRange > > ResolveTileReadRanges (int16_t object_id)
 Resolve every tile-data range consumed by ParseObject.
 
absl::StatusOr< ObjectRoutineInfoParseObjectRoutine (int16_t object_id)
 Parse object routine data.
 
absl::StatusOr< ObjectSubtypeInfoGetObjectSubtype (int16_t object_id)
 Get object subtype information.
 
absl::StatusOr< ObjectSizeInfoParseObjectSize (int16_t object_id, uint8_t size_byte)
 Parse object size and orientation.
 
int DetermineSubtype (int16_t object_id) const
 Determine object subtype from ID.
 
ObjectDrawInfo GetObjectDrawInfo (int16_t object_id) const
 Get draw routine information for an object.
 

Private Member Functions

absl::StatusOr< std::vector< gfx::TileInfo > > ParseSubtype1 (int16_t object_id)
 Parse subtype 1 objects (0x00-0xFF)
 
absl::StatusOr< std::vector< gfx::TileInfo > > ParseSubtype2 (int16_t object_id)
 Parse subtype 2 objects (0x100-0x1FF)
 
absl::StatusOr< std::vector< gfx::TileInfo > > ParseSubtype3 (int16_t object_id)
 Parse subtype 3 objects (0x200+)
 
absl::StatusOr< std::vector< gfx::TileInfo > > ReadTileData (int address, int tile_count)
 Read tile data from ROM.
 
int GetSubtype2TileCount (int16_t object_id) const
 Get tile count for subtype 2 objects.
 
int GetSubtype3TileCount (int16_t object_id) const
 Get tile count for subtype 3 objects.
 
int ResolveTileCountForObject (int16_t object_id) const
 

Private Attributes

Romrom_
 
std::vector< ObjectTileReadRange > * tile_read_range_collector_ = nullptr
 

Detailed Description

Direct ROM parser for dungeon objects.

This class replaces the SNES emulation approach with direct ROM parsing, providing better performance and reliability for object rendering.

Definition at line 104 of file object_parser.h.

Constructor & Destructor Documentation

◆ ObjectParser()

yaze::zelda3::ObjectParser::ObjectParser ( Rom * rom)
inlineexplicit

Definition at line 106 of file object_parser.h.

Member Function Documentation

◆ ParseObject()

absl::StatusOr< std::vector< gfx::TileInfo > > yaze::zelda3::ObjectParser::ParseObject ( int16_t object_id)

Parse object data directly from ROM.

Parameters
object_idThe object ID to parse
Returns
StatusOr containing the parsed tile data

Definition at line 98 of file object_parser.cc.

References DetermineSubtype(), ParseSubtype1(), ParseSubtype2(), ParseSubtype3(), and rom_.

Referenced by yaze::zelda3::RoomObject::LoadTilesWithParser(), and ResolveTileReadRanges().

Here is the call graph for this function:

◆ ResolveTileReadRanges()

absl::StatusOr< std::vector< ObjectTileReadRange > > yaze::zelda3::ObjectParser::ResolveTileReadRanges ( int16_t object_id)

Resolve every tile-data range consumed by ParseObject.

This deliberately executes the parser's normal read path and therefore fails if any source is malformed or outside the loaded ROM. Callers must not turn a resolution error into an empty impact set.

Definition at line 126 of file object_parser.cc.

References ParseObject(), and tile_read_range_collector_.

Referenced by yaze::zelda3::ObjectTileEditor::AnalyzeStandardTileSourceImpact().

Here is the call graph for this function:

◆ ParseObjectRoutine()

absl::StatusOr< ObjectRoutineInfo > yaze::zelda3::ObjectParser::ParseObjectRoutine ( int16_t object_id)

Parse object routine data.

Parameters
object_idThe object ID
Returns
StatusOr containing routine information

Definition at line 149 of file object_parser.cc.

References GetObjectSubtype(), yaze::zelda3::ObjectRoutineInfo::is_orientation_dependent, yaze::zelda3::ObjectRoutineInfo::is_repeatable, rom_, yaze::zelda3::ObjectRoutineInfo::routine_ptr, yaze::zelda3::ObjectRoutineInfo::tile_count, and yaze::zelda3::ObjectRoutineInfo::tile_ptr.

Here is the call graph for this function:

◆ GetObjectSubtype()

absl::StatusOr< ObjectSubtypeInfo > yaze::zelda3::ObjectParser::GetObjectSubtype ( int16_t object_id)

◆ ParseObjectSize()

absl::StatusOr< ObjectSizeInfo > yaze::zelda3::ObjectParser::ParseObjectSize ( int16_t object_id,
uint8_t size_byte )

Parse object size and orientation.

Parameters
object_idThe object ID
size_byteThe size byte from object data
Returns
StatusOr containing size and orientation info

Definition at line 209 of file object_parser.cc.

References yaze::zelda3::ObjectSizeInfo::height_tiles, yaze::zelda3::ObjectSizeInfo::is_horizontal, yaze::zelda3::ObjectSizeInfo::is_repeatable, yaze::zelda3::ObjectSizeInfo::repeat_count, and yaze::zelda3::ObjectSizeInfo::width_tiles.

◆ DetermineSubtype()

int yaze::zelda3::ObjectParser::DetermineSubtype ( int16_t object_id) const

Determine object subtype from ID.

Definition at line 815 of file object_parser.cc.

Referenced by GetObjectSubtype(), ParseObject(), and ResolveTileCountForObject().

◆ GetObjectDrawInfo()

◆ ParseSubtype1()

absl::StatusOr< std::vector< gfx::TileInfo > > yaze::zelda3::ObjectParser::ParseSubtype1 ( int16_t object_id)
private

Parse subtype 1 objects (0x00-0xFF)

Definition at line 237 of file object_parser.cc.

References yaze::Rom::data(), yaze::zelda3::kRoomObjectSubtype1, yaze::zelda3::kRoomObjectTileAddress, LOG_DEBUG, ReadTileData(), rom_, and yaze::Rom::size().

Referenced by ParseObject().

Here is the call graph for this function:

◆ ParseSubtype2()

absl::StatusOr< std::vector< gfx::TileInfo > > yaze::zelda3::ObjectParser::ParseSubtype2 ( int16_t object_id)
private

Parse subtype 2 objects (0x100-0x1FF)

Definition at line 290 of file object_parser.cc.

References yaze::Rom::data(), GetSubtype2TileCount(), yaze::zelda3::kRoomObjectSubtype2, yaze::zelda3::kRoomObjectTileAddress, LOG_DEBUG, ReadTileData(), rom_, and yaze::Rom::size().

Referenced by ParseObject().

Here is the call graph for this function:

◆ ParseSubtype3()

absl::StatusOr< std::vector< gfx::TileInfo > > yaze::zelda3::ObjectParser::ParseSubtype3 ( int16_t object_id)
private

Parse subtype 3 objects (0x200+)

Definition at line 355 of file object_parser.cc.

References yaze::Rom::data(), GetSubtype3TileCount(), yaze::zelda3::kRoomObjectSubtype3, yaze::zelda3::kRoomObjectTileAddress, ReadTileData(), rom_, and yaze::Rom::size().

Referenced by ParseObject().

Here is the call graph for this function:

◆ ReadTileData()

absl::StatusOr< std::vector< gfx::TileInfo > > yaze::zelda3::ObjectParser::ReadTileData ( int address,
int tile_count )
private

Read tile data from ROM.

Parameters
addressThe address to read from
tile_countNumber of tiles to read
Returns
StatusOr containing tile data

Definition at line 513 of file object_parser.cc.

References yaze::Rom::data(), LOG_DEBUG, rom_, yaze::Rom::size(), tile_read_range_collector_, and yaze::gfx::WordToTileInfo().

Referenced by ParseSubtype1(), ParseSubtype2(), and ParseSubtype3().

Here is the call graph for this function:

◆ GetSubtype2TileCount()

int yaze::zelda3::ObjectParser::GetSubtype2TileCount ( int16_t object_id) const
private

Get tile count for subtype 2 objects.

Different subtype 2 objects have different tile counts:

  • 4x4 corners (0x100-0x10F): 16 tiles
  • Weird corners (0x110-0x117): 12 tiles
  • Others: 8 tiles
Parameters
object_idThe object ID
Returns
Number of tiles to read

Definition at line 573 of file object_parser.cc.

Referenced by ParseSubtype2(), and ResolveTileCountForObject().

◆ GetSubtype3TileCount()

int yaze::zelda3::ObjectParser::GetSubtype3TileCount ( int16_t object_id) const
private

Get tile count for subtype 3 objects.

Different subtype 3 objects have different tile counts:

  • PrisonCell aliases (0xF8D/0xF97): 6 tiles from literal obj1488
  • RupeeFloor (0xF92): 2 tiles from literal obj1DD6
  • BigKeyLock (0xF98): 4 tiles (one closed 2x2 block)
  • BombableFloor (0xFC7): 32 tiles (two non-contiguous 4x4 states)
  • Chest/OpenChest (0xF99/0xF9A): 8/4 tiles (stateful/fixed 2x2)
  • BigChest/OpenBigChest (0xFB1/0xFB2): 24/12 tiles (stateful/fixed 4x3)
  • TableRock4x3 variants: 12 tiles
  • 4x4 objects: 16 tiles
  • Most others: 8 tiles
Parameters
object_idThe object ID
Returns
Number of tiles to read

Definition at line 627 of file object_parser.cc.

Referenced by ParseSubtype3(), and ResolveTileCountForObject().

◆ ResolveTileCountForObject()

int yaze::zelda3::ObjectParser::ResolveTileCountForObject ( int16_t object_id) const
private

Definition at line 826 of file object_parser.cc.

References DetermineSubtype(), GetSubtype2TileCount(), and GetSubtype3TileCount().

Referenced by GetObjectDrawInfo(), and GetObjectSubtype().

Here is the call graph for this function:

Member Data Documentation

◆ rom_

Rom* yaze::zelda3::ObjectParser::rom_
private

◆ tile_read_range_collector_

std::vector<ObjectTileReadRange>* yaze::zelda3::ObjectParser::tile_read_range_collector_ = nullptr
private

Definition at line 227 of file object_parser.h.

Referenced by ReadTileData(), and ResolveTileReadRanges().


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