Skip to content

Commit dbf5d4f

Browse files
committed
breakpoint ui
1 parent a0fc20f commit dbf5d4f

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

emulator/src/Gui/CodeViewer.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,29 +80,26 @@ CodeElem CodeViewer::LookUp(uint8_t seg, uint16_t offset, int *idx) {
8080

8181
/**
8282
* called before the instruction is executed (for breakpoints/step, in CPU.cpp) or
83-
* right after a POP PC is executed (for RET TRACE, in CPUPushPop.cpp)
83+
* right after a POP PC is executed (for TRACE, in CPUPushPop.cpp)
8484
*/
8585
bool CodeViewer::TryTrigBP(uint8_t seg, uint16_t offset, bool bp_mode) {
8686
for (auto it = break_points.begin(); it != break_points.end(); it++) {
8787
if (it->second == 1) {
88-
// TODO: We ignore a second trigger
8988
CodeElem e = codes[it->first];
9089
if (e.segment == seg && e.offset == offset) {
91-
break_points[it->first] = 2;
9290
cur_row = it->first;
93-
need_roll = true;
9491
bp = it->first;
92+
need_roll = true;
9593
return true;
9694
}
9795
}
9896
}
9997
if (!bp_mode && (debug_flags & DEBUG_STEP || debug_flags & DEBUG_RET_TRACE)) { // pause for step/trace
10098
int idx = 0;
10199
LookUp(seg, offset, &idx);
102-
break_points[idx] = 2;
103100
cur_row = idx;
104-
need_roll = true;
105101
bp = idx;
102+
need_roll = true;
106103
return true;
107104
}
108105
return false;
@@ -113,21 +110,22 @@ void CodeViewer::DrawContent() {
113110
c.Begin(max_row, ImGui::GetTextLineHeight());
114111
while (c.Step()) {
115112
for (int line_i = c.DisplayStart; line_i < c.DisplayEnd; line_i++) {
113+
if (line_i == bp) {
114+
// the break point is triggered!
115+
ImGui::TextColored(ImVec4(0.0, 1.0, 0.0, 1.0), "[ > ]");
116+
}
116117
CodeElem e = codes[line_i];
117118
auto it = break_points.find(line_i);
118-
if (it == break_points.end()) {
119+
if (it == break_points.end() || !break_points[line_i]) {
119120
ImGui::Text("[ o ]");
120121
if (ImGui::IsItemHovered() && ImGui::IsMouseClicked(0)) {
121122
break_points[line_i] = 1;
122123
}
123-
} else if (it->second == 1) {
124+
} else {
124125
ImGui::TextColored(ImVec4(1.0, 0.0, 0.0, 1.0), "[ x ]");
125126
if (ImGui::IsItemHovered() && ImGui::IsMouseClicked(0)) {
126-
break_points.erase(line_i);
127+
break_points[line_i] = 0;
127128
}
128-
} else { // it->second == 2
129-
// the break point is triggered!
130-
ImGui::TextColored(ImVec4(0.0, 1.0, 0.0, 1.0), "[ > ]");
131129
}
132130
ImGui::SameLine();
133131
ImGui::TextColored(ImVec4(1.0, 1.0, 0.0, 1.0), "%d:%04x", e.segment, e.offset);
@@ -218,8 +216,9 @@ void CodeViewer::DrawWindow() {
218216
ImGui::Checkbox("TRACE", &trace_debug);
219217
if (bp != -1) {
220218
ImGui::SameLine();
221-
if (ImGui::Button("Continue?")) {
222-
break_points.erase(bp);
219+
if (ImGui::Button("Continue")) {
220+
if (!step_debug && !trace_debug)
221+
break_points[bp] = 0;
223222
m_emu->SetPaused(false);
224223
bp = -1;
225224
}

0 commit comments

Comments
 (0)