Debugger: Scroll overlay position is now based on the selected cycle/scanline

This commit is contained in:
Souryo 2017-09-28 20:05:00 -04:00
parent c7a001e691
commit 1f974dcedd
5 changed files with 17 additions and 13 deletions

View file

@ -926,11 +926,13 @@ void Debugger::SetPpuViewerScanlineCycle(int32_t scanline, int32_t cycle)
_ppuViewerCycle = cycle; _ppuViewerCycle = cycle;
} }
void Debugger::SetLastFramePpuScroll(uint16_t x, uint16_t y) void Debugger::SetLastFramePpuScroll(uint16_t addr, uint8_t xScroll, bool updateHorizontalScrollOnly)
{ {
if(Debugger::Instance) { if(Debugger::Instance) {
Debugger::Instance->_ppuScrollX = x; Debugger::Instance->_ppuScrollX = ((addr & 0x1F) << 3) | xScroll | ((addr & 0x400) ? 0x100 : 0);
Debugger::Instance->_ppuScrollY = y; if(!updateHorizontalScrollOnly) {
Debugger::Instance->_ppuScrollY = (((addr & 0x3E0) >> 2) | ((addr & 0x7000) >> 12)) + ((addr & 0x800) ? 240 : 0);
}
} }
} }

View file

@ -196,7 +196,7 @@ public:
static void ProcessVramWriteOperation(uint16_t addr, uint8_t &value); static void ProcessVramWriteOperation(uint16_t addr, uint8_t &value);
static void ProcessPpuCycle(); static void ProcessPpuCycle();
static void SetLastFramePpuScroll(uint16_t x, uint16_t y); static void SetLastFramePpuScroll(uint16_t addr, uint8_t xScroll, bool updateHorizontalScrollOnly);
uint32_t GetPpuScroll(); uint32_t GetPpuScroll();
static void ProcessInterrupt(uint16_t cpuAddr, uint16_t destCpuAddr, bool forNmi); static void ProcessInterrupt(uint16_t cpuAddr, uint16_t destCpuAddr, bool forNmi);

View file

@ -330,6 +330,9 @@ void PPU::WriteRAM(uint16_t addr, uint8_t value)
} else { } else {
_state.XScroll = value & 0x07; _state.XScroll = value & 0x07;
_state.TmpVideoRamAddr = (_state.TmpVideoRamAddr & ~0x001F) | (value >> 3); _state.TmpVideoRamAddr = (_state.TmpVideoRamAddr & ~0x001F) | (value >> 3);
//Update debugger overlay X scroll only
Debugger::SetLastFramePpuScroll(_state.TmpVideoRamAddr, _state.XScroll, false);
} }
_state.WriteToggle = !_state.WriteToggle; _state.WriteToggle = !_state.WriteToggle;
break; break;
@ -341,6 +344,7 @@ void PPU::WriteRAM(uint16_t addr, uint8_t value)
//A 3-cycle delay causes issues with the scanline test. //A 3-cycle delay causes issues with the scanline test.
_updateVramAddrDelay = 2; _updateVramAddrDelay = 2;
_updateVramAddr = _state.TmpVideoRamAddr; _updateVramAddr = _state.TmpVideoRamAddr;
Debugger::SetLastFramePpuScroll(_updateVramAddr, _state.XScroll, false);
} else { } else {
_state.TmpVideoRamAddr = (_state.TmpVideoRamAddr & ~0xFF00) | ((value & 0x3F) << 8); _state.TmpVideoRamAddr = (_state.TmpVideoRamAddr & ~0xFF00) | ((value & 0x3F) << 8);
} }
@ -843,10 +847,7 @@ void PPU::ProcessScanline()
_oamCopybuffer = _secondarySpriteRAM[0]; _oamCopybuffer = _secondarySpriteRAM[0];
} }
if(_scanline == -1) { if(_scanline == -1) {
Debugger::SetLastFramePpuScroll( Debugger::SetLastFramePpuScroll(_state.VideoRamAddr, _state.XScroll, false);
((_state.VideoRamAddr & 0x1F) << 3) | _state.XScroll | ((_state.VideoRamAddr & 0x400) ? 0x100 : 0),
(((_state.VideoRamAddr & 0x3E0) >> 2) | ((_state.VideoRamAddr & 0x7000) >> 12)) + ((_state.VideoRamAddr & 0x800) ? 240 : 0)
);
} }
} else if(_prevRenderingEnabled && (_cycle == 328 || _cycle == 336)) { } else if(_prevRenderingEnabled && (_cycle == 328 || _cycle == 336)) {
_state.LowBitShift <<= 8; _state.LowBitShift <<= 8;

View file

@ -25,6 +25,8 @@ namespace Mesen.GUI.Debugger.Controls
private int _currentPpuAddress = -1; private int _currentPpuAddress = -1;
private int _tileX = 0; private int _tileX = 0;
private int _tileY = 0; private int _tileY = 0;
private int _xScroll = 0;
private int _yScroll = 0;
private int _nametableIndex = 0; private int _nametableIndex = 0;
private ctrlChrViewer _chrViewer; private ctrlChrViewer _chrViewer;
@ -48,6 +50,8 @@ namespace Mesen.GUI.Debugger.Controls
public void GetData() public void GetData()
{ {
InteropEmu.DebugGetPpuScroll(out _xScroll, out _yScroll);
for(int i = 0; i < 4; i++) { for(int i = 0; i < 4; i++) {
InteropEmu.DebugGetNametable(i, out _nametablePixelData[i], out _tileData[i], out _attributeData[i]); InteropEmu.DebugGetNametable(i, out _nametablePixelData[i], out _tileData[i], out _attributeData[i]);
} }
@ -57,9 +61,6 @@ namespace Mesen.GUI.Debugger.Controls
{ {
_currentPpuAddress = -1; _currentPpuAddress = -1;
int xScroll, yScroll;
InteropEmu.DebugGetPpuScroll(out xScroll, out yScroll);
DebugState state = new DebugState(); DebugState state = new DebugState();
InteropEmu.DebugGetState(ref state); InteropEmu.DebugGetState(ref state);
int tileIndexOffset = state.PPU.ControlFlags.BackgroundPatternAddr == 0x1000 ? 256 : 0; int tileIndexOffset = state.PPU.ControlFlags.BackgroundPatternAddr == 0x1000 ? 256 : 0;
@ -114,7 +115,7 @@ namespace Mesen.GUI.Debugger.Controls
} }
if(chkShowPpuScrollOverlay.Checked) { if(chkShowPpuScrollOverlay.Checked) {
DrawScrollOverlay(xScroll, yScroll, g); DrawScrollOverlay(_xScroll, _yScroll, g);
} }
} }