Add stack window
diff --git a/cpu.c b/cpu.c
index d457868..f58d181 100644
--- a/cpu.c
+++ b/cpu.c
@@ -25,6 +25,7 @@
cpu->regs[SP] = 0xFD; // stack at is 0x100 + SP
cpu->pc = 0x600; // arbitrary program counter start
cpu->running = true;
+ memset(cpu->mem + 0x100, 0, 0xFE);
}
cpu_t new_cpu()
diff --git a/gui.c b/gui.c
index 201fdae..f9cd310 100644
--- a/gui.c
+++ b/gui.c
@@ -39,13 +39,9 @@
.b = 0.50f,
.a = 1.0f,
};
- struct nk_color selected =
- {
- .r = 28,
- .g = 234,
- .b = 79,
- .a = 255,
- };
+ struct nk_color
+ selected = nk_rgb(28, 234, 79),
+ red = nk_rgb(226, 56, 76);
uint16_t disas_start = 0x600,
disas_end = 0x600 + 32;
@@ -162,6 +158,30 @@
}
nk_end(ctx);
+ if (nk_begin(ctx, "Stack", nk_rect(250, 250, 230, 350),
+ NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_SCALABLE|
+ NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE))
+ {
+ nk_layout_row_static(ctx, 24, 48, 2);
+ for (int i = 0xFD; i >= 0; i--)
+ {
+ char line[6];
+ sprintf(line, "$%x", 0x100 + i);
+ nk_label(ctx, line, NK_TEXT_LEFT);
+
+ sprintf(line, "$%x", cpu->mem[0x100 + i]);
+ if (i == cpu->regs[SP])
+ {
+ nk_label_colored(ctx, line, NK_TEXT_LEFT, selected);
+ }
+ else
+ {
+ nk_label(ctx, line, NK_TEXT_LEFT);
+ }
+ }
+ }
+ nk_end(ctx);
+
if (nk_begin(ctx, "Debugger", nk_rect(50, 50, 230, 150),
NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_SCALABLE|
NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE))