Add additional flag declarations for BPS and file handling in z3ed
This commit is contained in:
@@ -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 <rom_file> <bps_file>\n";
|
||||
std::cout << "Create BPS Patch -c <bps_file> <src_file> "
|
||||
"<modified_file>\n\n";
|
||||
|
||||
std::cout << "Open ROM -o <rom_file>\n";
|
||||
std::cout << "Backup ROM -b <rom_file> <optional:new_file>\n";
|
||||
std::cout << "Expand ROM -x <rom_file> <file_size>\n\n";
|
||||
|
||||
std::cout << "Transfer Tile16 -t <src_rom> <dest_rom> "
|
||||
"<tile32_id_list:csv>\n\n";
|
||||
|
||||
std::cout << "Export Graphics -e <rom_file> <bin_file>\n";
|
||||
std::cout << "Import Graphics -i <bin_file> <rom_file>\n\n";
|
||||
|
||||
std::cout << "SNES to PC Address -s <address>\n";
|
||||
std::cout << "PC to SNES Address -p <address>\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<std::string> 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<std::string> 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<yaze::util::Flag<std::string> *>(flag);
|
||||
std::cout << "Flag: " << flag->name() << " = " << flags->Get() << std::endl;
|
||||
}
|
||||
|
||||
yaze::cli::ShowMain();
|
||||
return EXIT_SUCCESS;
|
||||
// return yaze::cli::RunCommandHandler(argc, argv);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user