Debugger: Fixed deadlock when loading another game with the debugger opened

This commit is contained in:
Sour 2019-05-04 09:25:10 -04:00
parent 702b609381
commit e0e39957a5
5 changed files with 21 additions and 8 deletions

View file

@ -87,6 +87,8 @@ void Console::Run()
_videoDecoder->StartThread();
_emulationThreadId = std::this_thread::get_id();
_memoryManager->IncrementMasterClockValue<182>();
auto lock = _runLock.AcquireSafe();
while(!_stopFlag) {
_cpu->Exec();
@ -192,8 +194,9 @@ void Console::Reset()
//_controlManager->Reset();
_notificationManager->SendNotification(ConsoleNotificationType::GameReset);
ProcessEvent(EventType::Reset);
_memoryManager->IncrementMasterClockValue<166>();
_memoryManager->IncrementMasterClockValue<182>();
Unlock();
}
@ -263,8 +266,6 @@ bool Console::LoadRom(VirtualFile romFile, VirtualFile patchFile, bool stopRom)
_notificationManager->SendNotification(ConsoleNotificationType::GameLoaded);
_memoryManager->IncrementMasterClockValue<166>();
_rewindManager.reset(new RewindManager(shared_from_this()));
_notificationManager->RegisterNotificationListener(_rewindManager);

View file

@ -21,7 +21,7 @@ Cpu::~Cpu()
void Cpu::PowerOn()
{
_state = {};
_state.PC = ReadDataWord(Cpu::ResetVector);
_state.PC = _memoryManager->PeekWord(Cpu::ResetVector);
_state.SP = 0x1FF;
_state.PS = ProcFlags::IrqDisable;
_state.EmulationMode = true;
@ -44,7 +44,7 @@ void Cpu::Reset()
_state.StopState = CpuStopState::Running;
SetSP(_state.SP);
_state.K = 0;
_state.PC = ReadDataWord(Cpu::ResetVector);
_state.PC = _memoryManager->PeekWord(Cpu::ResetVector);
}
void Cpu::Exec()

View file

@ -84,6 +84,12 @@ void Debugger::Release()
}
}
void Debugger::Reset()
{
_prevOpCode = 0xFF;
_spcPrevOpCode = 0xFF;
}
void Debugger::ProcessCpuRead(uint32_t addr, uint8_t value, MemoryOperationType type)
{
AddressInfo addressInfo = _memoryManager->GetAbsoluteAddress(addr);
@ -353,6 +359,10 @@ void Debugger::ProcessEvent(EventType type)
_console->GetNotificationManager()->SendNotification(ConsoleNotificationType::EventViewerRefresh);
_eventManager->ClearFrameEvents();
break;
case EventType::Reset:
Reset();
break;
}
}

View file

@ -64,12 +64,13 @@ private:
atomic<int32_t> _spcBreakAddress;
atomic<int32_t> _breakScanline;
uint8_t _prevOpCode = 0;
uint8_t _prevOpCode = 0xFF;
uint32_t _prevProgramCounter = 0;
uint8_t _spcPrevOpCode = 0;
uint8_t _spcPrevOpCode = 0xFF;
uint32_t _spcPrevProgramCounter = 0;
void Reset();
void SleepUntilResume();
void ProcessStepConditions(uint8_t opCode, uint32_t currentPc);
void ProcessBreakConditions(MemoryOperationInfo &operation, AddressInfo &addressInfo);

View file

@ -5,5 +5,6 @@ enum class EventType
Nmi = 0,
Irq = 1,
StartFrame = 2,
EndFrame = 3
EndFrame = 3,
Reset = 4
};