@@ -67,12 +67,10 @@ CodeViewer::~CodeViewer() {
67
67
68
68
CodeElem CodeViewer::LookUp (uint8_t seg, uint16_t offset, int *idx) {
69
69
// binary search
70
- CodeElem target;
71
- target.offset = offset;
72
- target.segment = seg;
73
- auto it = std::lower_bound (codes.begin (), codes.end (), target);
74
- if (it == codes.end ())
75
- it = codes.begin ();
70
+ CodeElem target (seg, offset);
71
+ auto it = std::upper_bound (codes.begin (), codes.end (), target);
72
+ if (it != codes.begin ())
73
+ --it;
76
74
if (idx)
77
75
*idx = it - codes.begin ();
78
76
return CodeElem (it->segment , it->offset );
@@ -86,8 +84,8 @@ bool CodeViewer::TryTrigBP(uint8_t seg, uint16_t offset, bool is_bp) {
86
84
int idx = 0 ;
87
85
LookUp (seg, offset, &idx);
88
86
cur_row = idx;
89
- triggered_bp_line = idx ;
90
- need_roll = true ;
87
+ triggered_bp_line = - 1 ;
88
+ try_roll = true ;
91
89
return true ;
92
90
}
93
91
for (auto it = break_points.begin (); it != break_points.end (); it++) {
@@ -96,7 +94,7 @@ bool CodeViewer::TryTrigBP(uint8_t seg, uint16_t offset, bool is_bp) {
96
94
if (e.segment == seg && e.offset == offset) {
97
95
cur_row = it->first ;
98
96
triggered_bp_line = it->first ;
99
- need_roll = true ;
97
+ try_roll = true ;
100
98
return true ;
101
99
}
102
100
}
@@ -133,11 +131,13 @@ void CodeViewer::DrawContent() {
133
131
else
134
132
ImGui::Text (" %s" , e.srcbuf );
135
133
}
136
- }
137
- if (need_roll) {
138
- float v = (float )cur_row / max_row * ImGui::GetScrollMaxY ();
139
- ImGui::SetScrollY (v);
140
- need_roll = false ;
134
+ if (try_roll) {
135
+ try_roll = false ;
136
+ if (!(c.DisplayStart + 1 <= cur_row && cur_row < c.DisplayEnd - 5 )) {
137
+ float v = (float )cur_row / max_row * ImGui::GetScrollMaxY ();
138
+ ImGui::SetScrollY (v);
139
+ }
140
+ }
141
141
}
142
142
}
143
143
@@ -162,8 +162,7 @@ void CodeViewer::DrawWindow() {
162
162
ImGui::Text (" Go to Addr:" );
163
163
ImGui::SameLine ();
164
164
ImGui::SetNextItemWidth (ImGui::CalcTextSize (" 000000" ).x );
165
- ImGui::InputText (" ##input" , adrbuf, 8 );
166
- if (adrbuf[0 ] != ' \0 ' && ImGui::IsItemFocused ()) {
165
+ if (ImGui::InputText (" ##input" , adrbuf, sizeof (adrbuf), ImGuiInputTextFlags_EnterReturnsTrue)) {
167
166
size_t addr;
168
167
if (sscanf (adrbuf, " %zX" , &addr) == 1 )
169
168
JumpTo (addr >> 16 , addr & 0x0ffff );
@@ -172,7 +171,7 @@ void CodeViewer::DrawWindow() {
172
171
ImGui::Checkbox (" STEP" , &step_debug);
173
172
ImGui::SameLine ();
174
173
ImGui::Checkbox (" TRACE" , &trace_debug);
175
- if (triggered_bp_line != - 1 ) {
174
+ if (m_emu-> GetPaused () ) {
176
175
ImGui::SameLine ();
177
176
if (ImGui::Button (" Continue" )) {
178
177
if (!step_debug && !trace_debug)
@@ -189,5 +188,5 @@ void CodeViewer::JumpTo(uint8_t seg, uint16_t offset) {
189
188
int idx = 0 ;
190
189
LookUp (seg, offset, &idx);
191
190
cur_row = idx;
192
- need_roll = true ;
191
+ try_roll = true ;
193
192
}
0 commit comments