#include #include #include #include #include #include #include #include #include #include "absl/status/status.h" #include "app/core/common.h" #include "app/core/constants.h" #include "app/rom.h" #include "cli/command_handler.h" #include "cli/patch.h" namespace yaze { namespace cli { namespace { void HelpCommand() { Color::Modifier ylw(Color::FG_YELLOW); Color::Modifier mag(Color::FG_MAGENTA); Color::Modifier red(Color::FG_RED); Color::Modifier reset(Color::FG_RESET); Color::Modifier underline(Color::FG_UNDERLINE); std::cout << "\n"; std::cout << ylw << " ▲ " << reset << " z3ed\n"; std::cout << ylw << "▲ ▲ " << reset << " by " << mag << "scawful\n\n" << reset; std::cout << "The Legend of " << red << "Zelda" << reset << ": A Link to the Past Hacking Tool\n\n"; std::cout << underline; std::cout << "Command" << reset << " " << underline << "Arg" << reset << " " << underline << "Params\n" << reset; std::cout << "Apply BPS Patch -a \n"; std::cout << "Create BPS Patch -c " "\n\n"; std::cout << "Open ROM -o \n"; std::cout << "Backup ROM -b \n"; std::cout << "Expand ROM -x \n\n"; std::cout << "Transfer Tile16 -t " "\n\n"; std::cout << "Export Graphics -e \n"; std::cout << "Import Graphics -i \n\n"; std::cout << "SNES to PC Address -s
\n"; std::cout << "PC to SNES Address -p
\n"; std::cout << "\n"; } int RunCommandHandler(int argc, char* argv[]) { if (argv[1] == "-h" || argc == 1) { HelpCommand(); return EXIT_SUCCESS; } std::vector arguments; for (int i = 2; i < argc; i++) { // Skip the arg mode (argv[1]) std::cout << "argv[" << i << "] = " << argv[i] << std::endl; arguments.emplace_back(argv[i]); } Commands commands; std::string mode = argv[1]; if (commands.handlers.find(mode) != commands.handlers.end()) { PRINT_IF_ERROR(commands.handlers[mode]->handle(arguments)) } else { std::cerr << "Invalid mode specified: " << mode << std::endl; } return EXIT_SUCCESS; } } // namespace } // namespace cli } // namespace yaze int main(int argc, char* argv[]) { return yaze::cli::RunCommandHandler(argc, argv); }