yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
rom_diff_tool.h
Go to the documentation of this file.
1
9#ifndef YAZE_SRC_CLI_SERVICE_AGENT_TOOLS_ROM_DIFF_TOOL_H_
10#define YAZE_SRC_CLI_SERVICE_AGENT_TOOLS_ROM_DIFF_TOOL_H_
11
12#include <cstdint>
13#include <string>
14#include <vector>
15
16#include "absl/status/status.h"
18
19namespace yaze {
20namespace cli {
21namespace agent {
22namespace tools {
23
27struct RomDiff {
28 uint32_t address;
29 uint32_t length;
30 std::vector<uint8_t> old_value;
31 std::vector<uint8_t> new_value;
32 std::string category; // "tiles", "sprites", "code", "data", etc.
33 std::string description;
34};
35
41 size_t num_regions = 0;
42 std::map<std::string, int> changes_by_category;
43 std::vector<RomDiff> diffs;
44};
45
52 public:
53 std::string GetName() const override { return "rom-diff"; }
54
55 std::string GetDescription() const {
56 return "Compare two ROM files and identify differences";
57 }
58
59 std::string GetUsage() const override {
60 return "rom-diff --rom1=<path> --rom2=<path> [--semantic] [--format=<json|text>]";
61 }
62
63 protected:
64 absl::Status ValidateArgs(const resources::ArgumentParser& parser) override {
65 return parser.RequireArgs({"rom1", "rom2"});
66 }
67
68 absl::Status Execute(Rom* rom, const resources::ArgumentParser& parser,
69 resources::OutputFormatter& formatter) override;
70
71 bool RequiresRom() const override { return false; }
72
73 private:
74 DiffSummary ComputeDiff(const std::vector<uint8_t>& rom1,
75 const std::vector<uint8_t>& rom2,
76 bool semantic);
77
78 std::string CategorizeAddress(uint32_t address) const;
79 std::string DescribeChange(uint32_t address, const std::vector<uint8_t>& old_val,
80 const std::vector<uint8_t>& new_val) const;
81
82 std::string FormatAsJson(const DiffSummary& summary) const;
83 std::string FormatAsText(const DiffSummary& summary) const;
84};
85
94 public:
95 std::string GetName() const override { return "rom-changes"; }
96
97 std::string GetDescription() const {
98 return "Analyze what game elements changed between two ROMs";
99 }
100
101 std::string GetUsage() const override {
102 return "rom-changes --rom1=<path> --rom2=<path> [--format=<json|text>]";
103 }
104
105 protected:
106 absl::Status ValidateArgs(const resources::ArgumentParser& parser) override {
107 return parser.RequireArgs({"rom1", "rom2"});
108 }
109
110 absl::Status Execute(Rom* rom, const resources::ArgumentParser& parser,
111 resources::OutputFormatter& formatter) override;
112
113 bool RequiresRom() const override { return false; }
114};
115
116} // namespace tools
117} // namespace agent
118} // namespace cli
119} // namespace yaze
120
121#endif // YAZE_SRC_CLI_SERVICE_AGENT_TOOLS_ROM_DIFF_TOOL_H_
122
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:24
Analyze what game elements changed between two ROMs.
bool RequiresRom() const override
Check if the command requires a loaded ROM.
std::string GetName() const override
Get the command name.
absl::Status Execute(Rom *rom, const resources::ArgumentParser &parser, resources::OutputFormatter &formatter) override
Execute the command business logic.
absl::Status ValidateArgs(const resources::ArgumentParser &parser) override
Validate command arguments.
std::string GetUsage() const override
Get the command usage string.
Compare two ROM files and identify differences.
std::string DescribeChange(uint32_t address, const std::vector< uint8_t > &old_val, const std::vector< uint8_t > &new_val) const
DiffSummary ComputeDiff(const std::vector< uint8_t > &rom1, const std::vector< uint8_t > &rom2, bool semantic)
absl::Status Execute(Rom *rom, const resources::ArgumentParser &parser, resources::OutputFormatter &formatter) override
Execute the command business logic.
bool RequiresRom() const override
Check if the command requires a loaded ROM.
std::string GetUsage() const override
Get the command usage string.
std::string FormatAsJson(const DiffSummary &summary) const
std::string CategorizeAddress(uint32_t address) const
absl::Status ValidateArgs(const resources::ArgumentParser &parser) override
Validate command arguments.
std::string FormatAsText(const DiffSummary &summary) const
std::string GetName() const override
Get the command name.
Utility for parsing common CLI argument patterns.
absl::Status RequireArgs(const std::vector< std::string > &required) const
Validate that required arguments are present.
Base class for CLI command handlers.
Utility for consistent output formatting across commands.
Summary of differences between two ROMs.
std::map< std::string, int > changes_by_category
A single difference between two ROMs.
std::vector< uint8_t > new_value
std::vector< uint8_t > old_value