feat: 3dsx loading

romFS works too, pretty neat
This commit is contained in:
Théo B 2023-09-02 23:49:11 +02:00
parent a18ed8778f
commit 29352d223b
8 changed files with 469 additions and 39 deletions

View file

@ -453,6 +453,8 @@ bool Emulator::loadROM(const std::filesystem::path& path) {
success = loadNCSD(path, ROMType::NCSD);
else if (extension == ".cxi" || extension == ".app")
success = loadNCSD(path, ROMType::CXI);
else if (extension == ".3dsx")
success = load3DSX(path);
else {
printf("Unknown file type\n");
success = false;
@ -492,6 +494,19 @@ bool Emulator::loadNCSD(const std::filesystem::path& path, ROMType type) {
return true;
}
bool Emulator::load3DSX(const std::filesystem::path& path) {
std::optional<u32> entrypoint = memory.load3DSX(path);
romType = ROMType::HB_3DSX;
if (!entrypoint.has_value()) {
return false;
}
cpu.setReg(15, entrypoint.value()); // Set initial PC
return true;
}
bool Emulator::loadELF(const std::filesystem::path& path) {
loadedELF.open(path, std::ios_base::binary); // Open ROM in binary mode
romType = ROMType::ELF;