diff --git a/README.md b/README.md index 562593e..649bcf7 100644 --- a/README.md +++ b/README.md @@ -58,8 +58,7 @@ ROT-8 ([rəʊˈteɪt]) 提供了一套简洁的指令集,使利用无ALU的各 | 20 | 01 02 04 08 10 20 40 80 01 02 04 08 10 20 40 80 | | 30 | 01 02 04 08 10 20 40 80 01 02 04 08 10 20 40 80 | | 40 | 01 02 04 08 10 20 40 80 01 02 04 08 10 20 40 80 | -| 50 | 01 02 04 08 10 20 40 80 01 02 10 00 00 00 00 00 | -| | ^^ | +| 50 | 01 02 04 08 10 20 40 80 01 02 10*00 00 00 00 00 | | 60 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | | 70 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | | 80 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | @@ -82,7 +81,7 @@ ROT-8 ([rəʊˈteɪt]) 提供了一套简洁的指令集,使利用无ALU的各 | `step / pc / op` | 已经执行的指令数,程序计数器,以及 `pc` 处即将执行的指令 | | `cell ... value` | 指针所指 Cell 的编号、十进制值与十六进制值 | | `b7 ... b0` | 该 Cell 的各位,`#` 为 1,`.` 为 0;宽 Cell 改画一行按 4 位分组的数据 | -| 纸带 | 每行 16 个 Cell(宽 Cell 会变少),行首是十六进制地址,`^^` 标出数据指针;纸带比画面长时只画指针附近的一窗,末行注明窗口范围 | +| 纸带 | 每行 16 个 Cell(宽 Cell 会变少),行首是十六进制地址。**指针那一格反显**(终端没有颜色时,值后面跟一个 `*`,占的是它本来那个分隔空格);纸带比画面长时只画指针附近的一窗,末行注明窗口范围 | | `out` | 到此刻为止 `OUT` 输出的值(保留最近 10 个) | 参数: diff --git a/src/rot8_viz.c b/src/rot8_viz.c index d7d6c48..1f54302 100644 --- a/src/rot8_viz.c +++ b/src/rot8_viz.c @@ -478,46 +478,24 @@ static void viz_grid(rot8_viz *viz, rot8_iter *iter, FILE *out, bool color) { for (col = 0; col < cols; col++) { size_t index = base + (size_t)col; char cell[16]; + bool here; unsigned long value; if (index >= cells) { line_put(&ln, " "); continue; } + here = (ptr >= 0 && (size_t)ptr == index); value = (unsigned long)mem[index]; snprintf(cell, sizeof cell, "%0*lX", digits, value); - if (ptr >= 0 && (size_t)ptr == index) { - line_style(&ln, cell, ANSI_PTR); - } else { - line_style(&ln, cell, value == 0 ? ANSI_ZERO : ANSI_DATA); - } - line_put(&ln, " "); + line_style(&ln, cell, here ? ANSI_PTR + : (value == 0 ? ANSI_ZERO : ANSI_DATA)); + /* The pointer cell says it in place: reverse video with colour, a + * star in the separator column without it. (The old caret row + * under the tape said the same thing a second time, and cost a + * line.) */ + line_put(&ln, here && !color ? "*" : " "); } line_close(&ln); - - /* 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. The mark sits in - * the middle of the digits: two carets for an even digit count, one for - * an odd one, so it stays centred instead of leaning to one side. */ - 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; - const char *mark = digits % 2 == 0 ? "^^" : "^"; - char field[16]; - int pad = digits; - if (here) { - pad = (digits - (int)strlen(mark)) / 2; - } else { - mark = ""; - } - snprintf(field, sizeof field, "%*s%s ", pad, "", mark); - line_style(&ln, field, here ? ANSI_PTR : NULL); - } - line_close(&ln); - } } if (total_rows > shown) {