Browse Source

emul: add live register stats in the corner

pull/103/head
Virgil Dupras 4 years ago
parent
commit
7f3e55cb51
3 changed files with 24 additions and 3 deletions
  1. +6
    -0
      emul/emul.c
  2. +1
    -0
      emul/emul.h
  3. +17
    -3
      emul/forth.c

+ 6
- 0
emul/emul.c View File

@@ -173,6 +173,12 @@ void emul_memdump()
fclose(fp);
}

void emul_debugstr(char *s)
{
sprintf(s, "SP %04x (%04x) IX %04x (%04x)",
m.cpu.R1.wr.SP, m.minsp, m.cpu.R1.wr.IX, m.maxix);
}

void emul_printdebug()
{
fprintf(stderr, "Min SP: %04x\n", m.minsp);


+ 1
- 0
emul/emul.h View File

@@ -35,4 +35,5 @@ bool emul_steps(unsigned int steps);
void emul_loop();
void emul_trace(ushort addr);
void emul_memdump();
void emul_debugstr(char *s);
void emul_printdebug();

+ 17
- 3
emul/forth.c View File

@@ -20,7 +20,15 @@

static FILE *fp;
static int retcode = 0;
WINDOW *bw, *w;
WINDOW *bw, *dw, *w;

void debug_panel()
{
char buf[30];
emul_debugstr(buf);
mvwaddnstr(dw, 0, 0, buf, 30);
wrefresh(dw);
}

static uint8_t iord_stdio()
{
@@ -28,6 +36,7 @@ static uint8_t iord_stdio()
if (fp != NULL) {
c = getc(fp);
} else {
debug_panel();
c = wgetch(w);
}
if (c == EOF) {
@@ -74,13 +83,18 @@ int main(int argc, char *argv[])
} else if (argc == 1) {
fp = NULL;
initscr(); cbreak(); noecho(); nl(); clear();
// border window
bw = newwin(WLINES+2, WCOLS+2, 0, 0);
wborder(bw, 0, 0, 0, 0, 0, 0, 0, 0);
wrefresh(bw);
// debug panel
dw = newwin(1, 30, LINES-1, COLS-30);
w = newwin(WLINES, WCOLS, 1, 1);
scrollok(w, 1);
while (emul_step());
nocbreak(); echo(); delwin(w); delwin(bw); endwin();
while (emul_steps(1000)) {
debug_panel();
}
nocbreak(); echo(); delwin(w); delwin(bw); delwin(dw); endwin();
printf("\nDone!\n");
emul_printdebug();
} else {


Loading…
Cancel
Save