CPU: Display clean message when CPU crashes

This commit is contained in:
Souryo 2016-02-11 22:59:31 -05:00
parent c3694e16f5
commit 6f6a07b6c9
2 changed files with 8 additions and 2 deletions

View file

@ -247,7 +247,7 @@ private:
case AddrMode::AbsYW: return GetAbsYAddr(true);
default: break;
}
throw std::runtime_error("invalid addressing mode");
throw std::runtime_error("Invalid OP code - CPU crashed");
}
uint16_t GetOperand()

View file

@ -215,7 +215,13 @@ void Console::Run()
VideoDecoder::GetInstance()->StartThread();
while(true) {
_cpu->Exec();
try {
_cpu->Exec();
} catch(const std::runtime_error &ex) {
MessageManager::DisplayMessage("Error", string("Game has crashed. (") + ex.what() + ")");
break;
}
uint32_t currentFrameNumber = PPU::GetFrameCount();
if(currentFrameNumber != lastFrameNumber) {
lastFrameNumber = currentFrameNumber;