We can almost load commercial carts now

This commit is contained in:
wheremyfoodat 2022-10-03 19:10:09 +03:00
parent 36b0117ebc
commit 87bf469447
5 changed files with 50 additions and 8 deletions

View file

@ -67,11 +67,20 @@ std::optional<NCSD> Memory::loadNCSD(const std::filesystem::path& path) {
}
}
}
if (!ncsd.partitions[0].ncch.hasExtendedHeader()) {
printf("NCSD's CXI doesn't have exheader?\n");
auto& cxi = ncsd.partitions[0].ncch;
if (!cxi.hasExtendedHeader() || !cxi.hasCode()) {
printf("NCSD with an invalid CXI in partition 0?\n");
return std::nullopt;
}
// Map code file to memory
const auto& code = cxi.codeFile;
printf("Text address = %08X page count = %08X\n", cxi.text.address, cxi.text.size);
printf("Rodata address = %08X page count = %08X\n", cxi.rodata.address, cxi.rodata.size);
printf("Data address = %08X page count = %08X\n", cxi.data.address, cxi.data.size);
ncsd.entrypoint = cxi.text.address;
return ncsd;
}