From 8e4dacca8a4c064f5813135a84dd0fd96f907fd5 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Thu, 25 Aug 2022 00:16:32 +0200 Subject: [PATCH] Emulator: Add cli argument to specify bootrom path --- src/loader.cpp | 2 +- src/loader.h | 3 +++ src/main.cpp | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/loader.cpp b/src/loader.cpp index 7c8a823..6dfd322 100644 --- a/src/loader.cpp +++ b/src/loader.cpp @@ -53,7 +53,7 @@ void Loader::init() Emu::the().addMemorySpace("IE", 0xffff, 0xffff); // 1B, Interrupt Enable register // Load bootrom - auto bootrom = ruc::File("gbc_bios.bin").data(); + auto bootrom = ruc::File(m_bootrom_path).data(); for (size_t i = 0; i < bootrom.length(); ++i) { // Skip cartridge header memory range if (i >= 0x0100 && i <= 0x01ff) { diff --git a/src/loader.h b/src/loader.h index 45213d0..842337b 100644 --- a/src/loader.h +++ b/src/loader.h @@ -17,6 +17,8 @@ public: void loadRom(std::string_view rom_path); + void setBootromPath(std::string_view bootrom_path) { m_bootrom_path = bootrom_path; } + private: void init(); void update(); @@ -24,5 +26,6 @@ private: void loadCartridgeHeader(); + std::string_view m_bootrom_path; std::string m_rom_data; }; diff --git a/src/main.cpp b/src/main.cpp index 3b5939f..6d26077 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,12 +13,15 @@ int main(int argc, const char* argv[]) { + std::string_view bootrom_path = "gbc_bios.bin"; std::string_view rom_path; ruc::ArgParser argParser; + argParser.addOption(bootrom_path, 'b', "bootrom", nullptr, nullptr, "", ruc::ArgParser::Required::Yes); argParser.addOption(rom_path, 'r', "rom", nullptr, nullptr, "", ruc::ArgParser::Required::Yes); argParser.parse(argc, argv); + Loader::the().setBootromPath(bootrom_path); Loader::the().loadRom(rom_path); return 0;