[SeaBIOS] [PATCH 3/3] vgabios: Simplify set_cursor_pos()

Kevin O'Connor kevin at koconnor.net
Mon Jul 4 18:41:16 CEST 2016


Rework set_cursor_pos() to be slightly simpler.

Signed-off-by: Kevin O'Connor <kevin at koconnor.net>
---
 vgasrc/vgabios.c | 28 ++++++++++------------------
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/vgasrc/vgabios.c b/vgasrc/vgabios.c
index 2593e03..cfb6ba2 100644
--- a/vgasrc/vgabios.c
+++ b/vgasrc/vgabios.c
@@ -83,27 +83,19 @@ set_cursor_shape(u16 cursor_type)
 static void
 set_cursor_pos(struct cursorpos cp)
 {
-    u8 page = cp.page, x = cp.x, y = cp.y;
-
-    // Should not happen...
-    if (page > 7)
+    if (cp.page > 7)
+        // Should not happen...
         return;
 
-    vgafb_set_swcursor(0);
-
-    // Bios cursor pos
-    SET_BDA(cursor_pos[page], (y << 8) | x);
-
-    if (!CONFIG_VGA_STDVGA_PORTS)
-        return;
-
-    // Set the hardware cursor
-    u8 current = GET_BDA(video_page);
-    if (cp.page != current)
-        return;
+    if (cp.page == GET_BDA(video_page)) {
+        // Update cursor in hardware
+        vgafb_set_swcursor(0);
+        if (CONFIG_VGA_STDVGA_PORTS)
+            stdvga_set_cursor_pos((int)text_address(cp));
+    }
 
-    // Calculate the memory address
-    stdvga_set_cursor_pos((int)text_address(cp));
+    // Update BIOS cursor pos
+    SET_BDA(cursor_pos[cp.page], (cp.y << 8) | cp.x);
 }
 
 struct cursorpos
-- 
2.5.5




More information about the SeaBIOS mailing list