summaryrefslogtreecommitdiffstats
path: root/tis100-curses.c
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2023-12-27 14:12:17 +0100
committerLouis Burda <quent.burda@gmail.com>2023-12-27 14:12:17 +0100
commit11d75bf41c7d22b6a6a76fa2dd4843d23a75fffb (patch)
tree4821a231ac0dcee71296db75022aa6fc220a8159 /tis100-curses.c
parentc06c696a20fa8987bbb13da608153ccfc3cd55e7 (diff)
downloadtis100-11d75bf41c7d22b6a6a76fa2dd4843d23a75fffb.tar.gz
tis100-11d75bf41c7d22b6a6a76fa2dd4843d23a75fffb.zip
Fix instruction squishing to fit tpu row
Diffstat (limited to 'tis100-curses.c')
-rw-r--r--tis100-curses.c12
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;