diff --git a/pipelined-cpu/srcs/board/cpu21_saolei_rom.vh b/pipelined-cpu/srcs/board/cpu21_saolei_rom.vh index edc6684..a802a7e 100644 --- a/pipelined-cpu/srcs/board/cpu21_saolei_rom.vh +++ b/pipelined-cpu/srcs/board/cpu21_saolei_rom.vh @@ -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; diff --git a/pipelined-cpu/srcs/rtl/cpu21_vga.v b/pipelined-cpu/srcs/rtl/cpu21_vga.v index 7bb4a38..5a86bd7 100644 --- a/pipelined-cpu/srcs/rtl/cpu21_vga.v +++ b/pipelined-cpu/srcs/rtl/cpu21_vga.v @@ -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; diff --git a/saolei/sw/saolei.c b/saolei/sw/saolei.c index c9bd06e..a783705 100644 --- a/saolei/sw/saolei.c +++ b/saolei/sw/saolei.c @@ -199,7 +199,8 @@ static void draw_all_covered(void) static void update_cursor_reg(void) { - REG_W(REG_CURSOR) = (cur_c & 31u) | ((cur_r & 31u) << 8); + /* 列用 6 位(0..39):hard 棋盘宽 30,光标列能到 35,掩 31 会把它变成 3 */ + REG_W(REG_CURSOR) = (cur_c & 63u) | ((cur_r & 31u) << 8); } static void set_bg(unsigned color)