diff options
Diffstat (limited to 'tis100-curses.c')
| -rw-r--r-- | tis100-curses.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tis100-curses.c b/tis100-curses.c index 8556480..cc36066 100644 --- a/tis100-curses.c +++ b/tis100-curses.c @@ -197,7 +197,8 @@ tui_draw_tpu(struct tpu *tpu) start = MAX(0, MIN(tpu->pc - 4, (int) tpu->inst_cnt - TPU_MAX_ROWS)); inst = start; for (offy = 0; offy < TPU_MAX_ROWS && inst < tpu->inst_cnt; ) { - asm_print_inst(rowbuf, sizeof(rowbuf), &tpu->insts[inst]); + asm_print_inst(rowbuf, sizeof(rowbuf), &tpu->insts[inst], + TPU_MAX_COLS - (size_t) offx); label = &tpu->label_map.labels[inst]; if (label->str) { len = strlen(label->str); @@ -211,9 +212,14 @@ tui_draw_tpu(struct tpu *tpu) offy += 1; } } + if ((size_t) offx + strlen(rowbuf) > TPU_MAX_COLS) + asm_print_inst(rowbuf, sizeof(rowbuf), &tpu->insts[inst], + TPU_MAX_COLS - (size_t) offx); tui_draw_text(sx + 1 + offx, sy + 1 + offy, - inst == tpu->pc ? A_STANDOUT | (tpu->idle ? A_DIM : 0) : 0, - "%-*.*s", TPU_MAX_COLS - offx, TPU_MAX_COLS, rowbuf); + inst == tpu->pc ? + A_STANDOUT | (tpu->idle ? A_DIM : 0) : 0, + "%-*.*s", TPU_MAX_COLS - offx, + TPU_MAX_COLS, rowbuf); inst += 1; offy += 1; offx = 0; |
