:: commit 35273093bac6c978359a0c2e9220bacb30e9af0a

mintsuki <mintsuki@protonmail.com> — 2021-09-14 18:02

parents: ab19d6ccad

term: Cursor should flip palette

diff --git a/stage23/drivers/vga_textmode.s2.c b/stage23/drivers/vga_textmode.s2.c
index d48c6ea9..c5a21410 100644
--- a/stage23/drivers/vga_textmode.s2.c
+++ b/stage23/drivers/vga_textmode.s2.c
@@ -29,8 +29,6 @@ static struct context {
 #define cursor_status context.cursor_status
     uint8_t text_palette;
 #define text_palette context.text_palette
-    uint8_t cursor_palette;
-#define cursor_palette context.cursor_palette
     bool scroll_enabled;
 #define scroll_enabled context.scroll_enabled
 } context;
@@ -43,7 +41,8 @@ static void clear_cursor(void) {
 
 static void draw_cursor(void) {
     if (cursor_status) {
-        video_mem[cursor_offset + 1] = cursor_palette;
+        uint8_t pal = current_buffer[cursor_offset + 1];
+        video_mem[cursor_offset + 1] = ((pal & 0xf0) >> 4) | ((pal & 0x0f) << 4);
     }
 }
 
@@ -165,7 +164,6 @@ void init_vga_textmode(size_t *_rows, size_t *_cols, bool managed) {
     cursor_offset = 0;
     cursor_status = true;
     text_palette = 0x07;
-    cursor_palette = 0x70;
     scroll_enabled = true;
 
     text_clear(false);
diff --git a/stage23/lib/gterm.c b/stage23/lib/gterm.c
index ca2310b0..fd8c970c 100644
--- a/stage23/lib/gterm.c
+++ b/stage23/lib/gterm.c
@@ -337,8 +337,13 @@ static void clear_cursor(void) {
 static void draw_cursor(void) {
     if (cursor_status) {
         struct gterm_char c = grid[cursor_x + cursor_y * cols];
-        c.fg = 0;
-        c.bg = 0xcccccc;
+        uint32_t tmp = c.bg;
+        c.bg = c.fg;
+        if (tmp == 0xffffffff) {
+            c.fg = 0;
+        } else {
+            c.fg = c.bg;
+        }
         plot_char_grid_force(&c, cursor_x, cursor_y);
     }
 }
tab: 248 wrap: offon