Analyze spritesheets for unused graphics regions. More...
#include <visual_analysis_tool.h>
Public Member Functions | |
| std::string | GetName () const override |
| Get the command name. | |
| std::string | GetDescription () const |
| std::string | GetUsage () const override |
| Get the command usage string. | |
Public Member Functions inherited from yaze::cli::resources::CommandHandler | |
| virtual | ~CommandHandler ()=default |
| absl::Status | Run (const std::vector< std::string > &args, Rom *rom_context, std::string *captured_output=nullptr) |
| Execute the command. | |
| virtual Descriptor | Describe () const |
| Provide metadata for TUI/help summaries. | |
| virtual bool | RequiresRom () const |
| Check if the command requires a loaded ROM. | |
| virtual void | SetProjectContext (project::YazeProject *project) |
| Set the YazeProject context. Default implementation does nothing, override if tool needs project info. | |
| virtual void | SetAsarWrapper (core::AsarWrapper *asar_wrapper) |
| Set the AsarWrapper context. Default implementation does nothing, override if tool needs Asar access. | |
| virtual void | SetRomContext (Rom *rom) |
| Set the ROM context for tools that need ROM access. Default implementation stores the ROM pointer for subclass use. | |
Protected Member Functions | |
| absl::Status | ValidateArgs (const resources::ArgumentParser &parser) override |
| Validate command arguments. | |
| absl::Status | Execute (Rom *rom, const resources::ArgumentParser &parser, resources::OutputFormatter &formatter) override |
| Execute the command business logic. | |
| bool | RequiresLabels () const override |
| Check if the command requires ROM labels. | |
Protected Member Functions inherited from yaze::cli::agent::tools::VisualAnalysisBase | |
| double | ComputePixelDifference (const std::vector< uint8_t > &tile_a, const std::vector< uint8_t > &tile_b) const |
| Compute simple pixel difference (Mean Absolute Error) | |
| double | ComputeStructuralSimilarity (const std::vector< uint8_t > &tile_a, const std::vector< uint8_t > &tile_b) const |
| Compute structural similarity index (SSIM-like) | |
| absl::StatusOr< std::vector< uint8_t > > | ExtractTile (Rom *rom, int sheet_index, int tile_index) const |
| Extract 8x8 tile data from ROM graphics. | |
| absl::StatusOr< std::vector< uint8_t > > | ExtractTileAtPosition (Rom *rom, int sheet_index, int x, int y) const |
| Extract 8x8 tile at specific pixel coordinates. | |
| bool | IsRegionEmpty (const std::vector< uint8_t > &data) const |
| Check if a tile region is empty (all 0x00 or 0xFF) | |
| int | GetTileCountForSheet (int sheet_index) const |
| Get the number of tiles in a graphics sheet. | |
| std::string | FormatMatchesAsJson (const std::vector< TileSimilarityMatch > &matches) const |
| Format similarity matches as JSON. | |
| std::string | FormatRegionsAsJson (const std::vector< UnusedRegion > ®ions) const |
| Format unused regions as JSON. | |
| std::string | FormatPaletteUsageAsJson (const std::vector< PaletteUsageStats > &stats) const |
| Format palette usage as JSON. | |
| std::string | FormatHistogramAsJson (const std::vector< TileUsageEntry > &entries) const |
| Format tile histogram as JSON. | |
Protected Member Functions inherited from yaze::cli::resources::CommandHandler | |
| virtual std::string | GetDefaultFormat () const |
| Get the default output format ("json" or "text") | |
| virtual std::string | GetOutputTitle () const |
| Get the output title for formatting. | |
Private Member Functions | |
| std::vector< UnusedRegion > | FindUnusedRegions (Rom *rom, int sheet_index, int tile_size) const |
| Find contiguous empty regions in a sheet. | |
| std::vector< UnusedRegion > | MergeAdjacentRegions (const std::vector< UnusedRegion > ®ions) const |
| Merge adjacent empty regions. | |
Additional Inherited Members | |
Static Public Attributes inherited from yaze::cli::agent::tools::VisualAnalysisBase | |
| static constexpr int | kTileWidth = 8 |
| static constexpr int | kTileHeight = 8 |
| static constexpr int | kTilePixels = kTileWidth * kTileHeight |
| static constexpr int | kSheetWidth = 128 |
| static constexpr int | kSheetHeight = 32 |
| static constexpr int | kTilesPerRow = kSheetWidth / kTileWidth |
| static constexpr int | kMaxSheets = 223 |
Protected Attributes inherited from yaze::cli::resources::CommandHandler | |
| Rom * | rom_ = nullptr |
| project::YazeProject * | project_ = nullptr |
| core::AsarWrapper * | asar_wrapper_ = nullptr |
Analyze spritesheets for unused graphics regions.
Usage: visual-analyze-spritesheet [–sheet <index>] [–tile_size <8|16>] [–format <json|text>]
Scans graphics sheets for contiguous empty regions that can be used for custom graphics in ROM hacking.
Definition at line 215 of file visual_analysis_tool.h.
|
inlineoverridevirtual |
Get the command name.
Override this to provide a unique identifier for the command. This is used for command registration and lookup.
Implements yaze::cli::resources::CommandHandler.
Definition at line 217 of file visual_analysis_tool.h.
|
inline |
Definition at line 219 of file visual_analysis_tool.h.
|
inlineoverridevirtual |
Get the command usage string.
Implements yaze::cli::resources::CommandHandler.
Definition at line 223 of file visual_analysis_tool.h.
|
overrideprotectedvirtual |
Validate command arguments.
Override this to check required arguments and perform custom validation. Called before Execute().
Implements yaze::cli::resources::CommandHandler.
Definition at line 425 of file visual_analysis_tool.cc.
|
overrideprotectedvirtual |
Execute the command business logic.
Override this to implement command-specific functionality. The ROM is guaranteed to be loaded and labels initialized.
Implements yaze::cli::resources::CommandHandler.
Definition at line 430 of file visual_analysis_tool.cc.
References FindUnusedRegions(), yaze::cli::agent::tools::VisualAnalysisBase::FormatRegionsAsJson(), yaze::cli::resources::ArgumentParser::GetInt(), yaze::cli::resources::ArgumentParser::GetString(), yaze::cli::agent::tools::VisualAnalysisBase::kMaxSheets, and MergeAdjacentRegions().
|
inlineoverrideprotectedvirtual |
Check if the command requires ROM labels.
Override to return false if labels are not needed.
Reimplemented from yaze::cli::resources::CommandHandler.
Definition at line 234 of file visual_analysis_tool.h.
|
private |
Find contiguous empty regions in a sheet.
Definition at line 468 of file visual_analysis_tool.cc.
References yaze::cli::agent::tools::VisualAnalysisBase::ExtractTileAtPosition(), yaze::cli::agent::tools::UnusedRegion::height, yaze::cli::agent::tools::VisualAnalysisBase::IsRegionEmpty(), yaze::cli::agent::tools::VisualAnalysisBase::kSheetHeight, yaze::cli::agent::tools::VisualAnalysisBase::kSheetWidth, yaze::cli::agent::tools::UnusedRegion::sheet_index, yaze::cli::agent::tools::UnusedRegion::tile_count, yaze::cli::agent::tools::UnusedRegion::width, yaze::cli::agent::tools::UnusedRegion::x, and yaze::cli::agent::tools::UnusedRegion::y.
Referenced by Execute().
|
private |
Merge adjacent empty regions.
Definition at line 512 of file visual_analysis_tool.cc.
References yaze::cli::agent::tools::UnusedRegion::tile_count, yaze::cli::agent::tools::UnusedRegion::width, yaze::cli::agent::tools::UnusedRegion::x, and yaze::cli::agent::tools::UnusedRegion::y.
Referenced by Execute().