Browse Source

Emulator: Add cli argument to specify bootrom path

master
Riyyi 2 years ago
parent
commit
8e4dacca8a
  1. 2
      src/loader.cpp
  2. 3
      src/loader.h
  3. 3
      src/main.cpp

2
src/loader.cpp

@ -53,7 +53,7 @@ void Loader::init()
Emu::the().addMemorySpace("IE", 0xffff, 0xffff); // 1B, Interrupt Enable register Emu::the().addMemorySpace("IE", 0xffff, 0xffff); // 1B, Interrupt Enable register
// Load bootrom // 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) { for (size_t i = 0; i < bootrom.length(); ++i) {
// Skip cartridge header memory range // Skip cartridge header memory range
if (i >= 0x0100 && i <= 0x01ff) { if (i >= 0x0100 && i <= 0x01ff) {

3
src/loader.h

@ -17,6 +17,8 @@ public:
void loadRom(std::string_view rom_path); void loadRom(std::string_view rom_path);
void setBootromPath(std::string_view bootrom_path) { m_bootrom_path = bootrom_path; }
private: private:
void init(); void init();
void update(); void update();
@ -24,5 +26,6 @@ private:
void loadCartridgeHeader(); void loadCartridgeHeader();
std::string_view m_bootrom_path;
std::string m_rom_data; std::string m_rom_data;
}; };

3
src/main.cpp

@ -13,12 +13,15 @@
int main(int argc, const char* argv[]) int main(int argc, const char* argv[])
{ {
std::string_view bootrom_path = "gbc_bios.bin";
std::string_view rom_path; std::string_view rom_path;
ruc::ArgParser argParser; 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.addOption(rom_path, 'r', "rom", nullptr, nullptr, "", ruc::ArgParser::Required::Yes);
argParser.parse(argc, argv); argParser.parse(argc, argv);
Loader::the().setBootromPath(bootrom_path);
Loader::the().loadRom(rom_path); Loader::the().loadRom(rom_path);
return 0; return 0;

Loading…
Cancel
Save