aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2024-04-02 13:07:58 -0400
committerKevin O'Connor <kevin@koconnor.net>2024-04-05 17:59:49 -0400
commitc5a361c09a19e3b1a83557b01f11f04b27181a11 (patch)
treea63b9a6f2f755ae233e9092615e43b122937fdf2
parent22c91412600b7fabd75ef68d2d4d3e63e9e27f9f (diff)
downloadseabios-c5a361c09a19e3b1a83557b01f11f04b27181a11.zip
seabios-c5a361c09a19e3b1a83557b01f11f04b27181a11.tar.gz
seabios-c5a361c09a19e3b1a83557b01f11f04b27181a11.tar.bz2
stdvga: Add stdvga_set_vertical_size() helper function
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>
-rw-r--r--vgasrc/bochsvga.c8
-rw-r--r--vgasrc/stdvga.c11
-rw-r--r--vgasrc/stdvga.h1
3 files changed, 13 insertions, 7 deletions
diff --git a/vgasrc/bochsvga.c b/vgasrc/bochsvga.c
index ab8f25e..3ef0f18 100644
--- a/vgasrc/bochsvga.c
+++ b/vgasrc/bochsvga.c
@@ -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);
diff --git a/vgasrc/stdvga.c b/vgasrc/stdvga.c
index 4bfa101..afe26db 100644
--- a/vgasrc/stdvga.c
+++ b/vgasrc/stdvga.c
@@ -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)
diff --git a/vgasrc/stdvga.h b/vgasrc/stdvga.h
index 1828585..ce5a80a 100644
--- a/vgasrc/stdvga.h
+++ b/vgasrc/stdvga.h
@@ -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);