From 04c083bdfea5f33a14764461f058586074088106 Mon Sep 17 00:00:00 2001 From: scawful Date: Tue, 21 Jan 2025 21:52:13 -0500 Subject: [PATCH] Add additional flag declarations for BPS and file handling in z3ed --- src/cli/z3ed.cc | 86 +++++++++++++++++-------------------------------- 1 file changed, 29 insertions(+), 57 deletions(-) diff --git a/src/cli/z3ed.cc b/src/cli/z3ed.cc index 11211796..7bc0d955 100644 --- a/src/cli/z3ed.cc +++ b/src/cli/z3ed.cc @@ -12,8 +12,30 @@ #include "util/macro.h" DECLARE_FLAG(std::string, rom_file); +DECLARE_FLAG(std::string, bps_file); +DECLARE_FLAG(std::string, src_file); +DECLARE_FLAG(std::string, modified_file); +DECLARE_FLAG(std::string, bin_file); +DECLARE_FLAG(std::string, address); +DECLARE_FLAG(std::string, length); +DECLARE_FLAG(std::string, file_size); +DECLARE_FLAG(std::string, dest_rom); +DECLARE_FLAG(std::string, tile32_id_list); DEFINE_FLAG(std::string, rom_file, "", "The ROM file to load."); +DEFINE_FLAG(std::string, bps_file, "", "The BPS file to apply."); + +DEFINE_FLAG(std::string, src_file, "", "The source file."); +DEFINE_FLAG(std::string, modified_file, "", "The modified file."); + +DEFINE_FLAG(std::string, bin_file, "", "The binary file to export to."); +DEFINE_FLAG(std::string, address, "", "The address to convert."); +DEFINE_FLAG(std::string, length, "", "The length of the data to read."); + +DEFINE_FLAG(std::string, file_size, "", "The size of the file to expand to."); +DEFINE_FLAG(std::string, dest_rom, "", "The destination ROM file."); +DEFINE_FLAG(std::string, tile32_id_list, "", + "The list of tile32 IDs to transfer."); namespace yaze { /** @@ -23,54 +45,7 @@ namespace yaze { namespace cli { namespace { -ColorModifier ylw(ColorCode::FG_YELLOW); -ColorModifier mag(ColorCode::FG_MAGENTA); -ColorModifier red(ColorCode::FG_RED); -ColorModifier reset(ColorCode::FG_RESET); -ColorModifier underline(ColorCode::FG_UNDERLINE); - -void HelpCommand() { - 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 (argc == 1) { - HelpCommand(); - return EXIT_SUCCESS; - } - - if (std::strcmp(argv[1], "-h") == 0 || 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; @@ -93,19 +68,16 @@ int RunCommandHandler(int argc, char *argv[]) { int main(int argc, char *argv[]) { std::vector tokens; - for (int i = 0; i < argc; i++) { - tokens.emplace_back(argv[i]); - } - + std::copy(argv, argv + argc, std::back_inserter(tokens)); yaze::util::FlagParser flag_parser(yaze::util::global_flag_registry()); - try { - flag_parser.Parse(&tokens); - } catch (const std::exception &e) { - std::cerr << "Error parsing flags: " << e.what() << std::endl; - return EXIT_FAILURE; + RETURN_IF_EXCEPTION(flag_parser.Parse(&tokens)); + + for (const auto &flag : yaze::util::global_flag_registry()->AllFlags()) { + // Cast the IFlag to a Flag and use Get + auto flags = dynamic_cast *>(flag); + std::cout << "Flag: " << flag->name() << " = " << flags->Get() << std::endl; } yaze::cli::ShowMain(); return EXIT_SUCCESS; - // return yaze::cli::RunCommandHandler(argc, argv); }