Put the caret under the cell it points at

This commit is contained in:
dsh committed 2026-11-07 11:12:43 +08:00
1 parent dde545d0d5
commit 83f18d46bb
2 files changed
+19 -3

No files matched your search

+4
View File
@@ -152,6 +152,10 @@ ROT-8 ([rəʊˈteɪt]) 提供了一套简洁的指令集,使利用无ALU的各
把默认几何显式写出来(`--mem 256 --cell 8`)时,行为与改默认值之前逐字节一致:`--dump` 的
画面、`OUT` 的输出都没有变 —— 所以拿旧基准对比时记得把这两个参数带上.
> 注意:按 8 bit 写死的 tape 拿到 11 bit 下**不只是算错,还可能永远跑不完** ——
> 那些 `%rep 8` 的循环只转了 8 圈,cell 没转回原位,"转到某位清零"的条件于是永远不成立.
> 实测旧 `test.r8asm` 的纸带在 11 bit 下 `--dump` 会一直跑下去. 换位宽请重新汇编纸带.
## 输入
`INP` 现在按这个顺序取值:先吃 `--input` 排好的队列,再问现场(live 模式),最后才回落到
+15 -3
View File
@@ -492,15 +492,27 @@ static void viz_grid(rot8_viz *viz, rot8_iter *iter, FILE *out, bool color) {
}
line_close(&ln);
/* A caret under the tape pointer, for terminals without colour. */
/* A caret under the tape pointer, for terminals without colour. One
* field is digits + 1 characters wide, exactly like a hex cell, or the
* caret walks left of its cell as the columns add up. */
if (ptr >= 0 && (size_t)ptr / (size_t)cols == first_row + row) {
line_open(&ln, viz, out, color);
snprintf(label, sizeof label, "%*s| ", addr + 3, "");
line_put(&ln, label);
for (col = 0; col < cols; col++) {
bool here = (size_t)ptr == base + (size_t)col;
line_style(&ln, here ? "^^ " : " ",
here ? ANSI_PTR : NULL);
const char *mark = "";
char field[16];
int pad;
if (here) {
mark = digits > 1 ? "^^" : "^";
}
pad = digits - (int)strlen(mark);
if (pad < 0) {
pad = 0;
}
snprintf(field, sizeof field, "%*s%s ", pad, "", mark);
line_style(&ln, field, here ? ANSI_PTR : NULL);
}
line_close(&ln);
}