diff --git a/Core/TraceLogger.cpp b/Core/TraceLogger.cpp index 9d794a7..3af4b03 100644 --- a/Core/TraceLogger.cpp +++ b/Core/TraceLogger.cpp @@ -392,7 +392,7 @@ const char* TraceLogger::GetExecutionTrace(uint32_t lineCount) lineCount = std::min(lineCount, _logCount); memcpy(_stateCacheCopy, _stateCache, sizeof(_stateCacheCopy)); memcpy(_disassemblyCacheCopy, _disassemblyCache, sizeof(_disassemblyCacheCopy)); - startPos = _currentPos + ExecutionLogSize - lineCount; + startPos = (_currentPos > 0 ? _currentPos : TraceLogger::ExecutionLogSize) - 1; } bool enabled = false; @@ -401,8 +401,11 @@ const char* TraceLogger::GetExecutionTrace(uint32_t lineCount) } if(enabled) { - for(int i = 0; i < (int)lineCount; i++) { - int index = (startPos + i) % ExecutionLogSize; + for(int i = 0; i < TraceLogger::ExecutionLogSize; i++) { + int index = (startPos - i); + if(index < 0) { + index = TraceLogger::ExecutionLogSize + index; + } if((i > 0 && startPos == index) || !_disassemblyCacheCopy[index].IsInitialized()) { //If the entire array was checked, or this element is not initialized, stop @@ -411,9 +414,7 @@ const char* TraceLogger::GetExecutionTrace(uint32_t lineCount) CpuType cpuType = _disassemblyCacheCopy[index].GetCpuType(); if(!_logCpu[(int)cpuType]) { - //This line isn't for a CPU currently being logged, increase the line count to try and - //get the number of lines the UI requested for the CPU type currently being logged - lineCount++; + //This line isn't for a CPU currently being logged continue; } @@ -426,6 +427,11 @@ const char* TraceLogger::GetExecutionTrace(uint32_t lineCount) _disassemblyCacheCopy[index].GetByteCode(byteCode); _executionTrace += byteCode + "\x1"; GetTraceRow(_executionTrace, _disassemblyCacheCopy[index], _stateCacheCopy[index]); + + lineCount--; + if(lineCount == 0) { + break; + } } } return _executionTrace.c_str(); diff --git a/UI/Debugger/Controls/ctrlTextbox.cs b/UI/Debugger/Controls/ctrlTextbox.cs index 6a9e691..1a18351 100644 --- a/UI/Debugger/Controls/ctrlTextbox.cs +++ b/UI/Debugger/Controls/ctrlTextbox.cs @@ -62,6 +62,11 @@ namespace Mesen.GUI.Debugger.Controls set { this._dataProvider = value; + + int lineCount = this._dataProvider.GetLineCount(); + if(this.SelectedLine >= lineCount) { + this.SelectedLine = lineCount - 1; + } this.Invalidate(); } } diff --git a/UI/Debugger/frmTraceLogger.Designer.cs b/UI/Debugger/frmTraceLogger.Designer.cs index e1982ee..0820658 100644 --- a/UI/Debugger/frmTraceLogger.Designer.cs +++ b/UI/Debugger/frmTraceLogger.Designer.cs @@ -475,6 +475,7 @@ namespace Mesen.GUI.Debugger this.chkIndentCode.TabIndex = 8; this.chkIndentCode.Text = "Indent code based on stack pointer"; this.chkIndentCode.UseVisualStyleBackColor = true; + this.chkIndentCode.Visible = false; this.chkIndentCode.CheckedChanged += new System.EventHandler(this.chkOptions_CheckedChanged); // // chkUseLabels @@ -533,6 +534,7 @@ namespace Mesen.GUI.Debugger this.chkExtendZeroPage.TabIndex = 20; this.chkExtendZeroPage.Text = "Show zero page addresses as 2 bytes"; this.chkExtendZeroPage.UseVisualStyleBackColor = true; + this.chkExtendZeroPage.Visible = false; this.chkExtendZeroPage.CheckedChanged += new System.EventHandler(this.chkOptions_CheckedChanged); // // chkLogCpu diff --git a/UI/Debugger/frmTraceLogger.cs b/UI/Debugger/frmTraceLogger.cs index 7e8c303..05efdc7 100644 --- a/UI/Debugger/frmTraceLogger.cs +++ b/UI/Debugger/frmTraceLogger.cs @@ -378,7 +378,7 @@ namespace Mesen.GUI.Debugger { _lineCount = count; UpdateMenu(); - RefreshLog(false, true); + RefreshLog(true, true); } private void mnu30000Lines_Click(object sender, EventArgs e) @@ -499,10 +499,11 @@ namespace Mesen.GUI.Debugger public CodeLineData GetCodeLineData(int lineIndex) { + int count = _textLines.Count - 1; return new CodeLineData() { - Address = _addresses[lineIndex], - Text = _textLines[lineIndex], - ByteCode = _byteCode[lineIndex], + Address = _addresses[count - lineIndex], + Text = _textLines[count - lineIndex], + ByteCode = _byteCode[count - lineIndex], EffectiveAddress = -1 }; }