Skip to content

Commit 7f49f77

Browse files
committed
Save/restore debugger breakpoints.
1 parent ae5021f commit 7f49f77

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed

emulator/Common.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ void DebugLog(const char* message)
101101
#ifndef Q_OS_WIN32
102102
QString dirname = QDir::homePath() + "/.QtUkncBtl/";
103103
QDir tracedir(dirname);
104-
if(!tracedir.exists())
104+
if (!tracedir.exists())
105105
{
106-
if(!tracedir.mkdir(dirname))
106+
if (!tracedir.mkdir(dirname))
107107
{
108108
::perror("Operation failed");
109109
return;
@@ -113,7 +113,7 @@ void DebugLog(const char* message)
113113
#endif
114114
#endif
115115
Common_LogFile = ::fopen(fullpathfile.c_str(), "a+b");
116-
if(!Common_LogFile)
116+
if (!Common_LogFile)
117117
{
118118
::perror("Tracefile opening failed");
119119
return;

emulator/Emulator.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,12 @@ bool Emulator_Init()
7171
m_wEmulatorCPUBpsCount = m_wEmulatorPPUBpsCount = 0;
7272
for (int i = 0; i <= MAX_BREAKPOINTCOUNT; i++)
7373
{
74-
m_EmulatorCPUBps[i] = 0177777;
75-
m_EmulatorPPUBps[i] = 0177777;
74+
uint16_t address = Settings_GetDebugBreakpoint(i, true);
75+
m_EmulatorCPUBps[i] = address;
76+
if (address != 0177777) m_wEmulatorCPUBpsCount = i + 1;
77+
address = Settings_GetDebugBreakpoint(i, false);
78+
m_EmulatorPPUBps[i] = address;
79+
if (address != 0177777) m_wEmulatorPPUBpsCount = i + 1;
7680
}
7781

7882
g_pBoard = new CMotherboard();
@@ -126,6 +130,12 @@ void Emulator_Done()
126130
{
127131
ASSERT(g_pBoard != nullptr);
128132

133+
// Save breakpoints
134+
for (int i = 0; i < MAX_BREAKPOINTCOUNT; i++)
135+
Settings_SetDebugBreakpoint(i, true, i < m_wEmulatorCPUBpsCount ? m_EmulatorCPUBps[i] : 0177777);
136+
for (int i = 0; i < MAX_BREAKPOINTCOUNT; i++)
137+
Settings_SetDebugBreakpoint(i, false, i < m_wEmulatorPPUBpsCount ? m_EmulatorPPUBps[i] : 0177777);
138+
129139
CProcessor::Done();
130140

131141
g_pBoard->SetSoundGenCallback(nullptr);

emulator/Settings.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,25 @@ quint16 Settings_GetDebugMemoryMode()
105105
return (quint16)value.toUInt();
106106
}
107107

108+
void Settings_SetDebugBreakpoint(int bpno, bool okCpuPpu, quint16 address)
109+
{
110+
char bufValueName[] = "DebugBreakptCpu0";
111+
bufValueName[12] = okCpuPpu ? 'C' : 'P';
112+
bufValueName[15] = bpno < 10 ? '0' + (char)bpno : 'A' + (char)(bpno - 10);
113+
if (address == 0177777)
114+
Global_getSettings()->remove(bufValueName);
115+
else
116+
Global_getSettings()->setValue(bufValueName, address);
117+
}
118+
quint16 Settings_GetDebugBreakpoint(int bpno, bool okCpuPpu)
119+
{
120+
char bufValueName[] = "DebugBreakptCpu0";
121+
bufValueName[12] = okCpuPpu ? 'C' : 'P';
122+
bufValueName[15] = bpno < 10 ? '0' + (char)bpno : 'A' + (char)(bpno - 10);
123+
QVariant value = Global_getSettings()->value(bufValueName, 0177777);
124+
return (quint16)value.toUInt();
125+
}
126+
108127
void Settings_SetDebugMemoryAddress(quint16 mode)
109128
{
110129
Global_getSettings()->setValue("DebugMemoryAddress", mode);

emulator/main.h

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ void Settings_SetSoundAY(bool flag);
4141
bool Settings_GetSoundAY();
4242
bool Settings_GetDebugCpuPpu();
4343
void Settings_SetDebugCpuPpu(bool flag);
44+
void Settings_SetDebugBreakpoint(int bpno, bool okCpuPpu, quint16 address);
45+
quint16 Settings_GetDebugBreakpoint(int bpno, bool okCpuPpu);
4446
void Settings_SetDebugMemoryMode(quint16 mode);
4547
quint16 Settings_GetDebugMemoryMode();
4648
void Settings_SetDebugMemoryAddress(quint16 address);

0 commit comments

Comments
 (0)