Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit 86e951d

Browse files
committed
Debugger: Added DMC sample tracking to CDL files + a highlight option for it in the memory viewer
1 parent 898824c commit 86e951d

File tree

9 files changed

+166
-103
lines changed

9 files changed

+166
-103
lines changed

Core/Debugger.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,13 @@ bool Debugger::PrivateProcessRamOperation(MemoryOperationType type, uint16_t &ad
417417
{
418418
OperationInfo operationInfo { addr, (int16_t)value, type };
419419

420+
bool isDmcRead = false;
421+
if(type == MemoryOperationType::DmcRead) {
422+
//Used to flag the data in the CDL file
423+
isDmcRead = true;
424+
type = MemoryOperationType::Read;
425+
}
426+
420427
ProcessCpuOperation(addr, value, type);
421428

422429
if(type == MemoryOperationType::ExecOpCode) {
@@ -471,6 +478,9 @@ bool Debugger::PrivateProcessRamOperation(MemoryOperationType type, uint16_t &ad
471478
_codeDataLogger->SetFlag(absoluteAddr, CdlPrgFlags::Code);
472479
} else if(type == MemoryOperationType::Read) {
473480
_codeDataLogger->SetFlag(absoluteAddr, CdlPrgFlags::Data);
481+
if(isDmcRead) {
482+
_codeDataLogger->SetFlag(absoluteAddr, CdlPrgFlags::PcmData);
483+
}
474484
}
475485
} else if(addr < 0x2000 || absoluteRamAddr >= 0) {
476486
if(type == MemoryOperationType::Write) {

Core/DeltaModulationChannel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void DeltaModulationChannel::StartDmcTransfer()
6060
void DeltaModulationChannel::FillReadBuffer()
6161
{
6262
if(_bytesRemaining > 0) {
63-
_readBuffer = _memoryManager->Read(_currentAddr);
63+
_readBuffer = _memoryManager->Read(_currentAddr, MemoryOperationType::DmcRead);
6464
_bufferEmpty = false;
6565

6666
_currentAddr++;

Core/Types.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ enum class MemoryOperationType
1515
ExecOpCode = 2,
1616
ExecOperand = 3,
1717
PpuRenderingRead = 4,
18-
DummyRead = 5
18+
DummyRead = 5,
19+
DmcRead = 6
1920
};
2021

2122
struct State

GUI.NET/Config/DebugInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,14 @@ public class DebugInfo
138138
public bool RamHighlightChrReadBytes = false;
139139
public bool RamHighlightCodeBytes = false;
140140
public bool RamHighlightDataBytes = false;
141+
public bool RamHighlightDmcDataBytes = false;
141142
public XmlColor RamReadColor = Color.Blue;
142143
public XmlColor RamWriteColor = Color.Red;
143144
public XmlColor RamExecColor = Color.Green;
144145
public XmlColor RamLabelledByteColor = Color.LightPink;
145146
public XmlColor RamCodeByteColor = Color.DarkSeaGreen;
146147
public XmlColor RamDataByteColor = Color.LightSteelBlue;
148+
public XmlColor RamDmcDataByteColor = Color.Gold;
147149
public XmlColor RamChrDrawnByteColor = Color.DarkSeaGreen;
148150
public XmlColor RamChrReadByteColor = Color.LightSteelBlue;
149151

GUI.NET/Debugger/ByteColorProvider.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ public class ByteColorProvider : IByteColorProvider
2525
bool _hideReadBytes;
2626
bool _hideWrittenBytes;
2727
bool _hideExecutedBytes;
28+
bool _highlightDmcDataBytes;
2829
bool _highlightDataBytes;
2930
bool _highlightCodeBytes;
3031
bool _highlightLabelledBytes;
3132

32-
public ByteColorProvider(DebugMemoryType memoryType, bool showExec, bool showWrite, bool showRead, int framesToFade, bool hideUnusedBytes, bool hideReadBytes, bool hideWrittenBytes, bool hideExecutedBytes, bool highlightDataBytes, bool highlightCodeBytes, bool highlightLabelledBytes)
33+
public ByteColorProvider(DebugMemoryType memoryType, bool showExec, bool showWrite, bool showRead, int framesToFade, bool hideUnusedBytes, bool hideReadBytes, bool hideWrittenBytes, bool hideExecutedBytes, bool highlightDmcDataBytes, bool highlightDataBytes, bool highlightCodeBytes, bool highlightLabelledBytes)
3334
{
3435
_memoryType = memoryType;
3536
_showExec = showExec;
@@ -40,6 +41,7 @@ public ByteColorProvider(DebugMemoryType memoryType, bool showExec, bool showWri
4041
_hideReadBytes = hideReadBytes;
4142
_hideWrittenBytes = hideWrittenBytes;
4243
_hideExecutedBytes = hideExecutedBytes;
44+
_highlightDmcDataBytes = highlightDmcDataBytes;
4345
_highlightDataBytes = highlightDataBytes;
4446
_highlightCodeBytes = highlightCodeBytes;
4547
_highlightLabelledBytes = highlightLabelledBytes;
@@ -59,7 +61,7 @@ public void Prepare(long firstByteIndex, long lastByteIndex)
5961
_execCounts = InteropEmu.DebugGetMemoryAccessCountsEx((UInt32)firstByteIndex, (UInt32)(lastByteIndex - firstByteIndex + 1), _memoryType, MemoryOperationType.Exec);
6062

6163
_cdlData = null;
62-
if(_highlightDataBytes || _highlightCodeBytes || _highlightLabelledBytes) {
64+
if(_highlightDmcDataBytes || _highlightDataBytes || _highlightCodeBytes || _highlightLabelledBytes) {
6365
switch(_memoryType) {
6466
case DebugMemoryType.ChrRom:
6567
case DebugMemoryType.PpuMemory:
@@ -115,6 +117,9 @@ public Color GetByteColor(long firstByteIndex, long byteIndex, out Color bgColor
115117
} else if((_cdlData[index] & 0x01) != 0 && _highlightCodeBytes) {
116118
//Code
117119
bgColor = ConfigManager.Config.DebugInfo.RamCodeByteColor;
120+
} else if((_cdlData[index] & 0x40) != 0 && _highlightDmcDataBytes) {
121+
//DMC channel Data
122+
bgColor = ConfigManager.Config.DebugInfo.RamDmcDataByteColor;
118123
} else if((_cdlData[index] & 0x02) != 0 && _highlightDataBytes) {
119124
//Data
120125
bgColor = ConfigManager.Config.DebugInfo.RamDataByteColor;

GUI.NET/Debugger/frmMemoryViewer.Designer.cs

Lines changed: 46 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GUI.NET/Debugger/frmMemoryViewer.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ protected override void OnLoad(EventArgs e)
5151
this.mnuHighlightChrReadBytes.Checked = ConfigManager.Config.DebugInfo.RamHighlightChrReadBytes;
5252
this.mnuHighlightCodeBytes.Checked = ConfigManager.Config.DebugInfo.RamHighlightCodeBytes;
5353
this.mnuHighlightDataBytes.Checked = ConfigManager.Config.DebugInfo.RamHighlightDataBytes;
54+
this.mnuHighlightDmcDataBytes.Checked = ConfigManager.Config.DebugInfo.RamHighlightDmcDataBytes;
5455

5556
this.UpdateFadeOptions();
5657

@@ -133,6 +134,7 @@ private void UpdateByteColorProvider()
133134
mnuHideReadBytes.Checked,
134135
mnuHideWrittenBytes.Checked,
135136
mnuHideExecutedBytes.Checked,
137+
mnuHighlightDmcDataBytes.Checked,
136138
mnuHighlightDataBytes.Checked,
137139
mnuHighlightCodeBytes.Checked,
138140
mnuHighlightLabelledBytes.Checked
@@ -239,6 +241,7 @@ private void UpdateConfig()
239241
ConfigManager.Config.DebugInfo.RamHighlightChrReadBytes = this.mnuHighlightChrReadBytes.Checked;
240242
ConfigManager.Config.DebugInfo.RamHighlightCodeBytes = this.mnuHighlightCodeBytes.Checked;
241243
ConfigManager.Config.DebugInfo.RamHighlightDataBytes = this.mnuHighlightDataBytes.Checked;
244+
ConfigManager.Config.DebugInfo.RamHighlightDmcDataBytes = this.mnuHighlightDmcDataBytes.Checked;
242245

243246
ConfigManager.ApplyChanges();
244247
}

0 commit comments

Comments
 (0)