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

Loads and queries the hack manifest JSON for yaze-ASM integration. More...

#include <hack_manifest.h>

Collaboration diagram for yaze::core::HackManifest:

Public Member Functions

 HackManifest ()=default
 
absl::Status LoadFromFile (const std::string &filepath)
 Load manifest from a JSON file path.
 
absl::Status LoadFromString (const std::string &json_content)
 Load manifest from a JSON string.
 
bool loaded () const
 Check if the manifest has been loaded.
 
void Clear ()
 Clear any loaded manifest state.
 
AddressOwnership ClassifyAddress (uint32_t address) const
 Classify a ROM address by ownership.
 
bool IsWriteOverwritten (uint32_t address) const
 Check if a ROM write at this address would be overwritten by asar.
 
bool IsProtected (uint32_t address) const
 Check if an address is in a protected region.
 
std::optional< AddressOwnershipGetBankOwnership (uint8_t bank) const
 Get the bank ownership for a given bank number.
 
std::string GetRoomTagLabel (uint8_t tag_id) const
 Get the human-readable label for a room tag ID.
 
std::optional< RoomTagEntryGetRoomTag (uint8_t tag_id) const
 Get the full room tag entry for a tag ID.
 
const std::vector< RoomTagEntry > & room_tags () const
 Get all room tags.
 
bool IsFeatureEnabled (const std::string &flag_name) const
 
const std::vector< FeatureFlag > & feature_flags () const
 
std::string GetSramVariableName (uint32_t address) const
 
const std::vector< SramVariable > & sram_variables () const
 
const MessageLayoutmessage_layout () const
 
bool IsExpandedMessage (uint16_t message_id) const
 
const std::vector< ProtectedRegion > & protected_regions () const
 
const std::unordered_map< uint8_t, OwnedBank > & owned_banks () const
 
std::vector< WriteConflictAnalyzeWriteRanges (const std::vector< std::pair< uint32_t, uint32_t > > &ranges) const
 Analyze a set of address ranges for write conflicts.
 
std::vector< WriteConflictAnalyzePcWriteRanges (const std::vector< std::pair< uint32_t, uint32_t > > &pc_ranges) const
 Analyze a set of PC-offset ranges for write conflicts.
 
absl::Status LoadProjectRegistry (const std::string &code_folder)
 Load project registry data from the code folder.
 
const ProjectRegistryproject_registry () const
 
bool HasProjectRegistry () const
 
void SetOracleProgressionState (const OracleProgressionState &state)
 
void ClearOracleProgressionState ()
 
std::optional< OracleProgressionStateoracle_progression_state () const
 
const BuildPipelinebuild_pipeline () const
 
const std::string & hack_name () const
 
int manifest_version () const
 
int total_hooks () const
 

Private Member Functions

void Reset ()
 

Private Attributes

bool loaded_ = false
 
int manifest_version_ = 0
 
std::string hack_name_
 
int total_hooks_ = 0
 
std::vector< ProtectedRegionprotected_regions_
 
std::unordered_map< uint8_t, OwnedBankowned_banks_
 
std::unordered_map< uint8_t, RoomTagEntryroom_tag_map_
 
std::vector< RoomTagEntryroom_tags_
 
std::unordered_map< std::string, FeatureFlagfeature_flag_map_
 
std::vector< FeatureFlagfeature_flags_
 
std::unordered_map< uint32_t, SramVariablesram_map_
 
std::vector< SramVariablesram_variables_
 
MessageLayout message_layout_ {}
 
BuildPipeline build_pipeline_
 
ProjectRegistry project_registry_
 
std::optional< OracleProgressionStateoracle_progression_state_
 

Detailed Description

Loads and queries the hack manifest JSON for yaze-ASM integration.

The manifest describes which ROM addresses belong to the ASM hack layer versus the yaze editing layer. This enables yaze to:

  1. Skip writing to hook addresses (asar overwrites them anyway)
  2. Warn when the user edits shared data that requires a rebuild
  3. Display room tag labels and SRAM variable names
  4. Show feature flag status in the project settings panel

Usage: HackManifest manifest; auto status = manifest.LoadFromFile("hack_manifest.json"); if (status.ok()) { auto ownership = manifest.ClassifyAddress(0x0085C4); // ownership == AddressOwnership::kHookPatched

auto tag_name = manifest.GetRoomTagLabel(0x39); // tag_name == "CustomTag" }

Definition at line 223 of file hack_manifest.h.

Constructor & Destructor Documentation

◆ HackManifest()

yaze::core::HackManifest::HackManifest ( )
default

Member Function Documentation

◆ LoadFromFile()

absl::Status yaze::core::HackManifest::LoadFromFile ( const std::string & filepath)

Load manifest from a JSON file path.

Definition at line 119 of file hack_manifest.cc.

References LoadFromString().

Referenced by yaze::project::YazeProject::TryLoadHackManifest().

Here is the call graph for this function:

◆ LoadFromString()

absl::Status yaze::core::HackManifest::LoadFromString ( const std::string & json_content)

Load manifest from a JSON string.

Definition at line 129 of file hack_manifest.cc.

References yaze::core::RoomTagEntry::address, yaze::core::SramVariable::address, yaze::core::BuildPipeline::assembler, ASSIGN_OR_RETURN, yaze::core::OwnedBank::bank, yaze::core::OwnedBank::bank_end, yaze::core::OwnedBank::bank_start, build_pipeline_, yaze::core::BuildPipeline::build_script, yaze::Json::contains(), yaze::core::MessageLayout::data_end, yaze::core::MessageLayout::data_start, yaze::core::BuildPipeline::dev_rom, yaze::core::RoomTagEntry::enabled, yaze::core::FeatureFlag::enabled, yaze::core::ProtectedRegion::end, yaze::core::BuildPipeline::entry_point, yaze::core::MessageLayout::expanded_count, yaze::core::RoomTagEntry::feature_flag, feature_flag_map_, feature_flags_, yaze::core::MessageLayout::first_expanded_id, hack_name_, yaze::core::MessageLayout::hook_address, yaze::core::ProtectedRegion::hook_count, yaze::core::MessageLayout::last_expanded_id, loaded_, manifest_version_, message_layout_, yaze::core::RoomTagEntry::name, yaze::core::FeatureFlag::name, yaze::core::SramVariable::name, owned_banks_, yaze::core::OwnedBank::ownership, yaze::core::OwnedBank::ownership_note, yaze::Json::parse(), yaze::core::BuildPipeline::patched_rom, protected_regions_, yaze::core::RoomTagEntry::purpose, yaze::core::SramVariable::purpose, Reset(), room_tag_map_, room_tags_, yaze::core::RoomTagEntry::source, yaze::core::FeatureFlag::source, sram_map_, sram_variables_, yaze::core::ProtectedRegion::start, yaze::core::RoomTagEntry::tag_id, total_hooks_, yaze::core::FeatureFlag::value, yaze::Json::value(), and yaze::core::MessageLayout::vanilla_count.

Referenced by LoadFromFile().

Here is the call graph for this function:

◆ loaded()

◆ Clear()

void yaze::core::HackManifest::Clear ( )
inline

Clear any loaded manifest state.

This is primarily used when switching projects to ensure we never keep a stale manifest across loads.

Definition at line 248 of file hack_manifest.h.

References Reset().

Referenced by yaze::project::YazeProject::TryLoadHackManifest().

Here is the call graph for this function:

◆ ClassifyAddress()

AddressOwnership yaze::core::HackManifest::ClassifyAddress ( uint32_t address) const

Classify a ROM address by ownership.

Checks in order:

  1. Is it in an owned/shared/expansion bank?
  2. Is it in a protected region (vanilla hook)?
  3. Otherwise: vanilla safe

Definition at line 292 of file hack_manifest.cc.

References IsProtected(), yaze::core::kHookPatched, yaze::core::kVanillaSafe, loaded_, and owned_banks_.

Referenced by IsWriteOverwritten().

Here is the call graph for this function:

◆ IsWriteOverwritten()

bool yaze::core::HackManifest::IsWriteOverwritten ( uint32_t address) const

Check if a ROM write at this address would be overwritten by asar.

Returns true for hook_patched, asm_owned, and asm_expansion addresses. For shared addresses, returns false (yaze can write, but must rebuild).

Definition at line 313 of file hack_manifest.cc.

References ClassifyAddress(), yaze::core::kAsmExpansion, yaze::core::kAsmOwned, and yaze::core::kHookPatched.

Here is the call graph for this function:

◆ IsProtected()

bool yaze::core::HackManifest::IsProtected ( uint32_t address) const

Check if an address is in a protected region.

Definition at line 320 of file hack_manifest.cc.

References protected_regions_.

Referenced by ClassifyAddress().

◆ GetBankOwnership()

std::optional< AddressOwnership > yaze::core::HackManifest::GetBankOwnership ( uint8_t bank) const

Get the bank ownership for a given bank number.

Definition at line 339 of file hack_manifest.cc.

References owned_banks_.

◆ GetRoomTagLabel()

std::string yaze::core::HackManifest::GetRoomTagLabel ( uint8_t tag_id) const

Get the human-readable label for a room tag ID.

Definition at line 350 of file hack_manifest.cc.

References room_tag_map_.

Referenced by yaze::zelda3::ResourceLabelProvider::GetLabel().

◆ GetRoomTag()

std::optional< RoomTagEntry > yaze::core::HackManifest::GetRoomTag ( uint8_t tag_id) const

Get the full room tag entry for a tag ID.

Definition at line 357 of file hack_manifest.cc.

References room_tag_map_.

Referenced by yaze::editor::RoomTagEditorPanel::DrawQuickAssign(), and yaze::editor::RoomTagEditorPanel::DrawTagTable().

◆ room_tags()

const std::vector< RoomTagEntry > & yaze::core::HackManifest::room_tags ( ) const
inline

Get all room tags.

Definition at line 296 of file hack_manifest.h.

References room_tags_.

Referenced by yaze::editor::SettingsPanel::DrawProjectSettings().

◆ IsFeatureEnabled()

bool yaze::core::HackManifest::IsFeatureEnabled ( const std::string & flag_name) const

Definition at line 364 of file hack_manifest.cc.

References feature_flag_map_.

◆ feature_flags()

const std::vector< FeatureFlag > & yaze::core::HackManifest::feature_flags ( ) const
inline

◆ GetSramVariableName()

std::string yaze::core::HackManifest::GetSramVariableName ( uint32_t address) const

Definition at line 473 of file hack_manifest.cc.

References sram_map_.

◆ sram_variables()

const std::vector< SramVariable > & yaze::core::HackManifest::sram_variables ( ) const
inline

◆ message_layout()

const MessageLayout & yaze::core::HackManifest::message_layout ( ) const
inline

◆ IsExpandedMessage()

bool yaze::core::HackManifest::IsExpandedMessage ( uint16_t message_id) const

◆ protected_regions()

const std::vector< ProtectedRegion > & yaze::core::HackManifest::protected_regions ( ) const
inline

Definition at line 326 of file hack_manifest.h.

References protected_regions_.

Referenced by yaze::editor::ManifestPanel::DrawProtectedRegions().

◆ owned_banks()

const std::unordered_map< uint8_t, OwnedBank > & yaze::core::HackManifest::owned_banks ( ) const
inline

Definition at line 330 of file hack_manifest.h.

References owned_banks_.

◆ AnalyzeWriteRanges()

std::vector< WriteConflict > yaze::core::HackManifest::AnalyzeWriteRanges ( const std::vector< std::pair< uint32_t, uint32_t > > & ranges) const

Analyze a set of address ranges for write conflicts.

For each range [start, end), checks if any addresses are owned by the ASM layer. Returns one WriteConflict per conflicting region (not per byte). Useful for pre-save diagnostics in the dungeon/overworld editors.

Definition at line 371 of file hack_manifest.cc.

References yaze::core::WriteConflict::address, yaze::core::kHookPatched, loaded_, owned_banks_, yaze::core::WriteConflict::ownership, and protected_regions_.

Referenced by AnalyzePcWriteRanges().

◆ AnalyzePcWriteRanges()

std::vector< WriteConflict > yaze::core::HackManifest::AnalyzePcWriteRanges ( const std::vector< std::pair< uint32_t, uint32_t > > & pc_ranges) const

Analyze a set of PC-offset ranges for write conflicts.

Editors typically operate on raw ROM offsets (PC). The hack manifest uses SNES addresses (LoROM) as emitted by org $XXXXXX in ASM.

This helper converts PC ranges to SNES ranges (splitting at LoROM bank boundaries) and then runs the same conflict analysis.

Definition at line 441 of file hack_manifest.cc.

References AnalyzeWriteRanges(), loaded_, and yaze::PcToSnes().

Referenced by yaze::editor::EditorManager::SaveRom().

Here is the call graph for this function:

◆ LoadProjectRegistry()

absl::Status yaze::core::HackManifest::LoadProjectRegistry ( const std::string & code_folder)

Load project registry data from the code folder.

Loads dungeons.json, overworld.json, and resource labels from oracle_resource_labels.json (unified) or oracle_room_labels.json (legacy).

Definition at line 489 of file hack_manifest.cc.

References yaze::core::ProjectRegistry::all_resource_labels, yaze::core::OverworldArea::area_id, yaze::core::StoryEventGraph::AutoLayout(), yaze::core::DungeonRoom::blockset, yaze::Json::contains(), yaze::core::DungeonConnection::direction, yaze::core::DungeonEntry::doors, yaze::core::ProjectRegistry::dungeons, yaze::core::StoryEventGraph::edges(), yaze::core::DungeonConnection::from_room, yaze::core::DungeonRoom::grid_col, yaze::core::OverworldArea::grid_col, yaze::core::DungeonRoom::grid_row, yaze::core::OverworldArea::grid_row, yaze::core::DungeonEntry::holewarps, yaze::core::DungeonRoom::id, yaze::core::DungeonEntry::id, yaze::Json::is_array(), yaze::Json::is_object(), yaze::Json::items(), yaze::core::DungeonConnection::label, yaze::core::StoryEventGraph::LoadFromJson(), LOG_DEBUG, LOG_WARN, yaze::core::DungeonRoom::name, yaze::core::DungeonEntry::name, yaze::core::OverworldArea::name, yaze::core::StoryEventGraph::nodes(), oracle_progression_state_, yaze::core::ProjectRegistry::overworld_areas, yaze::core::DungeonRoom::palette, yaze::Json::parse(), project_registry_, yaze::core::DungeonEntry::rooms, yaze::core::DungeonRoom::spriteset, yaze::core::DungeonEntry::stairs, yaze::core::ProjectRegistry::story_events, yaze::core::DungeonRoom::tag1, yaze::core::DungeonRoom::tag2, yaze::core::DungeonConnection::to_room, yaze::core::DungeonRoom::type, yaze::core::StoryEventGraph::UpdateStatus(), yaze::core::DungeonEntry::vanilla_name, and yaze::core::OverworldArea::world.

Referenced by yaze::project::YazeProject::TryLoadHackManifest().

◆ project_registry()

◆ HasProjectRegistry()

◆ SetOracleProgressionState()

◆ ClearOracleProgressionState()

◆ oracle_progression_state()

◆ build_pipeline()

const BuildPipeline & yaze::core::HackManifest::build_pipeline ( ) const
inline

Definition at line 396 of file hack_manifest.h.

References build_pipeline_.

Referenced by yaze::editor::SettingsPanel::DrawProjectSettings().

◆ hack_name()

const std::string & yaze::core::HackManifest::hack_name ( ) const
inline

Definition at line 402 of file hack_manifest.h.

References hack_name_.

Referenced by yaze::editor::SettingsPanel::DrawProjectSettings().

◆ manifest_version()

int yaze::core::HackManifest::manifest_version ( ) const
inline

Definition at line 403 of file hack_manifest.h.

References manifest_version_.

Referenced by yaze::editor::SettingsPanel::DrawProjectSettings().

◆ total_hooks()

int yaze::core::HackManifest::total_hooks ( ) const
inline

Definition at line 404 of file hack_manifest.h.

References total_hooks_.

Referenced by yaze::editor::SettingsPanel::DrawProjectSettings().

◆ Reset()

Member Data Documentation

◆ loaded_

bool yaze::core::HackManifest::loaded_ = false
private

◆ manifest_version_

int yaze::core::HackManifest::manifest_version_ = 0
private

Definition at line 410 of file hack_manifest.h.

Referenced by LoadFromString(), manifest_version(), and Reset().

◆ hack_name_

std::string yaze::core::HackManifest::hack_name_
private

Definition at line 411 of file hack_manifest.h.

Referenced by hack_name(), LoadFromString(), and Reset().

◆ total_hooks_

int yaze::core::HackManifest::total_hooks_ = 0
private

Definition at line 412 of file hack_manifest.h.

Referenced by LoadFromString(), Reset(), and total_hooks().

◆ protected_regions_

std::vector<ProtectedRegion> yaze::core::HackManifest::protected_regions_
private

◆ owned_banks_

std::unordered_map<uint8_t, OwnedBank> yaze::core::HackManifest::owned_banks_
private

◆ room_tag_map_

std::unordered_map<uint8_t, RoomTagEntry> yaze::core::HackManifest::room_tag_map_
private

Definition at line 421 of file hack_manifest.h.

Referenced by GetRoomTag(), GetRoomTagLabel(), LoadFromString(), and Reset().

◆ room_tags_

std::vector<RoomTagEntry> yaze::core::HackManifest::room_tags_
private

Definition at line 422 of file hack_manifest.h.

Referenced by LoadFromString(), Reset(), and room_tags().

◆ feature_flag_map_

std::unordered_map<std::string, FeatureFlag> yaze::core::HackManifest::feature_flag_map_
private

Definition at line 425 of file hack_manifest.h.

Referenced by IsFeatureEnabled(), LoadFromString(), and Reset().

◆ feature_flags_

std::vector<FeatureFlag> yaze::core::HackManifest::feature_flags_
private

Definition at line 426 of file hack_manifest.h.

Referenced by feature_flags(), LoadFromString(), and Reset().

◆ sram_map_

std::unordered_map<uint32_t, SramVariable> yaze::core::HackManifest::sram_map_
private

Definition at line 429 of file hack_manifest.h.

Referenced by GetSramVariableName(), LoadFromString(), and Reset().

◆ sram_variables_

std::vector<SramVariable> yaze::core::HackManifest::sram_variables_
private

Definition at line 430 of file hack_manifest.h.

Referenced by LoadFromString(), Reset(), and sram_variables().

◆ message_layout_

MessageLayout yaze::core::HackManifest::message_layout_ {}
private

Definition at line 433 of file hack_manifest.h.

Referenced by IsExpandedMessage(), LoadFromString(), message_layout(), and Reset().

◆ build_pipeline_

BuildPipeline yaze::core::HackManifest::build_pipeline_
private

Definition at line 436 of file hack_manifest.h.

Referenced by build_pipeline(), LoadFromString(), and Reset().

◆ project_registry_

ProjectRegistry yaze::core::HackManifest::project_registry_
private

◆ oracle_progression_state_

std::optional<OracleProgressionState> yaze::core::HackManifest::oracle_progression_state_
private

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