yaze 0.2.0
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
z3ed.cc
Go to the documentation of this file.
1#include <cstdint>
2#include <cstring>
3#include <iostream>
4#include <memory>
5#include <sstream>
6#include <string>
7#include <string_view>
8#include <unordered_map>
9#include <vector>
10
11#include "absl/flags/flag.h"
12#include "absl/status/status.h"
13#include "app/core/constants.h"
14#include "app/rom.h"
15#include "cli/command.h"
16
17ABSL_FLAG(bool, verbose, false, "Enable verbose output");
18ABSL_FLAG(bool, debug, false, "Enable debug output");
19
20namespace yaze {
21
26namespace cli {
27namespace {
28
35 std::cout << "\n";
36 std::cout << ylw << " ▲ " << reset << " z3ed\n";
37 std::cout << ylw << "▲ ▲ " << reset << " by " << mag << "scawful\n\n"
38 << reset;
39 std::cout << "The Legend of " << red << "Zelda" << reset
40 << ": A Link to the Past Hacking Tool\n\n";
41 std::cout << underline;
42 std::cout << "Command" << reset << " " << underline << "Arg"
43 << reset << " " << underline << "Params\n"
44 << reset;
45
46 std::cout << "Apply BPS Patch -a <rom_file> <bps_file>\n";
47 std::cout << "Create BPS Patch -c <bps_file> <src_file> "
48 "<modified_file>\n\n";
49
50 std::cout << "Open ROM -o <rom_file>\n";
51 std::cout << "Backup ROM -b <rom_file> <optional:new_file>\n";
52 std::cout << "Expand ROM -x <rom_file> <file_size>\n\n";
53
54 std::cout << "Transfer Tile16 -t <src_rom> <dest_rom> "
55 "<tile32_id_list:csv>\n\n";
56
57 std::cout << "Export Graphics -e <rom_file> <bin_file>\n";
58 std::cout << "Import Graphics -i <bin_file> <rom_file>\n\n";
59
60 std::cout << "SNES to PC Address -s <address>\n";
61 std::cout << "PC to SNES Address -p <address>\n";
62 std::cout << "\n";
63}
64
65int RunCommandHandler(int argc, char* argv[]) {
66 if (argc == 1) {
68 return EXIT_SUCCESS;
69 }
70
71 if (std::strcmp(argv[1], "-h") == 0 || argc == 1) {
73 return EXIT_SUCCESS;
74 }
75
76 std::vector<std::string> arguments;
77 for (int i = 2; i < argc; i++) { // Skip the arg mode (argv[1])
78 std::cout << "argv[" << i << "] = " << argv[i] << std::endl;
79 arguments.emplace_back(argv[i]);
80 }
81
82 Commands commands;
83 std::string mode = argv[1];
84 if (commands.handlers.find(mode) != commands.handlers.end()) {
85 PRINT_IF_ERROR(commands.handlers[mode]->handle(arguments))
86 } else {
87 std::cerr << "Invalid mode specified: " << mode << std::endl;
88 }
89 return EXIT_SUCCESS;
90}
91
92} // namespace
93} // namespace cli
94} // namespace yaze
95
96int main(int argc, char* argv[]) {
97 return yaze::cli::RunCommandHandler(argc, argv);
98}
#define PRINT_IF_ERROR(expression)
Definition constants.h:43
int RunCommandHandler(int argc, char *argv[])
Definition z3ed.cc:65
@ FG_RESET
Definition command.h:37
@ FG_MAGENTA
Definition command.h:35
@ FG_UNDERLINE
Definition command.h:38
@ FG_YELLOW
Definition command.h:33
Definition common.cc:21
Command handler for the CLI.
Definition command.h:246
std::unordered_map< std::string, std::shared_ptr< CommandHandler > > handlers
Definition command.h:247
int main(int argc, char *argv[])
Definition z3ed.cc:96
ABSL_FLAG(bool, verbose, false, "Enable verbose output")