fix(saolei): 修 hard 模式光标到某一格就跳回最左边(列只有 5 位)

现象:只看 hard 模式时,光标移到某一排的某个格子后再往右,会跳回最左边。

原因:光标的列字段只有 5 位。
- 软件 update_cursor_reg():REG_CURSOR = (cur_c & 31u) | ...
- RTL cpu21_vga.v:cursor_here = (cursor_i[4:0] == ccol) && ...
hard 棋盘宽 30、左上角列 5,光标列能到 35,35 被掩成 3,于是画在第 3 列。
初级/中级列最大 25 以内,所以只有 hard 暴露出来;背景界面光标能走到列 39,
同样受影响。

改法:
- saolei.c:列掩码 31u -> 63u(6 位,覆盖 0..39)
- cpu21_vga.v:cursor_i[4:0] -> cursor_i[5:0]
This commit is contained in:
2026-09-23 21:13:35 +08:00
parent 7e13571744
commit 10d4836ad7
3 changed files with 6 additions and 3 deletions
+1 -1
View File
@@ -310,7 +310,7 @@
rom[307] = 32'h79402703;
rom[308] = 32'h01F7F793;
rom[309] = 32'h00879793;
rom[310] = 32'h01F77713;
rom[310] = 32'h03F77713;
rom[311] = 32'h00E7E7B3;
rom[312] = 32'h00001737;
rom[313] = 32'h14F72223;
+3 -1
View File
@@ -280,7 +280,9 @@ module cpu21_vga #(
// VGA 上和图里都能一眼看到指针。想改回闪动:把 blink_q 加回来,
// 再在 cursor_box 里与上 blink 即可。
// ---------------------------------------------------------------------------
wire cursor_here = (cursor_i[4:0] == ccol) && (cursor_i[12:8] == crow);
// 列必须比 6 位(0..39):hard 难度的棋盘宽 30,光标能到列 35,
// 以前这里只取 [4:0],35 被当成 3,光标会“跳回最左边”。
wire cursor_here = (cursor_i[5:0] == ccol) && (cursor_i[12:8] == crow);
wire on_border = (hx[3:0] < 4'd2) || (hx[3:0] > 4'd13) || (vy[3:0] < 4'd2) || (vy[3:0] > 4'd13);
wire cursor_box = cursor_here && ctrl_i[0] && on_border;