Fix for issue #59
This commit is contained in:
@@ -34,7 +34,7 @@ void Core::LoadROM(const std::string& rom_) {
|
|||||||
GameDB::match(cpu->mem);
|
GameDB::match(cpu->mem);
|
||||||
cpu->mem.mmio.vi.isPal = cpu->mem.IsROMPAL();
|
cpu->mem.mmio.vi.isPal = cpu->mem.IsROMPAL();
|
||||||
cpu->mem.mmio.si.pif.InitDevices(cpu->mem.saveType);
|
cpu->mem.mmio.si.pif.InitDevices(cpu->mem.saveType);
|
||||||
cpu->mem.mmio.si.pif.LoadMempak(rom);
|
cpu->mem.mmio.si.pif.mempakPath = rom;
|
||||||
cpu->mem.mmio.si.pif.LoadEeprom(cpu->mem.saveType, rom);
|
cpu->mem.mmio.si.pif.LoadEeprom(cpu->mem.saveType, rom);
|
||||||
cpu->mem.flash.Load(cpu->mem.saveType, rom);
|
cpu->mem.flash.Load(cpu->mem.saveType, rom);
|
||||||
cpu->mem.LoadSRAM(cpu->mem.saveType, rom);
|
cpu->mem.LoadSRAM(cpu->mem.saveType, rom);
|
||||||
|
|||||||
@@ -27,8 +27,9 @@ void PIF::Reset() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PIF::LoadMempak(const std::string& path) {
|
void PIF::MaybeLoadMempak() {
|
||||||
mempakPath = fs::path(path).replace_extension(".mempak").string();
|
if(!mempakOpen) {
|
||||||
|
mempakPath = fs::path(mempakPath).replace_extension(".mempak").string();
|
||||||
std::error_code error;
|
std::error_code error;
|
||||||
if (mempak.is_mapped()) {
|
if (mempak.is_mapped()) {
|
||||||
mempak.sync(error);
|
mempak.sync(error);
|
||||||
@@ -54,6 +55,8 @@ void PIF::LoadMempak(const std::string& path) {
|
|||||||
mempak = mio::make_mmap_sink(
|
mempak = mio::make_mmap_sink(
|
||||||
mempakPath, 0, mio::map_entire_file, error);
|
mempakPath, 0, mio::map_entire_file, error);
|
||||||
if (error) { Util::panic("Could not open {}", mempakPath); }
|
if (error) { Util::panic("Could not open {}", mempakPath); }
|
||||||
|
mempakOpen = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCE_INLINE size_t getSaveSize(SaveType saveType) {
|
FORCE_INLINE size_t getSaveSize(SaveType saveType) {
|
||||||
@@ -247,7 +250,8 @@ void PIF::ProcessCommands(Mem &mem) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PIF::MempakRead(const u8* cmd, u8* res) const {
|
void PIF::MempakRead(const u8* cmd, u8* res) {
|
||||||
|
MaybeLoadMempak();
|
||||||
u16 offset = cmd[3] << 8;
|
u16 offset = cmd[3] << 8;
|
||||||
offset |= cmd[4];
|
offset |= cmd[4];
|
||||||
|
|
||||||
@@ -274,6 +278,7 @@ void PIF::MempakRead(const u8* cmd, u8* res) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PIF::MempakWrite(u8* cmd, u8* res) {
|
void PIF::MempakWrite(u8* cmd, u8* res) {
|
||||||
|
MaybeLoadMempak();
|
||||||
// First two bytes in the command are the offset
|
// First two bytes in the command are the offset
|
||||||
u16 offset = cmd[3] << 8;
|
u16 offset = cmd[3] << 8;
|
||||||
offset |= cmd[4];
|
offset |= cmd[4];
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ struct PIF {
|
|||||||
PIF() = default;
|
PIF() = default;
|
||||||
~PIF() = default;
|
~PIF() = default;
|
||||||
void Reset();
|
void Reset();
|
||||||
void LoadMempak(const std::string&);
|
void MaybeLoadMempak();
|
||||||
void LoadEeprom(SaveType, const std::string&);
|
void LoadEeprom(SaveType, const std::string&);
|
||||||
void ProcessCommands(Mem&);
|
void ProcessCommands(Mem&);
|
||||||
void InitDevices(SaveType);
|
void InitDevices(SaveType);
|
||||||
@@ -118,12 +118,12 @@ struct PIF {
|
|||||||
void UpdateController();
|
void UpdateController();
|
||||||
bool ReadButtons(u8*) const;
|
bool ReadButtons(u8*) const;
|
||||||
void ControllerID(u8*) const;
|
void ControllerID(u8*) const;
|
||||||
void MempakRead(const u8*, u8*) const;
|
void MempakRead(const u8*, u8*);
|
||||||
void MempakWrite(u8*, u8*);
|
void MempakWrite(u8*, u8*);
|
||||||
void EepromRead(const u8*, u8*, const Mem&) const;
|
void EepromRead(const u8*, u8*, const Mem&) const;
|
||||||
void EepromWrite(const u8*, u8*, const Mem&);
|
void EepromWrite(const u8*, u8*, const Mem&);
|
||||||
|
|
||||||
bool gamepadConnected = false;
|
bool gamepadConnected = false, mempakOpen = false;
|
||||||
SDL_GameController* gamepad{};
|
SDL_GameController* gamepad{};
|
||||||
JoybusDevice joybusDevices[6]{};
|
JoybusDevice joybusDevices[6]{};
|
||||||
u8 bootrom[PIF_BOOTROM_SIZE]{}, ram[PIF_RAM_SIZE]{};
|
u8 bootrom[PIF_BOOTROM_SIZE]{}, ram[PIF_RAM_SIZE]{};
|
||||||
|
|||||||
Reference in New Issue
Block a user