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, kDiggableTilesBitfieldSize > | bitfield_ = {} |
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.
|
default |
| 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().
| 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().
| void yaze::zelda3::DiggableTiles::Clear | ( | ) |
Clear all diggable bits.
Definition at line 29 of file diggable_tiles.cc.
References bitfield_.
Referenced by yaze::zelda3::Overworld::AutoDetectDiggableTiles(), yaze::editor::DrawDiggableTilesEditorPopup(), and 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().

| 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().

| 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().

| 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().
| 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.
|
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().
|
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.
| tile16 | The Tile16 to check |
| all_tiles_types | The tile types array from ROM (512 entries) |
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().
|
private |
Definition at line 103 of file diggable_tiles.h.
Referenced by Clear(), FromBytes(), GetRawData(), IsDiggable(), SetDiggable(), and ToBytes().