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

View file

@ -224,7 +224,7 @@ class PPU : public IMemoryHandler, public Snapshotable
{
return _secondarySpriteRAM;
}
static uint32_t GetPixelBrightness(uint8_t x, uint8_t y)
{
//Used by Zapper, gives a rough approximation of the brightness level of the specific pixel

View file

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