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