diff --git a/include/emulator.hpp b/include/emulator.hpp index 2477d7a4..56c29967 100644 --- a/include/emulator.hpp +++ b/include/emulator.hpp @@ -50,7 +50,8 @@ public: void run(); void runFrame(); - bool loadELF(std::filesystem::path& path); + bool loadROM(const std::filesystem::path& path); + bool loadELF(const std::filesystem::path& path); bool loadELF(std::ifstream& file); void initGraphicsContext() { gpu.initGraphicsContext(); } }; \ No newline at end of file diff --git a/src/emulator.cpp b/src/emulator.cpp index 499d6a8a..fe1b271b 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -48,7 +48,20 @@ void Emulator::runFrame() { cpu.runFrame(); } -bool Emulator::loadELF(std::filesystem::path& path) { +bool Emulator::loadROM(const std::filesystem::path& path) { + auto extension = path.extension(); + + if (extension == ".elf" || extension == ".axf") + return loadELF(path); + else if (extension == ".3ds") + Helpers::panic("3DS file"); + else { + printf("Unknown file type\n"); + return false; + } +} + +bool Emulator::loadELF(const std::filesystem::path& path) { loadedROM.open(path, std::ios_base::binary); // Open ROM in binary mode romType = ROMType::ELF; diff --git a/src/main.cpp b/src/main.cpp index 9325e905..9e8d6cd1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,10 +9,10 @@ int main (int argc, char *argv[]) { emu.initGraphicsContext(); - auto elfPath = std::filesystem::current_path() / (argc > 1 ? argv[1] : "sm64.elf"); - if (!emu.loadELF(elfPath)) { + auto elfPath = std::filesystem::current_path() / (argc > 1 ? argv[1] : "Metroid2.3ds"); + if (!emu.loadROM(elfPath)) { // For some reason just .c_str() doesn't show the proper path - Helpers::panic("Failed to load ELF file: %s", elfPath.string().c_str()); + Helpers::panic("Failed to load ROM file: %s", elfPath.string().c_str()); } emu.run();