add z3ed cli tool

rom backups
export and import graphics
pc to snes and snes to pc addr conversion
This commit is contained in:
scawful
2023-08-18 11:42:46 -04:00
parent 7e87b1ed45
commit baf7547fff
8 changed files with 588 additions and 54 deletions

78
src/cli/z3ed.cc Normal file
View File

@@ -0,0 +1,78 @@
#include <cstdint>
#include <cstring>
#include <iostream>
#include <memory>
#include <sstream>
#include <string>
#include <string_view>
#include <unordered_map>
#include <vector>
#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 <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 << "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 (argv[1] == "-h" || argc == 1) {
HelpCommand();
return EXIT_SUCCESS;
}
Commands commands;
std::string mode = argv[1];
std::string arg = argv[2];
if (commands.handlers.find(mode) != commands.handlers.end()) {
PRINT_IF_ERROR(commands.handlers[mode]->handle(arg))
} 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);
}