yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
rom_commands.h
Go to the documentation of this file.
1#ifndef YAZE_SRC_CLI_HANDLERS_ROM_COMMANDS_H_
2#define YAZE_SRC_CLI_HANDLERS_ROM_COMMANDS_H_
3
4#include <cstdint>
5#include <vector>
6
8
9namespace yaze {
10namespace cli {
11namespace handlers {
12
21absl::Status ApplyRawRomWrite(Rom* rom, uint32_t address,
22 const std::vector<uint8_t>& bytes,
23 const resources::ArgumentParser& parser,
24 resources::OutputFormatter& formatter);
25
30 public:
31 std::string GetName() const override { return "rom-read"; }
32 std::string GetDescription() const {
33 return "Read raw bytes from ROM at an address";
34 }
35 std::string GetUsage() const override {
36 return "rom-read --address <hex> [--length <bytes>] "
37 "[--data-format <hex|ascii|both>] [--format <json|text>]";
38 }
39
40 absl::Status ValidateArgs(const resources::ArgumentParser& parser) override {
41 return parser.RequireArgs({"address"});
42 }
43
44 absl::Status Execute(Rom* rom, const resources::ArgumentParser& parser,
45 resources::OutputFormatter& formatter) override;
46};
47
52 public:
53 std::string GetName() const override { return "rom-write"; }
54 std::string GetDescription() const {
55 return "Write raw bytes to ROM at an address (dry-run unless --write)";
56 }
57 std::string GetUsage() const override {
58 return "rom-write --address <hex> --data <hex_string> [--write] "
59 "[--allow-project-rom]";
60 }
61
62 absl::Status ValidateArgs(const resources::ArgumentParser& parser) override {
63 return parser.RequireArgs({"address", "data"});
64 }
65
66 absl::Status Execute(Rom* rom, const resources::ArgumentParser& parser,
67 resources::OutputFormatter& formatter) override;
68};
69
74 public:
75 std::string GetName() const override { return "rom-info"; }
76 std::string GetDescription() const { return "Display ROM information"; }
77 std::string GetUsage() const override { return "rom-info"; }
78
79 absl::Status ValidateArgs(const resources::ArgumentParser& parser) override {
80 return absl::OkStatus();
81 }
82
83 absl::Status Execute(Rom* rom, const resources::ArgumentParser& parser,
84 resources::OutputFormatter& formatter) override;
85};
86
91 public:
92 std::string GetName() const override { return "rom-validate"; }
93 std::string GetDescription() const { return "Validate ROM file integrity"; }
94 std::string GetUsage() const override { return "rom-validate"; }
95
96 absl::Status ValidateArgs(const resources::ArgumentParser& parser) override {
97 return absl::OkStatus();
98 }
99
100 absl::Status Execute(Rom* rom, const resources::ArgumentParser& parser,
101 resources::OutputFormatter& formatter) override;
102};
103
108 public:
109 std::string GetName() const override { return "rom-diff"; }
110 std::string GetDescription() const { return "Compare two ROM files"; }
111 std::string GetUsage() const override {
112 return "rom-diff --rom_a <file> --rom_b <file>";
113 }
114 bool RequiresRom() const override { return false; }
115
116 absl::Status ValidateArgs(const resources::ArgumentParser& parser) override {
117 return parser.RequireArgs({"rom_a", "rom_b"});
118 }
119
120 absl::Status Execute(Rom* rom, const resources::ArgumentParser& parser,
121 resources::OutputFormatter& formatter) override;
122};
123
128 public:
129 std::string GetName() const override { return "rom-generate-golden"; }
130 std::string GetDescription() const {
131 return "Generate golden ROM file for testing";
132 }
133 std::string GetUsage() const override {
134 return "rom-generate-golden --rom_file <file> --golden_file <file>";
135 }
136 bool RequiresRom() const override { return false; }
137
138 absl::Status ValidateArgs(const resources::ArgumentParser& parser) override {
139 return parser.RequireArgs({"rom_file", "golden_file"});
140 }
141
142 absl::Status Execute(Rom* rom, const resources::ArgumentParser& parser,
143 resources::OutputFormatter& formatter) override;
144};
145
150 public:
151 std::string GetName() const override { return "rom-resolve-address"; }
152 std::string GetDescription() const {
153 return "Resolve an address to a symbol name";
154 }
155 std::string GetUsage() const override {
156 return "rom-resolve-address --address <hex> [--max-offset <bytes>]";
157 }
158
159 absl::Status ValidateArgs(const resources::ArgumentParser& parser) override {
160 return parser.RequireArgs({"address"});
161 }
162
163 absl::Status Execute(Rom* rom, const resources::ArgumentParser& parser,
164 resources::OutputFormatter& formatter) override;
165};
166
171 public:
172 std::string GetName() const override { return "rom-find-symbol"; }
173 std::string GetDescription() const {
174 return "Find a symbol by name or pattern";
175 }
176 std::string GetUsage() const override {
177 return "rom-find-symbol --name <string>";
178 }
179
180 absl::Status ValidateArgs(const resources::ArgumentParser& parser) override {
181 return parser.RequireArgs({"name"});
182 }
183
184 absl::Status Execute(Rom* rom, const resources::ArgumentParser& parser,
185 resources::OutputFormatter& formatter) override;
186};
187
188} // namespace handlers
189} // namespace cli
190} // namespace yaze
191
192#endif // YAZE_SRC_CLI_HANDLERS_ROM_COMMANDS_H_
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:52
Command handler for comparing ROM files.
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 GetName() const override
Get the command name.
std::string GetUsage() const override
Get the command usage string.
absl::Status ValidateArgs(const resources::ArgumentParser &parser) override
Validate command arguments.
Command handler for finding a symbol by name.
absl::Status ValidateArgs(const resources::ArgumentParser &parser) override
Validate command arguments.
std::string GetName() const override
Get the command name.
std::string GetUsage() const override
Get the command usage string.
absl::Status Execute(Rom *rom, const resources::ArgumentParser &parser, resources::OutputFormatter &formatter) override
Execute the command business logic.
Command handler for generating golden ROM files.
bool RequiresRom() const override
Check if the command requires a loaded ROM.
std::string GetUsage() const override
Get the command usage string.
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 GetName() const override
Get the command name.
Command handler for displaying ROM information.
absl::Status ValidateArgs(const resources::ArgumentParser &parser) override
Validate command arguments.
std::string GetUsage() const override
Get the command usage string.
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.
Command handler for reading raw ROM bytes.
std::string GetUsage() const override
Get the command usage string.
std::string GetName() const override
Get the command name.
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.
Command handler for resolving an address to a symbol.
std::string GetName() const override
Get the command name.
absl::Status ValidateArgs(const resources::ArgumentParser &parser) override
Validate command arguments.
std::string GetUsage() const override
Get the command usage string.
absl::Status Execute(Rom *rom, const resources::ArgumentParser &parser, resources::OutputFormatter &formatter) override
Execute the command business logic.
Command handler for validating ROM files.
absl::Status ValidateArgs(const resources::ArgumentParser &parser) override
Validate command arguments.
std::string GetUsage() const override
Get the command usage string.
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.
Command handler for writing raw ROM bytes.
std::string GetUsage() const override
Get the command usage string.
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.
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.
absl::Status ApplyRawRomWrite(Rom *rom, uint32_t address, const std::vector< uint8_t > &bytes, const resources::ArgumentParser &parser, resources::OutputFormatter &formatter)
Shared body of rom-write and hex-write.