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

Manages diggable tile state as a 512-bit bitfield. More...

#include <diggable_tiles.h>

Public Member Functions

 DiggableTiles ()=default
 
bool IsDiggable (uint16_t tile_id) const
 Check if a Map16 tile ID is marked as diggable.
 
void SetDiggable (uint16_t tile_id, bool diggable)
 Set or clear the diggable bit for a Map16 tile ID.
 
void Clear ()
 Clear all diggable bits.
 
void SetVanillaDefaults ()
 Reset to vanilla diggable tiles.
 
std::vector< uint16_t > GetAllDiggableTileIds () const
 Get all tile IDs that are currently marked as diggable.
 
int GetDiggableCount () const
 Get the count of tiles marked as diggable.
 
void FromBytes (const uint8_t *data)
 Load bitfield from raw bytes (64 bytes).
 
void ToBytes (uint8_t *data) const
 Write bitfield to raw bytes (64 bytes).
 
const std::array< uint8_t, kDiggableTilesBitfieldSize > & GetRawData () const
 Get raw bitfield data for direct ROM writing.
 

Static Public Member Functions

static bool IsTile16Diggable (const gfx::Tile16 &tile16, const std::array< uint8_t, 0x200 > &all_tiles_types)
 Check if a Tile16 should be diggable based on its component tiles.
 

Private Attributes

std::array< uint8_t, kDiggableTilesBitfieldSizebitfield_ = {}
 

Detailed Description

Manages diggable tile state as a 512-bit bitfield.

Each Map16 tile ID (0-511) has one bit indicating if it's diggable. Used to replace the hardcoded CMP chain in bank 1B with a table lookup.

Definition at line 37 of file diggable_tiles.h.

Constructor & Destructor Documentation

◆ DiggableTiles()

yaze::zelda3::DiggableTiles::DiggableTiles ( )
default

Member Function Documentation

◆ IsDiggable()

bool yaze::zelda3::DiggableTiles::IsDiggable ( uint16_t tile_id) const

Check if a Map16 tile ID is marked as diggable.

Definition at line 7 of file diggable_tiles.cc.

References bitfield_, and yaze::zelda3::kMaxDiggableTileId.

Referenced by yaze::editor::DrawDiggableTilesEditorPopup(), GetAllDiggableTileIds(), and GetDiggableCount().

◆ SetDiggable()

void yaze::zelda3::DiggableTiles::SetDiggable ( uint16_t tile_id,
bool diggable )

Set or clear the diggable bit for a Map16 tile ID.

Definition at line 16 of file diggable_tiles.cc.

References bitfield_, and yaze::zelda3::kMaxDiggableTileId.

Referenced by yaze::zelda3::Overworld::AutoDetectDiggableTiles(), yaze::editor::DrawDiggableTilesEditorPopup(), and SetVanillaDefaults().

◆ Clear()

void yaze::zelda3::DiggableTiles::Clear ( )

◆ SetVanillaDefaults()

void yaze::zelda3::DiggableTiles::SetVanillaDefaults ( )

Reset to vanilla diggable tiles.

Definition at line 33 of file diggable_tiles.cc.

References Clear(), yaze::zelda3::kNumVanillaDiggableTiles, yaze::zelda3::kVanillaDiggableTiles, and SetDiggable().

Referenced by yaze::editor::DrawDiggableTilesEditorPopup(), and yaze::zelda3::Overworld::LoadDiggableTiles().

Here is the call graph for this function:

◆ GetAllDiggableTileIds()

std::vector< uint16_t > yaze::zelda3::DiggableTiles::GetAllDiggableTileIds ( ) const

Get all tile IDs that are currently marked as diggable.

Definition at line 40 of file diggable_tiles.cc.

References IsDiggable(), and yaze::zelda3::kMaxDiggableTileId.

Referenced by yaze::zelda3::DiggableTilesPatch::GenerateDataTable().

Here is the call graph for this function:

◆ GetDiggableCount()

int yaze::zelda3::DiggableTiles::GetDiggableCount ( ) const

Get the count of tiles marked as diggable.

Definition at line 50 of file diggable_tiles.cc.

References IsDiggable(), and yaze::zelda3::kMaxDiggableTileId.

Referenced by yaze::zelda3::Overworld::AutoDetectDiggableTiles(), and yaze::editor::DrawDiggableTilesEditorPopup().

Here is the call graph for this function:

◆ FromBytes()

void yaze::zelda3::DiggableTiles::FromBytes ( const uint8_t * data)

Load bitfield from raw bytes (64 bytes).

Definition at line 60 of file diggable_tiles.cc.

References bitfield_, and yaze::zelda3::kDiggableTilesBitfieldSize.

Referenced by yaze::zelda3::Overworld::LoadDiggableTiles().

◆ ToBytes()

void yaze::zelda3::DiggableTiles::ToBytes ( uint8_t * data) const

Write bitfield to raw bytes (64 bytes).

Definition at line 64 of file diggable_tiles.cc.

References bitfield_, and yaze::zelda3::kDiggableTilesBitfieldSize.

◆ GetRawData()

const std::array< uint8_t, kDiggableTilesBitfieldSize > & yaze::zelda3::DiggableTiles::GetRawData ( ) const
inline

Get raw bitfield data for direct ROM writing.

Definition at line 84 of file diggable_tiles.h.

References bitfield_.

Referenced by yaze::zelda3::DiggableTilesPatch::GenerateDataTable(), and yaze::zelda3::Overworld::SaveDiggableTiles().

◆ IsTile16Diggable()

bool yaze::zelda3::DiggableTiles::IsTile16Diggable ( const gfx::Tile16 & tile16,
const std::array< uint8_t, 0x200 > & all_tiles_types )
static

Check if a Tile16 should be diggable based on its component tiles.

A Tile16 is considered diggable if ALL 4 of its component Tile8s have tile type 0x48 or 0x4A (diggable ground) in the tile types array.

Parameters
tile16The Tile16 to check
all_tiles_typesThe tile types array from ROM (512 entries)
Returns
true if all 4 component tiles are diggable types

Definition at line 68 of file diggable_tiles.cc.

References yaze::zelda3::kTileTypeDiggable1, yaze::zelda3::kTileTypeDiggable2, yaze::gfx::Tile16::tile0_, yaze::gfx::Tile16::tile1_, yaze::gfx::Tile16::tile2_, and yaze::gfx::Tile16::tile3_.

Referenced by yaze::zelda3::Overworld::AutoDetectDiggableTiles(), and yaze::editor::DrawDiggableTilesEditorPopup().

Member Data Documentation

◆ bitfield_

std::array<uint8_t, kDiggableTilesBitfieldSize> yaze::zelda3::DiggableTiles::bitfield_ = {}
private

Definition at line 103 of file diggable_tiles.h.

Referenced by Clear(), FromBytes(), GetRawData(), IsDiggable(), SetDiggable(), and ToBytes().


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