Skip to content

Commit 896f2f2

Browse files
committed
ui
1 parent 391e918 commit 896f2f2

File tree

4 files changed

+34
-38
lines changed

4 files changed

+34
-38
lines changed

emulator/src/Chipset/CPU.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace casioemu {
1313
CPU::OpcodeSource CPU::opcode_sources[] = {
14-
// function, hints, main mask, operand {size, mask, shift} x2
14+
// function, hints, main mask, operand {size, mask, shift} x2
1515
// * Arithmetic Instructions
1616
{&CPU::OP_ADD, H_WB, 0x8001, {{1, 0x000F, 8}, {1, 0x000F, 4}}},
1717
{&CPU::OP_ADD, H_WB, 0x1000, {{1, 0x000F, 8}, {0, 0x00FF, 0}}},
@@ -441,7 +441,7 @@ namespace casioemu {
441441
output << std::hex << std::setfill('0') << std::uppercase;
442442
for (StackFrame frame : stack) {
443443
output << " function "
444-
<< std::setw(6) << (((size_t)frame.new_csr) << 16 | frame.new_pc)
444+
<< frame.new_csr << ":" << frame.new_pc
445445
<< " returns to " << std::setw(6);
446446
if (frame.lr_pushed) {
447447
uint16_t saved_lr, saved_lcsr = 0;
@@ -451,12 +451,12 @@ namespace casioemu {
451451
mmu.ReadData(frame.lr_push_address);
452452
if (memory_model == MM_LARGE)
453453
saved_lcsr = mmu.ReadData(frame.lr_push_address + 2);
454-
output << (((size_t)saved_lcsr) << 16 | saved_lr);
454+
output << saved_lcsr << ":" << saved_lr;
455455

456456
output << " - lr pushed at "
457457
<< std::setw(4) << frame.lr_push_address;
458458
} else {
459-
output << (((size_t)reg_lcsr) << 16 | reg_lr);
459+
output << reg_lcsr << ":" << reg_lr;
460460
}
461461
output << '\n';
462462
}

emulator/src/Chipset/CPUPushPop.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,26 +52,25 @@ namespace casioemu {
5252
}
5353

5454
void CPU::OP_POPL() {
55-
if (impl_operands[0].value & 1)
55+
if (impl_operands[0].value & 1) // POP ...,EA,...
5656
reg_ea = Pop16();
57-
if (impl_operands[0].value & 8) {
57+
if (impl_operands[0].value & 8) { // POP ...,LR,...
5858
/**
5959
* Sometimes a function calls another function in one branch, and
6060
* does not call another function in another branch. In that case
6161
* the compiler may decide to do a `push lr` / `pop lr` in only the
6262
* branch that has to save `lr`.
6363
*/
64-
if (!stack.empty() && stack.back().lr_pushed &&
65-
stack.back().lr_push_address == reg_sp)
64+
if (!stack.empty() && stack.back().lr_pushed && stack.back().lr_push_address == reg_sp)
6665
stack.back().lr_pushed = false;
6766

6867
reg_lr = Pop16();
6968
if (memory_model == MM_LARGE)
7069
reg_lcsr = Pop16() & 0x000F;
7170
}
72-
if (impl_operands[0].value & 4)
71+
if (impl_operands[0].value & 4) // POP ...,PSW,...
7372
reg_psw = Pop16();
74-
if (impl_operands[0].value & 2) {
73+
if (impl_operands[0].value & 2) { // POP ...,PC,...
7574
int oldsp = reg_sp;
7675
reg_pc = Pop16();
7776
if (memory_model == MM_LARGE)
@@ -83,8 +82,7 @@ namespace casioemu {
8382
}
8483
}
8584
}
86-
if (!stack.empty() && stack.back().lr_pushed &&
87-
stack.back().lr_push_address == oldsp)
85+
if (!stack.empty() && stack.back().lr_pushed && stack.back().lr_push_address == oldsp)
8886
stack.pop_back();
8987
}
9088
}

emulator/src/Gui/CodeViewer.cpp

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ CodeElem CodeViewer::LookUp(uint8_t seg, uint16_t offset, int *idx) {
7878
return CodeElem(it->segment, it->offset);
7979
}
8080

81+
/**
82+
* called after an instruction is done (in CPU.cpp) or
83+
* a POP PC is executed (in CPUPushPop.cpp)
84+
*/
8185
bool CodeViewer::TryTrigBP(uint8_t seg, uint16_t offset, bool bp_mode) {
8286
for (auto it = break_points.begin(); it != break_points.end(); it++) {
8387
if (it->second == 1) {
@@ -131,31 +135,27 @@ void CodeViewer::DrawContent() {
131135
if (selected_addr != (int64_t)e.segment * 0x10000 + e.offset) { // not selected
132136
ImGui::Text("%s", e.srcbuf);
133137
if (ImGui::IsItemHovered() && ImGui::IsMouseClicked(0)) {
134-
selected_addr = e.segment * 0x10000 + e.offset;
135138
cur_row = line_i;
136-
edit_active = true;
139+
need_roll = true;
137140
}
138141
} else { // selected
139-
if (edit_active) {
140-
ImGui::InputText("##data", e.srcbuf, strlen(e.srcbuf), ImGuiInputTextFlags_ReadOnly | ImGuiInputTextFlags_AlwaysOverwrite);
141-
// ImGui::SetKeyboardFocusHere();
142-
// if (!ImGui::IsItemActive()) {
143-
// edit_active = false;
144-
// }
145-
if (ImGui::IsWindowFocused()) {
146-
if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_DownArrow))) {
147-
cur_row++;
148-
if (cur_row >= max_row)
149-
cur_row = max_row;
150-
need_roll = true;
151-
} else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_UpArrow))) {
152-
cur_row--;
153-
if (cur_row < 0)
154-
cur_row = 0;
155-
need_roll = true;
156-
}
142+
ImGui::InputText("##data", e.srcbuf, strlen(e.srcbuf), ImGuiInputTextFlags_ReadOnly | ImGuiInputTextFlags_AlwaysOverwrite);
143+
if (ImGui::IsWindowFocused()) {
144+
if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_DownArrow))) {
145+
cur_row++;
146+
if (cur_row >= max_row)
147+
cur_row = max_row;
148+
need_roll = true;
149+
} else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_UpArrow))) {
150+
cur_row--;
151+
if (cur_row < 0)
152+
cur_row = 0;
153+
need_roll = true;
157154
}
158-
} else {}
155+
if (!ImGui::IsItemActive()) {
156+
selected_addr = -1;
157+
}
158+
}
159159
}
160160
}
161161
}
@@ -218,7 +218,7 @@ void CodeViewer::DrawWindow() {
218218
ImGui::SameLine();
219219
ImGui::Checkbox("STEP", &step_debug);
220220
ImGui::SameLine();
221-
ImGui::Checkbox("TRACE", &trace_debug);
221+
ImGui::Checkbox("RET TRACE", &trace_debug);
222222
if (bp != -1) {
223223
ImGui::SameLine();
224224
if (ImGui::Button("Continue?")) {
@@ -228,16 +228,15 @@ void CodeViewer::DrawWindow() {
228228
}
229229
}
230230

231-
// ImGui::BeginChild("##scrolling");
231+
ImGui::BeginChild("##scrolling");
232232
DrawMonitor();
233-
// ImGui::EndChild();
233+
ImGui::EndChild();
234234
ImGui::End();
235235
debug_flags = DEBUG_BREAKPOINT | (step_debug ? DEBUG_STEP : 0) | (trace_debug ? DEBUG_RET_TRACE : 0);
236236
}
237237

238238
void CodeViewer::JumpTo(uint8_t seg, uint16_t offset) {
239239
int idx = 0;
240-
// printf("jumpto:seg%d\n",seg);
241240
LookUp(seg, offset, &idx);
242241
cur_row = idx;
243242
need_roll = true;

emulator/src/Gui/CodeViewer.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class CodeViewer {
3232
int cur_row = 0;
3333

3434
bool is_loaded = false;
35-
bool edit_active = false;
3635
bool need_roll = false;
3736
int64_t selected_addr = -1;
3837
int64_t bp = -1;

0 commit comments

Comments
 (0)