Refactor PIF
This commit is contained in:
@@ -50,7 +50,7 @@ void Core::LoadROM(const std::string& 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);
|
||||||
PIF::ExecutePIF(cpu->mem, cpu->regs);
|
cpu->mem.mmio.si.pif.Execute();
|
||||||
pause = false;
|
pause = false;
|
||||||
render = true;
|
render = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ struct Mem;
|
|||||||
struct Registers;
|
struct Registers;
|
||||||
|
|
||||||
struct MMIO {
|
struct MMIO {
|
||||||
MMIO(Registers& regs) : mi(regs) {}
|
MMIO(Mem& mem, Registers& regs) : mi(regs), si(mem, regs) {}
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
VI vi;
|
VI vi;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
namespace n64 {
|
namespace n64 {
|
||||||
Mem::Mem(Registers& regs) : flash(saveData), mmio(regs) {
|
Mem::Mem(Registers& regs) : flash(saveData), mmio(*this, regs) {
|
||||||
memset(readPages, 0, PAGE_COUNT);
|
memset(readPages, 0, PAGE_COUNT);
|
||||||
memset(writePages, 0, PAGE_COUNT);
|
memset(writePages, 0, PAGE_COUNT);
|
||||||
|
|
||||||
|
|||||||
@@ -332,7 +332,7 @@ void PIF::EepromWrite(const u8* cmd, u8* res, const Mem& mem) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PIF::DoPIFHLE(Mem& mem, Registers& regs, bool pal, CICType cicType) {
|
void PIF::HLE(bool pal, CICType cicType) {
|
||||||
mem.Write<u32>(regs, PIF_RAM_REGION_START + 0x24, cicSeeds[cicType]);
|
mem.Write<u32>(regs, PIF_RAM_REGION_START + 0x24, cicSeeds[cicType]);
|
||||||
|
|
||||||
switch(cicType) {
|
switch(cicType) {
|
||||||
@@ -597,7 +597,7 @@ void PIF::DoPIFHLE(Mem& mem, Registers& regs, bool pal, CICType cicType) {
|
|||||||
regs.SetPC32(s32(0xA4000040));
|
regs.SetPC32(s32(0xA4000040));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PIF::ExecutePIF(Mem& mem, Registers& regs) {
|
void PIF::Execute() {
|
||||||
CICType cicType = mem.rom.cicType;
|
CICType cicType = mem.rom.cicType;
|
||||||
bool pal = mem.rom.pal;
|
bool pal = mem.rom.pal;
|
||||||
mem.Write<u32>(regs, PIF_RAM_REGION_START + 0x24, cicSeeds[cicType]);
|
mem.Write<u32>(regs, PIF_RAM_REGION_START + 0x24, cicSeeds[cicType]);
|
||||||
@@ -615,7 +615,7 @@ void PIF::ExecutePIF(Mem& mem, Registers& regs) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DoPIFHLE(mem, regs, pal, cicType);
|
HLE(pal, cicType);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<u8> PIF::Serialize() {
|
std::vector<u8> PIF::Serialize() {
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ enum CICType {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct PIF {
|
struct PIF {
|
||||||
PIF() = default;
|
PIF(Mem& mem, Registers& regs) : mem(mem), regs(regs) {}
|
||||||
~PIF() = default;
|
~PIF() = default;
|
||||||
void Reset();
|
void Reset();
|
||||||
void MaybeLoadMempak();
|
void MaybeLoadMempak();
|
||||||
@@ -160,8 +160,8 @@ struct PIF {
|
|||||||
void ProcessCommands(Mem&);
|
void ProcessCommands(Mem&);
|
||||||
void InitDevices(SaveType);
|
void InitDevices(SaveType);
|
||||||
void CICChallenge();
|
void CICChallenge();
|
||||||
static void ExecutePIF(Mem& mem, Registers& regs);
|
void Execute();
|
||||||
static void DoPIFHLE(Mem& mem, Registers& regs, bool pal, CICType cicType);
|
void HLE(bool pal, CICType cicType);
|
||||||
bool ReadButtons(u8*);
|
bool ReadButtons(u8*);
|
||||||
void ControllerID(u8*) const;
|
void ControllerID(u8*) const;
|
||||||
void MempakRead(const u8*, u8*);
|
void MempakRead(const u8*, u8*);
|
||||||
@@ -178,6 +178,8 @@ struct PIF {
|
|||||||
std::string mempakPath{}, eepromPath{};
|
std::string mempakPath{}, eepromPath{};
|
||||||
size_t eepromSize{};
|
size_t eepromSize{};
|
||||||
MupenMovie movie;
|
MupenMovie movie;
|
||||||
|
Mem& mem;
|
||||||
|
Registers& regs;
|
||||||
|
|
||||||
FORCE_INLINE u8 Read(u32 addr) {
|
FORCE_INLINE u8 Read(u32 addr) {
|
||||||
addr &= 0x7FF;
|
addr &= 0x7FF;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <Scheduler.hpp>
|
#include <Scheduler.hpp>
|
||||||
|
|
||||||
namespace n64 {
|
namespace n64 {
|
||||||
SI::SI() {
|
SI::SI(Mem& mem, Registers& regs) : pif(mem, regs) {
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ union SIStatus {
|
|||||||
struct Mem;
|
struct Mem;
|
||||||
|
|
||||||
struct SI {
|
struct SI {
|
||||||
SI();
|
SI(Mem&, Registers&);
|
||||||
void Reset();
|
void Reset();
|
||||||
SIStatus status{};
|
SIStatus status{};
|
||||||
u32 dramAddr{};
|
u32 dramAddr{};
|
||||||
|
|||||||
Reference in New Issue
Block a user