]> xenbits.xensource.com Git - seabios.git/commitdiff
stdvga: Add stdvga_set_vertical_size() helper function
authorKevin O'Connor <kevin@koconnor.net>
Tue, 2 Apr 2024 17:07:58 +0000 (13:07 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Fri, 5 Apr 2024 21:59:49 +0000 (17:59 -0400)
Add helper function and update the bochsvga.c code to use it.  This
emphasizes the relationship between stdvga_get_vertical_size() and
stdvga_set_vertical_size() code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
vgasrc/bochsvga.c
vgasrc/stdvga.c
vgasrc/stdvga.h

index ab8f25ee2bf319d8b1844cc017f7f1afff3d5cc7..3ef0f181984b9346e116b69ef2c657db436a8f59 100644 (file)
@@ -275,13 +275,7 @@ bochsvga_set_mode(struct vgamode_s *vmode_g, int flags)
     stdvga_crtc_write(crtc_addr, 0x11, 0x00);
     stdvga_crtc_write(crtc_addr, 0x01, width / 8 - 1);
     stdvga_set_linelength(vmode_g, width);
-    stdvga_crtc_write(crtc_addr, 0x12, height - 1);
-    u8 v = 0;
-    if ((height - 1) & 0x0100)
-        v |= 0x02;
-    if ((height - 1) & 0x0200)
-        v |= 0x40;
-    stdvga_crtc_mask(crtc_addr, 0x07, 0x42, v);
+    stdvga_set_vertical_size(height);
 
     stdvga_crtc_write(crtc_addr, 0x09, 0x00);
     stdvga_crtc_mask(crtc_addr, 0x17, 0x00, 0x03);
index 4bfa101a52a48b2ba82ea6d08d33feacd81160f4..afe26dbdad30d1778bbe796e9b487565144fc933 100644 (file)
@@ -286,6 +286,17 @@ stdvga_get_vertical_size(void)
     return vde + 1;
 }
 
+// Set vertical screen size (number of horizontal lines in the display)
+void
+stdvga_set_vertical_size(int lines)
+{
+    u16 crtc_addr = stdvga_get_crtc();
+    u16 vde = lines - 1;
+    stdvga_crtc_write(crtc_addr, 0x12, vde);
+    u8 ovl = ((vde >> 7) & 0x02) + ((vde >> 3) & 0x40);
+    stdvga_crtc_mask(crtc_addr, 0x07, 0x42, ovl);
+}
+
 // Get offset into framebuffer accessible from real-mode 64K segment
 int
 stdvga_get_window(struct vgamode_s *curmode_g, int window)
index 1828585295708605fcbe215d524c37bfcaa3901b..ce5a80ab0d2fa21f8ad21b17c8bab50d6df626b4 100644 (file)
@@ -67,6 +67,7 @@ void stdvga_set_cursor_shape(u16 cursor_type);
 void stdvga_set_cursor_pos(int address);
 void stdvga_set_character_height(u8 lines);
 u16 stdvga_get_vertical_size(void);
+void stdvga_set_vertical_size(int lines);
 int stdvga_get_window(struct vgamode_s *curmode_g, int window);
 int stdvga_set_window(struct vgamode_s *curmode_g, int window, int val);
 int stdvga_minimum_linelength(struct vgamode_s *vmode_g);