From 6378c32130ed12bb7212ae3a6b9a4e3320a664ec Mon Sep 17 00:00:00 2001 From: nzeemin Date: Sat, 1 Aug 2020 14:56:40 +0300 Subject: [PATCH] Debugger breakpoints. --- emulator/ConsoleView.cpp | 63 +++++++++++- emulator/DebugView.cpp | 4 +- emulator/DisasmView.cpp | 30 +++++- emulator/Emulator.cpp | 194 +++++++++++++++++++++++++++++++---- emulator/Emulator.h | 14 ++- emulator/Main.cpp | 11 +- emulator/Main.h | 3 +- emulator/Settings.cpp | 3 +- emulator/Views.h | 1 + emulator/emubase/Board.cpp | 8 +- emulator/emubase/Board.h | 8 +- emulator/emubase/Floppy.cpp | 12 +-- emulator/emubase/Processor.h | 1 + 13 files changed, 301 insertions(+), 51 deletions(-) diff --git a/emulator/ConsoleView.cpp b/emulator/ConsoleView.cpp index 6602dfa..48b9bea 100644 --- a/emulator/ConsoleView.cpp +++ b/emulator/ConsoleView.cpp @@ -515,6 +515,9 @@ void ConsoleView_ShowHelp() _T(" rN XXXXXX Set register N to value XXXXXX; N=0..7,ps\r\n") _T(" s Step Into; executes one instruction\r\n") _T(" so Step Over; executes and stops after the current instruction\r\n") + _T(" b List breakpoints set for the current processor\r\n") + _T(" bXXXXXX Set breakpoint at address XXXXXX\r\n") + _T(" bcXXXXXX Remove breakpoint at address XXXXXX\r\n") _T(" u Save memory dump to file memdumpXPU.bin\r\n") _T(" udl Save display list dump to file displaylist.txt\r\n") #if !defined(PRODUCT) @@ -634,9 +637,9 @@ void DoConsoleCommand() WORD bpaddress = (WORD)(pProc->GetPC() + instrLength * 2); if (m_okCurrentProc) - Emulator_SetCPUBreakpoint(bpaddress); + Emulator_SetTempCPUBreakpoint(bpaddress); else - Emulator_SetPPUBreakpoint(bpaddress); + Emulator_SetTempPPUBreakpoint(bpaddress); Emulator_Start(); } break; @@ -716,17 +719,69 @@ void DoConsoleCommand() { if (m_okCurrentProc) { - Emulator_SetCPUBreakpoint(value); + Emulator_SetTempCPUBreakpoint(value); Emulator_Start(); } else { - Emulator_SetPPUBreakpoint(value); + Emulator_SetTempPPUBreakpoint(value); Emulator_Start(); } } } break; + case _T('b'): + if (command[1] == 0) // b - list breakpoints + { + const uint16_t* pbps = m_okCurrentProc ? Emulator_GetCPUBreakpointList() : Emulator_GetPPUBreakpointList(); + if (pbps == nullptr || *pbps == 0177777) + { + ConsoleView_Print(_T(" No breakpoints.\r\n")); + } + else + { + while (*pbps != 0177777) + { + ConsoleView_PrintFormat(_T(" %06ho\r\n"), *pbps); + pbps++; + } + } + } + else if (command[1] == _T('c')) + { + if (command[2] == 0) // bc + { + //TODO: bc - clear all breakpoints + ConsoleView_Print(MESSAGE_UNKNOWN_COMMAND); + } + else // bcXXXXXX - remove breakpoint XXXXXX + { + WORD value; + if (!ParseOctalValue(command + 2, &value)) + ConsoleView_Print(MESSAGE_WRONG_VALUE); + else + { + bool result = m_okCurrentProc ? Emulator_RemoveCPUBreakpoint(value) : Emulator_RemovePPUBreakpoint(value); + if (!result) + ConsoleView_Print(_T(" Failed to remove breakpoint.\r\n")); + DisasmView_Redraw(); + } + } + } + else // bXXXXXX - add breakpoint XXXXXX + { + WORD value; + if (! ParseOctalValue(command + 1, &value)) + ConsoleView_Print(MESSAGE_WRONG_VALUE); + else + { + bool result = m_okCurrentProc ? Emulator_AddCPUBreakpoint(value) : Emulator_AddPPUBreakpoint(value); + if (!result) + ConsoleView_Print(_T(" Failed to add breakpoint.\r\n")); + DisasmView_Redraw(); + } + } + break; #if !defined(PRODUCT) case _T('t'): if (command[1] == _T('c')) // "tc" -- clear trace log diff --git a/emulator/DebugView.cpp b/emulator/DebugView.cpp index 7a35357..202f03c 100644 --- a/emulator/DebugView.cpp +++ b/emulator/DebugView.cpp @@ -537,8 +537,8 @@ void DebugView_DrawPorts(HDC hdc, BOOL okProcessor, const CMemoryController* pMe uint16_t* addresses = okProcessor ? m_DebugViewCPUPorts : m_DebugViewPPUPorts; int addrcount = okProcessor - ? sizeof(m_DebugViewCPUPorts) / sizeof(m_DebugViewCPUPorts[0]) - : sizeof(m_DebugViewPPUPorts) / sizeof(m_DebugViewPPUPorts[0]); + ? sizeof(m_DebugViewCPUPorts) / sizeof(m_DebugViewCPUPorts[0]) + : sizeof(m_DebugViewPPUPorts) / sizeof(m_DebugViewPPUPorts[0]); for (int i = 0; i < addrcount; i++) { uint16_t address = addresses[i]; diff --git a/emulator/DisasmView.cpp b/emulator/DisasmView.cpp index c148f9b..df306ac 100644 --- a/emulator/DisasmView.cpp +++ b/emulator/DisasmView.cpp @@ -111,6 +111,11 @@ void DisasmView_Create(HWND hwndParent, int x, int y, int width, int height) g_hwndDisasm, NULL, g_hInst, NULL); } +void DisasmView_Redraw() +{ + RedrawWindow(g_hwndDisasm, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_ALLCHILDREN); +} + // Adjust position of client windows void DisasmView_AdjustWindowLayout() { @@ -914,6 +919,18 @@ int DisasmView_GetInstructionHint(const WORD* memory, const CProcessor * pProc, return result; } +void DisasmView_DrawBreakpoint(HDC hdc, int x, int y, int size) +{ + COLORREF colorBreakpoint = Settings_GetColor(ColorDebugBreakpoint); + HBRUSH hBreakBrush = CreateSolidBrush(colorBreakpoint); + HGDIOBJ hOldBrush = SelectObject(hdc, hBreakBrush); + HGDIOBJ hOldPen = SelectObject(hdc, GetStockObject(NULL_PEN)); + Ellipse(hdc, x, y, x + size, y + size); + ::SelectObject(hdc, hOldPen); + ::SelectObject(hdc, hOldBrush); + ::DeleteObject(hBreakBrush); +} + int DisasmView_DrawDisassemble(HDC hdc, CProcessor* pProc, WORD base, WORD previous, int x, int y) { int result = -1; @@ -939,9 +956,9 @@ int DisasmView_DrawDisassemble(HDC hdc, CProcessor* pProc, WORD base, WORD previ // Draw current line background if (!m_okDisasmSubtitles) //NOTE: Subtitles can move lines down { + int yCurrent = (proccurrent - (current - 5)) * cyLine; HBRUSH hBrushCurrent = ::CreateSolidBrush(colorBackCurr); HGDIOBJ oldBrush = ::SelectObject(hdc, hBrushCurrent); - int yCurrent = (proccurrent - (current - 5)) * cyLine; PatBlt(hdc, 0, yCurrent, 1000, cyLine, PATCOPY); ::SelectObject(hdc, oldBrush); ::DeleteObject(hBrushCurrent); @@ -981,6 +998,11 @@ int DisasmView_DrawDisassemble(HDC hdc, CProcessor* pProc, WORD base, WORD previ } } + if (Emulator_IsBreakpoint(m_okDisasmProcessor, address)) // Breakpoint + { + DisasmView_DrawBreakpoint(hdc, x + cxChar / 2, y, cyLine); + } + DrawOctalValue(hdc, x + 5 * cxChar, y, address); // Address // Value at the address WORD value = memory[index]; @@ -992,15 +1014,15 @@ int DisasmView_DrawDisassemble(HDC hdc, CProcessor* pProc, WORD base, WORD previ // Current position if (address == current) { - TextOut(hdc, x + 1 * cxChar, y, _T(" >"), 3); + //TextOut(hdc, x + 2 * cxChar, y, _T(" > "), 3); result = y; // Remember line for the focus rect } if (address == proccurrent) - TextOut(hdc, x + 1 * cxChar, y, _T("PC>>"), 4); + TextOut(hdc, x + 2 * cxChar, y, _T("PC>"), 3); else if (address == previous) { ::SetTextColor(hdc, colorPrev); - TextOut(hdc, x + 1 * cxChar, y, _T(" > "), 4); + TextOut(hdc, x + 2 * cxChar, y, _T(" > "), 3); } BOOL okData = FALSE; diff --git a/emulator/Emulator.cpp b/emulator/Emulator.cpp index dfe715d..0917a3d 100644 --- a/emulator/Emulator.cpp +++ b/emulator/Emulator.cpp @@ -31,8 +31,12 @@ CMotherboard* g_pBoard = nullptr; bool g_okEmulatorInitialized = false; bool g_okEmulatorRunning = false; -uint16_t m_wEmulatorCPUBreakpoint = 0177777; -uint16_t m_wEmulatorPPUBreakpoint = 0177777; +int m_wEmulatorCPUBpsCount = 0; +int m_wEmulatorPPUBpsCount = 0; +uint16_t m_EmulatorCPUBps[MAX_BREAKPOINTCOUNT + 1]; +uint16_t m_EmulatorPPUBps[MAX_BREAKPOINTCOUNT + 1]; +uint16_t m_wEmulatorTempCPUBreakpoint = 0177777; +uint16_t m_wEmulatorTempPPUBreakpoint = 0177777; bool m_okEmulatorSound = false; uint16_t m_wEmulatorSoundSpeed = 100; @@ -121,6 +125,13 @@ bool Emulator_Init() ::memset(g_pEmulatorChangedRam, 0, sizeof(g_pEmulatorChangedRam)); CProcessor::Init(); + m_wEmulatorCPUBpsCount = m_wEmulatorPPUBpsCount = 0; + for (int i = 0; i <= MAX_BREAKPOINTCOUNT; i++) + { + m_EmulatorCPUBps[i] = 0177777; + m_EmulatorPPUBps[i] = 0177777; + } + g_pBoard = new CMotherboard(); if (! Emulator_LoadUkncRom()) @@ -199,12 +210,20 @@ void Emulator_Start() m_nFrameCount = 0; m_dwTickCount = GetTickCount(); + + // For proper breakpoint processing + if (m_wEmulatorCPUBpsCount != 0 || m_wEmulatorPPUBpsCount) + { + g_pBoard->GetCPU()->ClearInternalTick(); + g_pBoard->GetPPU()->ClearInternalTick(); + } } void Emulator_Stop() { g_okEmulatorRunning = false; - m_wEmulatorCPUBreakpoint = 0177777; - m_wEmulatorPPUBreakpoint = 0177777; + + Emulator_SetTempCPUBreakpoint(0177777); + Emulator_SetTempPPUBreakpoint(0177777); if (m_fpEmulatorParallelOut != nullptr) ::fflush(m_fpEmulatorParallelOut); @@ -230,22 +249,157 @@ void Emulator_Reset() MainWindow_UpdateAllViews(); } -void Emulator_SetCPUBreakpoint(uint16_t address) +bool Emulator_AddCPUBreakpoint(uint16_t address) { - m_wEmulatorCPUBreakpoint = address; + if (m_wEmulatorCPUBpsCount == MAX_BREAKPOINTCOUNT - 1 || address == 0177777) + return false; + for (int i = 0; i < m_wEmulatorCPUBpsCount; i++) // Check if the BP exists + { + if (m_EmulatorCPUBps[i] == address) + return false; // Already in the list + } + for (int i = 0; i < MAX_BREAKPOINTCOUNT; i++) // Put in the first empty cell + { + if (m_EmulatorCPUBps[i] == 0177777) + { + m_EmulatorCPUBps[i] = address; + break; + } + } + m_wEmulatorCPUBpsCount++; + return true; +} +bool Emulator_AddPPUBreakpoint(uint16_t address) +{ + if (m_wEmulatorPPUBpsCount == MAX_BREAKPOINTCOUNT - 1 || address == 0177777) + return false; + for (int i = 0; i < m_wEmulatorPPUBpsCount; i++) // Check if the BP exists + { + if (m_EmulatorPPUBps[i] == address) + return false; // Already in the list + } + for (int i = 0; i < MAX_BREAKPOINTCOUNT; i++) // Put in the first empty cell + { + if (m_EmulatorPPUBps[i] == 0177777) + { + m_EmulatorPPUBps[i] = address; + break; + } + } + m_wEmulatorPPUBpsCount++; + return true; } -void Emulator_SetPPUBreakpoint(uint16_t address) +bool Emulator_RemoveCPUBreakpoint(uint16_t address) { - m_wEmulatorPPUBreakpoint = address; + if (m_wEmulatorCPUBpsCount == 0 || address == 0177777) + return false; + for (int i = 0; i < MAX_BREAKPOINTCOUNT; i++) + { + if (m_EmulatorCPUBps[i] == address) + { + m_EmulatorCPUBps[i] = 0177777; + m_wEmulatorCPUBpsCount--; + if (m_wEmulatorCPUBpsCount > i) // fill the hole + { + m_EmulatorCPUBps[i] = m_EmulatorCPUBps[m_wEmulatorCPUBpsCount]; + m_EmulatorCPUBps[m_wEmulatorCPUBpsCount] = 0177777; + } + return true; + } + } + return false; } +bool Emulator_RemovePPUBreakpoint(uint16_t address) +{ + if (m_wEmulatorPPUBpsCount == 0 || address == 0177777) + return false; + for (int i = 0; i < MAX_BREAKPOINTCOUNT; i++) + { + if (m_EmulatorPPUBps[i] == address) + { + m_EmulatorPPUBps[i] = 0177777; + m_wEmulatorPPUBpsCount--; + if (m_wEmulatorPPUBpsCount > i) // fill the hole + { + m_EmulatorPPUBps[i] = m_EmulatorPPUBps[m_wEmulatorPPUBpsCount]; + m_EmulatorPPUBps[m_wEmulatorPPUBpsCount] = 0177777; + } + return true; + } + } + return false; +} +void Emulator_SetTempCPUBreakpoint(uint16_t address) +{ + if (m_wEmulatorTempCPUBreakpoint != 0177777) + Emulator_RemoveCPUBreakpoint(m_wEmulatorTempCPUBreakpoint); + if (address == 0177777) + { + m_wEmulatorTempCPUBreakpoint = 0177777; + return; + } + for (int i = 0; i < MAX_BREAKPOINTCOUNT; i++) + { + if (m_EmulatorCPUBps[i] == address) + return; // We have regular breakpoint with the same address + } + m_wEmulatorTempCPUBreakpoint = address; + m_EmulatorCPUBps[m_wEmulatorCPUBpsCount] = address; + m_wEmulatorCPUBpsCount++; +} +void Emulator_SetTempPPUBreakpoint(uint16_t address) +{ + if (m_wEmulatorTempPPUBreakpoint != 0177777) + Emulator_RemovePPUBreakpoint(m_wEmulatorTempPPUBreakpoint); + if (address == 0177777) + { + m_wEmulatorTempPPUBreakpoint = 0177777; + return; + } + for (int i = 0; i < MAX_BREAKPOINTCOUNT; i++) + { + if (m_EmulatorPPUBps[i] == address) + return; // We have regular breakpoint with the same address + } + m_wEmulatorTempPPUBreakpoint = address; + m_EmulatorPPUBps[m_wEmulatorPPUBpsCount] = address; + m_wEmulatorPPUBpsCount++; +} +const uint16_t* Emulator_GetCPUBreakpointList() { return m_EmulatorCPUBps; } +const uint16_t* Emulator_GetPPUBreakpointList() { return m_EmulatorPPUBps; } bool Emulator_IsBreakpoint() { - uint16_t wCPUAddr = g_pBoard->GetCPU()->GetPC(); - if (wCPUAddr == m_wEmulatorCPUBreakpoint) - return true; - uint16_t wPPUAddr = g_pBoard->GetPPU()->GetPC(); - if (wPPUAddr == m_wEmulatorPPUBreakpoint) - return true; + uint16_t address = g_pBoard->GetCPU()->GetPC(); + if (m_wEmulatorCPUBpsCount > 0) + { + for (int i = 0; i < m_wEmulatorCPUBpsCount; i++) + { + if (address == m_EmulatorCPUBps[i]) + return true; + } + } + address = g_pBoard->GetPPU()->GetPC(); + if (m_wEmulatorPPUBpsCount > 0) + { + for (int i = 0; i < m_wEmulatorPPUBpsCount; i++) + { + if (address == m_EmulatorPPUBps[i]) + return true; + } + } + return false; +} +bool Emulator_IsBreakpoint(bool okCpuPpu, uint16_t address) +{ + int bpsCount = okCpuPpu ? m_wEmulatorCPUBpsCount : m_wEmulatorPPUBpsCount; + uint16_t* pbps = okCpuPpu ? m_EmulatorCPUBps : m_EmulatorPPUBps; + if (bpsCount == 0) + return false; + for (int i = 0; i < bpsCount; i++) + { + if (address == pbps[i]) + return true; + } return false; } @@ -512,13 +666,17 @@ bool Emulator_SystemFrame() { SoundGen_SetVolume(Settings_GetSoundVolume()); - g_pBoard->SetCPUBreakpoint(m_wEmulatorCPUBreakpoint); - g_pBoard->SetPPUBreakpoint(m_wEmulatorPPUBreakpoint); - ScreenView_ScanKeyboard(); - if (!g_pBoard->SystemFrame()) + g_pBoard->SetCPUBreakpoints(m_wEmulatorCPUBpsCount > 0 ? m_EmulatorCPUBps : nullptr); + g_pBoard->SetPPUBreakpoints(m_wEmulatorPPUBpsCount > 0 ? m_EmulatorPPUBps : nullptr); + + if (!g_pBoard->SystemFrame()) // Breakpoint hit + { + Emulator_SetTempCPUBreakpoint(0177777); + Emulator_SetTempPPUBreakpoint(0177777); return false; + } // Calculate frames per second m_nFrameCount++; diff --git a/emulator/Emulator.h b/emulator/Emulator.h index 8151a1c..4c7c439 100644 --- a/emulator/Emulator.h +++ b/emulator/Emulator.h @@ -16,6 +16,7 @@ UKNCBTL. If not, see . */ ////////////////////////////////////////////////////////////////////// +const int MAX_BREAKPOINTCOUNT = 16; extern CMotherboard* g_pBoard; @@ -34,9 +35,18 @@ extern uint16_t g_wEmulatorPrevPpuPC; // Previous PC value bool Emulator_Init(); void Emulator_Done(); -void Emulator_SetCPUBreakpoint(uint16_t address); -void Emulator_SetPPUBreakpoint(uint16_t address); + +bool Emulator_AddCPUBreakpoint(uint16_t address); +bool Emulator_AddPPUBreakpoint(uint16_t address); +bool Emulator_RemoveCPUBreakpoint(uint16_t address); +bool Emulator_RemovePPUBreakpoint(uint16_t address); +void Emulator_SetTempCPUBreakpoint(uint16_t address); +void Emulator_SetTempPPUBreakpoint(uint16_t address); +const uint16_t* Emulator_GetCPUBreakpointList(); +const uint16_t* Emulator_GetPPUBreakpointList(); bool Emulator_IsBreakpoint(); +bool Emulator_IsBreakpoint(bool okCpuPpu, uint16_t address); + void Emulator_SetSound(bool soundOnOff); bool Emulator_SetSerial(bool serialOnOff, LPCTSTR serialPort); void Emulator_SetParallel(bool parallelOnOff); diff --git a/emulator/Main.cpp b/emulator/Main.cpp index ddf4ad7..b348bfb 100644 --- a/emulator/Main.cpp +++ b/emulator/Main.cpp @@ -85,14 +85,13 @@ int APIENTRY _tWinMain( ::Sleep(1); else { - if (Emulator_IsBreakpoint()) - Emulator_Stop(); - else + if (!Emulator_SystemFrame()) { - Emulator_SystemFrame(); - - ScreenView_RedrawScreen(); + // Breakpoint hit + Emulator_Stop(); } + + ScreenView_RedrawScreen(); } // Process all queue diff --git a/emulator/Main.h b/emulator/Main.h index 58bf6c9..db9c6ce 100644 --- a/emulator/Main.h +++ b/emulator/Main.h @@ -134,8 +134,9 @@ enum ColorIndices ColorDebugJumpNo = 12, ColorDebugJumpHint = 13, ColorDebugHint = 14, + ColorDebugBreakpoint = 15, - ColorIndicesCount = 15, + ColorIndicesCount = 16, }; diff --git a/emulator/Settings.cpp b/emulator/Settings.cpp index 9adb731..5d3ccd4 100644 --- a/emulator/Settings.cpp +++ b/emulator/Settings.cpp @@ -485,7 +485,7 @@ static ColorDescriptors[ColorIndicesCount] = { _T("ColorDebugValueChanged"), RGB(255, 0, 0), FALSE, _T("Debug Value Changed") }, { _T("ColorDebugPrevious"), RGB(0, 0, 255), FALSE, _T("Debug Previous Address Marker") }, { _T("ColorDebugMemoryROM"), RGB(0, 0, 255), FALSE, _T("Debug Memory ROM") }, - { _T("ColorDebugMemoryIO"), RGB(128, 192, 128), FALSE, _T("Debug Memory IO") }, + { _T("ColorDebugMemoryIO"), RGB(0, 128, 0), FALSE, _T("Debug Memory IO") }, { _T("ColorDebugMemoryNA"), RGB(128, 128, 128), FALSE, _T("Debug Memory NA") }, { _T("ColorDebugValue"), RGB(128, 128, 128), FALSE, _T("Debug Value") }, { _T("ColorDebugValueRom"), RGB(128, 128, 192), FALSE, _T("Debug Value ROM") }, @@ -495,6 +495,7 @@ static ColorDescriptors[ColorIndicesCount] = { _T("ColorDebugJumpNo"), RGB(180, 180, 180), FALSE, _T("Debug Jump No") }, { _T("ColorDebugJumpHint"), RGB(40, 128, 160), FALSE, _T("Debug Jump Hint") }, { _T("ColorDebugHint"), RGB(40, 40, 160), FALSE, _T("Debug Hint") }, + { _T("ColorDebugBreakpoint"), RGB(255, 128, 128), FALSE, _T("Debug Breakpoint") }, }; LPCTSTR Settings_GetColorFriendlyName(ColorIndices colorIndex) diff --git a/emulator/Views.h b/emulator/Views.h index f64c64d..5ff5243 100644 --- a/emulator/Views.h +++ b/emulator/Views.h @@ -92,6 +92,7 @@ extern HWND g_hwndDisasm; // Disasm View window handle void DisasmView_RegisterClass(); void DisasmView_Create(HWND hwndParent, int x, int y, int width, int height); +void DisasmView_Redraw(); LRESULT CALLBACK DisasmViewWndProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK DisasmViewViewerWndProc(HWND, UINT, WPARAM, LPARAM); void DisasmView_OnUpdate(); diff --git a/emulator/emubase/Board.cpp b/emulator/emubase/Board.cpp index d2f1cc4..5809114 100644 --- a/emulator/emubase/Board.cpp +++ b/emulator/emubase/Board.cpp @@ -661,8 +661,10 @@ void CMotherboard::DebugTicks() */ #define SYSTEMFRAME_EXECUTE_CPU { m_pCPU->Execute(); } #define SYSTEMFRAME_EXECUTE_PPU { m_pPPU->Execute(); } -#define SYSTEMFRAME_EXECUTE_BP_CPU { m_pCPU->Execute(); if (m_pCPU->GetPC() == m_CPUbp) return false; } -#define SYSTEMFRAME_EXECUTE_BP_PPU { m_pPPU->Execute(); if (m_pPPU->GetPC() == m_PPUbp) return false; } +#define SYSTEMFRAME_EXECUTE_BP_CPU { m_pCPU->Execute(); if (m_CPUbps != nullptr) \ + { const uint16_t* pbps = m_CPUbps; while(*pbps != 0177777) { if (m_pCPU->GetPC() == *pbps++) return false; } } } +#define SYSTEMFRAME_EXECUTE_BP_PPU { m_pPPU->Execute(); if (m_PPUbps != nullptr) \ + { const uint16_t* pbps = m_PPUbps; while(*pbps != 0177777) { if (m_pPPU->GetPC() == *pbps++) return false; } } } bool CMotherboard::SystemFrame() { int frameticks = 0; // 20000 ticks @@ -688,7 +690,7 @@ bool CMotherboard::SystemFrame() Tick50(); // 1/50 timer event // CPU - 16 times, PPU - 12.5 times - if (m_CPUbp == 0177777 && m_PPUbp == 0177777) // No breakpoints, no need to check + if (m_CPUbps == nullptr && m_PPUbps == nullptr) // No breakpoints, no need to check { /* 0 */ SYSTEMFRAME_EXECUTE_CPU; SYSTEMFRAME_EXECUTE_PPU; /* 1 */ SYSTEMFRAME_EXECUTE_CPU; SYSTEMFRAME_EXECUTE_PPU; diff --git a/emulator/emubase/Board.h b/emulator/emubase/Board.h index ff280d2..a9ab075 100644 --- a/emulator/emubase/Board.h +++ b/emulator/emubase/Board.h @@ -166,8 +166,8 @@ class CMotherboard uint8_t GetROMCartByte(int cartno, uint16_t offset) const; public: // Debug void DebugTicks(); ///< One Debug PPU tick -- use for debug step or debug breakpoint - void SetCPUBreakpoint(uint16_t bp) { m_CPUbp = bp; } ///< Set current CPU breakpoint - void SetPPUBreakpoint(uint16_t bp) { m_PPUbp = bp; } ///< Set current PPU breakpoint + void SetCPUBreakpoints(const uint16_t* bps) { m_CPUbps = bps; } ///< Set CPU breakpoint list + void SetPPUBreakpoints(const uint16_t* bps) { m_PPUbps = bps; } ///< Set PPU breakpoint list uint32_t GetTrace() const { return m_dwTrace; } void SetTrace(uint32_t dwTrace); chan_stc GetChannelStruct(unsigned char cpu, unsigned char chan, unsigned char tx) @@ -292,8 +292,8 @@ class CMotherboard int m_cputicks; unsigned int m_lineticks; private: - uint16_t m_CPUbp; ///< Current CPU breakpoint, 177777 if not set - uint16_t m_PPUbp; ///< Current PPU breakpoint, 177777 if not set + const uint16_t* m_CPUbps; ///< CPU breakpoint list, ends with 177777 value + const uint16_t* m_PPUbps; ///< PPU breakpoint list, ends with 177777 value uint32_t m_dwTrace; ///< Trace flags uint16_t m_timer; diff --git a/emulator/emubase/Floppy.cpp b/emulator/emubase/Floppy.cpp index 90688f8..a7acd5b 100644 --- a/emulator/emubase/Floppy.cpp +++ b/emulator/emubase/Floppy.cpp @@ -186,9 +186,9 @@ void CFloppyController::SetCommand(uint16_t cmd) { FlushChanges(); -//#if !defined(PRODUCT) -// DebugLogFormat(_T("Floppy DRIVE %hu\r\n"), newdrive); -//#endif +#if !defined(PRODUCT) + DebugLogFormat(_T("Floppy DRIVE %hu\r\n"), newdrive); +#endif m_drive = newdrive; m_pDrive = m_drivedata + m_drive; @@ -258,9 +258,9 @@ void CFloppyController::SetCommand(uint16_t cmd) uint16_t CFloppyController::GetData(void) { -//#if !defined(PRODUCT) -// DebugLogFormat(_T("Floppy READ\t\t%04x\r\n"), m_datareg); //DEBUG -//#endif +#if !defined(PRODUCT) + DebugLogFormat(_T("Floppy READ\t\t%04x\r\n"), m_datareg); //DEBUG +#endif m_status &= ~FLOPPY_STATUS_MOREDATA; m_writing = m_searchsync = false; diff --git a/emulator/emubase/Processor.h b/emulator/emubase/Processor.h index 4a42617..ab19ede 100644 --- a/emulator/emubase/Processor.h +++ b/emulator/emubase/Processor.h @@ -135,6 +135,7 @@ class CProcessor /// \brief Execute next command and process interrupts void CommandExecution(); int GetInternalTick() const { return m_internalTick; } + void ClearInternalTick() { m_internalTick = 0; } public: // Saving/loading emulator status (pImage addresses up to 32 bytes) void SaveToImage(uint8_t* pImage) const;