Debugger: Fixed issues with CPU/PPU state edition
This commit is contained in:
parent
62a10de12a
commit
ce3e4d7c80
6 changed files with 31 additions and 10 deletions
|
@ -92,7 +92,9 @@ private:
|
|||
|
||||
uint8_t ReadByte()
|
||||
{
|
||||
return MemoryRead(_state.PC++, MemoryOperationType::ExecOperand);
|
||||
uint8_t value = MemoryRead(_state.PC, MemoryOperationType::ExecOperand);
|
||||
_state.PC++;
|
||||
return value;
|
||||
}
|
||||
|
||||
uint16_t ReadWord()
|
||||
|
@ -813,7 +815,11 @@ public:
|
|||
|
||||
void SetState(State state)
|
||||
{
|
||||
uint16_t originalPc = state.PC;
|
||||
uint16_t originalDebugPc = state.DebugPC;
|
||||
_state = state;
|
||||
_cycleCount = state.CycleCount;
|
||||
state.PC = originalPc;
|
||||
state.DebugPC = originalDebugPc;
|
||||
}
|
||||
};
|
|
@ -412,10 +412,10 @@ bool Debugger::PrivateProcessRamOperation(MemoryOperationType type, uint16_t &ad
|
|||
_cpu->SetDebugPC(addr);
|
||||
_needRewind = false;
|
||||
}
|
||||
}
|
||||
|
||||
_currentReadAddr = &addr;
|
||||
_currentReadValue = &value;
|
||||
_currentReadAddr = &addr;
|
||||
_currentReadValue = &value;
|
||||
}
|
||||
|
||||
//Check if a breakpoint has been hit and freeze execution if one has
|
||||
bool breakDone = false;
|
||||
|
@ -589,26 +589,28 @@ void Debugger::SetState(DebugState state)
|
|||
{
|
||||
_cpu->SetState(state.CPU);
|
||||
_ppu->SetState(state.PPU);
|
||||
SetNextStatement(state.CPU.PC);
|
||||
if(state.CPU.PC != _cpu->GetState().PC) {
|
||||
SetNextStatement(state.CPU.PC);
|
||||
}
|
||||
}
|
||||
|
||||
void Debugger::PpuStep(uint32_t count)
|
||||
{
|
||||
_stepCount = -1;
|
||||
_ppuStepCount = count;
|
||||
_stepOverAddr = -1;
|
||||
_stepCycleCount = -1;
|
||||
_stepCount = -1;
|
||||
}
|
||||
|
||||
void Debugger::Step(uint32_t count, bool sendNotification)
|
||||
{
|
||||
//Run CPU for [count] INSTRUCTIONS before breaking again
|
||||
_stepOut = false;
|
||||
_stepCount = count;
|
||||
_stepOverAddr = -1;
|
||||
_stepCycleCount = -1;
|
||||
_ppuStepCount = -1;
|
||||
_sendNotification = sendNotification;
|
||||
_stepCount = count;
|
||||
}
|
||||
|
||||
void Debugger::StepCycles(uint32_t count)
|
||||
|
@ -621,9 +623,9 @@ void Debugger::StepCycles(uint32_t count)
|
|||
void Debugger::StepOut()
|
||||
{
|
||||
_stepOut = true;
|
||||
_stepCount = -1;
|
||||
_stepOverAddr = -1;
|
||||
_stepCycleCount = -1;
|
||||
_stepCount = -1;
|
||||
}
|
||||
|
||||
void Debugger::StepOver()
|
||||
|
@ -650,8 +652,8 @@ void Debugger::StepBack()
|
|||
void Debugger::Run()
|
||||
{
|
||||
//Resume execution after a breakpoint has been hit
|
||||
_stepCount = -1;
|
||||
_ppuStepCount = -1;
|
||||
_stepCount = -1;
|
||||
}
|
||||
|
||||
void Debugger::GenerateCodeOutput()
|
||||
|
|
10
Core/PPU.cpp
10
Core/PPU.cpp
|
@ -153,6 +153,16 @@ void PPU::SetState(PPUDebugState state)
|
|||
_cycle = state.Cycle;
|
||||
_scanline = state.Scanline;
|
||||
_frameCount = state.FrameCount;
|
||||
|
||||
UpdateMinimumDrawCycles();
|
||||
|
||||
_paletteRamMask = _flags.Grayscale ? 0x30 : 0x3F;
|
||||
if(_nesModel == NesModel::NTSC) {
|
||||
_intensifyColorBits = (_flags.IntensifyGreen ? 0x40 : 0x00) | (_flags.IntensifyRed ? 0x80 : 0x00) | (_flags.IntensifyBlue ? 0x100 : 0x00);
|
||||
} else if(_nesModel == NesModel::PAL || _nesModel == NesModel::Dendy) {
|
||||
//"Note that on the Dendy and PAL NES, the green and red bits swap meaning."
|
||||
_intensifyColorBits = (_flags.IntensifyRed ? 0x40 : 0x00) | (_flags.IntensifyGreen ? 0x80 : 0x00) | (_flags.IntensifyBlue ? 0x100 : 0x00);
|
||||
}
|
||||
}
|
||||
|
||||
void PPU::UpdateVideoRamAddr()
|
||||
|
|
|
@ -44,6 +44,7 @@ namespace Mesen.GUI
|
|||
{
|
||||
if(InteropEmu.IsRunning() && !InteropEmu.IsPaused()) {
|
||||
HideMouse();
|
||||
_tmrHideMouse.Stop();
|
||||
} else {
|
||||
ShowMouse();
|
||||
_tmrHideMouse.Stop();
|
||||
|
|
|
@ -154,6 +154,8 @@ namespace Mesen.GUI.Debugger
|
|||
state.PPU.State.VideoRamAddr = vramAddr;
|
||||
|
||||
InteropEmu.DebugSetState(state);
|
||||
_lastState = state;
|
||||
_dirty = false;
|
||||
btnUndo.Enabled = false;
|
||||
OnStateChanged?.Invoke(null, null);
|
||||
}
|
||||
|
|
|
@ -371,6 +371,7 @@ namespace Mesen.GUI.Debugger
|
|||
|
||||
private void ResumeExecution()
|
||||
{
|
||||
ctrlConsoleStatus.ApplyChanges();
|
||||
ClearActiveStatement();
|
||||
UpdateDebuggerFlags();
|
||||
InteropEmu.DebugRun();
|
||||
|
@ -381,7 +382,6 @@ namespace Mesen.GUI.Debugger
|
|||
ResumeExecution();
|
||||
}
|
||||
|
||||
|
||||
private void mnuToggleBreakpoint_Click(object sender, EventArgs e)
|
||||
{
|
||||
ToggleBreakpoint(false);
|
||||
|
|
Loading…
Add table
Reference in a new issue