CPU: Improve timings for WAI instruction (?)

This commit is contained in:
Sour 2019-03-22 21:12:58 -04:00
parent 5279b3d47d
commit ebfd42f5b6
3 changed files with 24 additions and 15 deletions

View file

@ -224,11 +224,13 @@ bool Console::LoadRom(VirtualFile romFile, VirtualFile patchFile, bool stopRom)
MessageManager::DisplayMessage("SPC", "spc700.rom not found, cannot launch game.");
return false;
}
_cart = cart;
UpdateRegion();
_internalRegisters.reset(new InternalRegisters(shared_from_this()));
_ppu.reset(new Ppu(shared_from_this()));
_spc.reset(new Spc(shared_from_this(), spcRomData));
_cart = cart;
_controlManager.reset(new ControlManager(shared_from_this()));
_memoryManager.reset(new MemoryManager());
_dmaController.reset(new DmaController(_memoryManager.get()));
@ -236,12 +238,7 @@ bool Console::LoadRom(VirtualFile romFile, VirtualFile patchFile, bool stopRom)
_memoryManager->Initialize(shared_from_this());
_cpu.reset(new Cpu(this));
_rewindManager.reset(new RewindManager(shared_from_this()));
_notificationManager->RegisterNotificationListener(_rewindManager);
_controlManager->UpdateControlDevices();
if(_debugger) {
//Reset debugger if it was running before
auto lock = _debuggerLock.AcquireSafe();
@ -249,10 +246,17 @@ bool Console::LoadRom(VirtualFile romFile, VirtualFile patchFile, bool stopRom)
GetDebugger();
_debugger->Step(1);
}
UpdateRegion();
_cpu->PowerOn();
_memoryManager->IncrementMasterClockValue<170>();
_rewindManager.reset(new RewindManager(shared_from_this()));
_notificationManager->RegisterNotificationListener(_rewindManager);
_controlManager->UpdateControlDevices();
UpdateRegion();
_paused = false;
_notificationManager->SendNotification(ConsoleNotificationType::GameLoaded);

View file

@ -10,6 +10,14 @@ Cpu::Cpu(Console *console)
{
_console = console;
_memoryManager = console->GetMemoryManager().get();
}
Cpu::~Cpu()
{
}
void Cpu::PowerOn()
{
_state = {};
_state.PC = ReadDataWord(Cpu::ResetVector);
_state.SP = 0x1FF;
@ -24,10 +32,6 @@ Cpu::Cpu(Console *console)
SetFlags(ProcFlags::IndexMode8);
}
Cpu::~Cpu()
{
}
void Cpu::Reset()
{
_state.EmulationMode = true;
@ -57,9 +61,8 @@ void Cpu::Exec()
//WAI
if(!_state.IrqSource && !_state.NmiFlag) {
#ifndef DUMMYCPU
_memoryManager->IncrementMasterClockValue<4>();
Idle();
#endif
return;
} else {
Idle();
Idle();

View file

@ -291,6 +291,8 @@ public:
Cpu(Console *console);
~Cpu();
void PowerOn();
void Reset();
void Exec();