accidentally forgot to store the save type from the match into the rom struct
This commit is contained in:
@@ -32,13 +32,9 @@ void Core::LoadROM(const std::string &romFilename) {
|
|||||||
const bool isArchive = std::ranges::any_of(archive_types, [&extension](const auto &e) { return e == extension; });
|
const bool isArchive = std::ranges::any_of(archive_types, [&extension](const auto &e) { return e == extension; });
|
||||||
|
|
||||||
auto rom = Mem::LoadROM(isArchive, romPath);
|
auto rom = Mem::LoadROM(isArchive, romPath);
|
||||||
GameDB::match(rom.header);
|
|
||||||
mem->rom = rom;
|
mem->rom = rom;
|
||||||
if (rom.gameNameDB.empty()) {
|
mem->mmio.vi.isPal = Mem::IsROMPAL(rom.header);
|
||||||
rom.gameNameDB = fs::path(romPath).stem().string();
|
|
||||||
mem->rom.gameNameDB = rom.gameNameDB;
|
|
||||||
}
|
|
||||||
mem->mmio.vi.isPal = Mem::IsROMPAL(rom);
|
|
||||||
mem->mmio.si.pif.InitDevices(mem->rom.saveType);
|
mem->mmio.si.pif.InitDevices(mem->rom.saveType);
|
||||||
mem->mmio.si.pif.mempakPath = romPath;
|
mem->mmio.si.pif.mempakPath = romPath;
|
||||||
mem->mmio.si.pif.LoadEeprom(mem->rom.saveType, romPath);
|
mem->mmio.si.pif.LoadEeprom(mem->rom.saveType, romPath);
|
||||||
|
|||||||
@@ -109,8 +109,8 @@ ROMHeader Mem::ReadROMHeader(bool isArchive, const std::string &filename) {
|
|||||||
res.clockRate = std::byteswap(res.clockRate);
|
res.clockRate = std::byteswap(res.clockRate);
|
||||||
res.programCounter = std::byteswap(res.programCounter);
|
res.programCounter = std::byteswap(res.programCounter);
|
||||||
res.release = std::byteswap(res.release);
|
res.release = std::byteswap(res.release);
|
||||||
res.unknown = std::byteswap(res.unknown);
|
res.checkCode = std::byteswap(res.checkCode);
|
||||||
res.unknown2 = std::byteswap(res.unknown2);
|
res.reserved = std::byteswap(res.reserved);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -139,14 +139,21 @@ ROM Mem::LoadROM(const bool isArchive, const std::string &filename) {
|
|||||||
res.header.clockRate = std::byteswap(res.header.clockRate);
|
res.header.clockRate = std::byteswap(res.header.clockRate);
|
||||||
res.header.programCounter = std::byteswap(res.header.programCounter);
|
res.header.programCounter = std::byteswap(res.header.programCounter);
|
||||||
res.header.release = std::byteswap(res.header.release);
|
res.header.release = std::byteswap(res.header.release);
|
||||||
res.header.unknown = std::byteswap(res.header.unknown);
|
res.header.checkCode = std::byteswap(res.header.checkCode);
|
||||||
res.header.unknown2 = std::byteswap(res.header.unknown2);
|
res.header.reserved = std::byteswap(res.header.reserved);
|
||||||
|
|
||||||
|
auto [saveType, _, gameNameDB] = GameDB::match(res.header);
|
||||||
|
res.saveType = saveType;
|
||||||
|
if (gameNameDB.empty()) {
|
||||||
|
gameNameDB = fs::path(filename).stem().string();
|
||||||
|
}
|
||||||
|
res.gameNameDB = gameNameDB;
|
||||||
|
|
||||||
const u32 checksum = SDL_crc32(0, &res.cart[0x40], 0x9C0);
|
const u32 checksum = SDL_crc32(0, &res.cart[0x40], 0x9C0);
|
||||||
SetROMCIC(checksum, res);
|
SetROMCIC(checksum, res);
|
||||||
endianness = std::byteswap(ircolib::read_access<u32>(res.cart, 0));
|
endianness = std::byteswap(ircolib::read_access<u32>(res.cart, 0));
|
||||||
Util::SwapN64Rom(res.cart, endianness);
|
Util::SwapN64Rom(res.cart, endianness);
|
||||||
res.pal = IsROMPAL(res);
|
res.pal = IsROMPAL(res.header);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,14 +10,15 @@
|
|||||||
|
|
||||||
namespace n64 {
|
namespace n64 {
|
||||||
struct ROMHeader {
|
struct ROMHeader {
|
||||||
u8 initialValues[4];
|
u8 unused;
|
||||||
|
u8 initialValues[3];
|
||||||
u32 clockRate;
|
u32 clockRate;
|
||||||
u32 programCounter;
|
u32 programCounter;
|
||||||
u32 release;
|
u32 release;
|
||||||
u64 unknown;
|
u64 checkCode;
|
||||||
u64 unknown2;
|
u64 reserved;
|
||||||
char imageName[20];
|
char imageName[20];
|
||||||
char unknown3[7];
|
u8 reserved2[7];
|
||||||
u8 categoryCode;
|
u8 categoryCode;
|
||||||
char uniqueCode[2];
|
char uniqueCode[2];
|
||||||
u8 countryCode;
|
u8 countryCode;
|
||||||
@@ -133,9 +134,9 @@ struct Mem {
|
|||||||
std::string sramPath{};
|
std::string sramPath{};
|
||||||
mio::mmap_sink saveData{};
|
mio::mmap_sink saveData{};
|
||||||
|
|
||||||
[[nodiscard]] static FORCE_INLINE bool IsROMPAL(ROM &rom) {
|
[[nodiscard]] static FORCE_INLINE bool IsROMPAL(ROMHeader &header) {
|
||||||
return std::ranges::any_of(std::array{'D', 'F', 'I', 'P', 'S', 'U', 'X', 'Y', 'Z'},
|
return std::ranges::any_of(std::array{'D', 'F', 'I', 'P', 'S', 'U', 'X', 'Y', 'Z'},
|
||||||
[&rom](uint8_t a) { return rom.header.countryCode == a; });
|
[&header](uint8_t a) { return header.countryCode == a; });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace n64
|
} // namespace n64
|
||||||
|
|||||||
Reference in New Issue
Block a user