:: commit 57c44befee0c98b33c7a74caf5c05c083ce713ef

mintsuki <mintsuki@protonmail.com> — 2021-08-25 23:23

parents: 9d8fd54127

Revert "term: Reverse video should not make the cursor invisible"

This reverts commit a5def082c335b5dbb506b016478d87fbab955816.
diff --git a/stage23/drivers/vga_textmode.s2.c b/stage23/drivers/vga_textmode.s2.c
index 26c1fc57..075a5dda 100644
--- a/stage23/drivers/vga_textmode.s2.c
+++ b/stage23/drivers/vga_textmode.s2.c
@@ -29,6 +29,8 @@ 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;
@@ -41,8 +43,7 @@ static void clear_cursor(void) {
 
 static void draw_cursor(void) {
     if (cursor_status) {
-        uint16_t c = current_buffer[cursor_offset + 1];
-        video_mem[cursor_offset + 1] = (c << 4) | (c >> 4);
+        video_mem[cursor_offset + 1] = cursor_palette;
     }
 }
 
@@ -164,6 +165,7 @@ 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 03344ddf..5c3804f1 100644
--- a/stage23/lib/gterm.c
+++ b/stage23/lib/gterm.c
@@ -86,16 +86,11 @@ void gterm_swap_palette(void) {
     }
 }
 
-#define A(rgb) ((uint8_t)((rgb) >> 24))
-#define R(rgb) ((uint8_t)((rgb) >> 16))
-#define G(rgb) ((uint8_t)((rgb) >> 8))
-#define B(rgb) ((uint8_t)((rgb) >> 0))
-#define ARGB(a, r, g, b) ( \
-    ((uint32_t)((a) & 0xFF) << 24) \
-  | ((uint32_t)((r) & 0xFF) << 16) \
-  | ((uint32_t)((g) & 0xFF) << 8) \
-  | ((uint32_t)((b) & 0xFF) << 0) \
-)
+#define A(rgb) (uint8_t)(rgb >> 24)
+#define R(rgb) (uint8_t)(rgb >> 16)
+#define G(rgb) (uint8_t)(rgb >> 8)
+#define B(rgb) (uint8_t)(rgb)
+#define ARGB(a, r, g, b) (a << 24) | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF)
 
 static inline uint32_t colour_blend(uint32_t fg, uint32_t bg) {
     unsigned alpha = 255 - A(fg);
@@ -342,16 +337,8 @@ static void clear_cursor(void) {
 static void draw_cursor(void) {
     if (cursor_status) {
         struct gterm_char c = grid[cursor_x + cursor_y * cols];
-        uint32_t tmp = c.fg;
-        if (c.bg == 0xffffffff) {
-            c.fg = ARGB(A(tmp),
-                        R(tmp) < 128 ? 255 : 0,
-                        G(tmp) < 128 ? 255 : 0,
-                        B(tmp) < 128 ? 255 : 0);
-        } else {
-            c.fg = c.bg;
-        }
-        c.bg = tmp;
+        c.fg = 0;
+        c.bg = 0xcccccc;
         plot_char_grid_force(&c, cursor_x, cursor_y);
     }
 }
tab: 248 wrap: offon