Rename the functions to make them a little easier to understand.
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- vgasrc/stdvga.c | 31 ++++++++++++++++++------------- vgasrc/stdvga.h | 5 +++-- vgasrc/vgabios.c | 7 +++++-- 3 files changed, 26 insertions(+), 17 deletions(-)
diff --git a/vgasrc/stdvga.c b/vgasrc/stdvga.c index 63700d4..2edd6d7 100644 --- a/vgasrc/stdvga.c +++ b/vgasrc/stdvga.c @@ -91,31 +91,36 @@ stdvga_set_palette_blinking(u8 enable_blink) stdvga_attr_mask(0x10, 0x08, (enable_blink & 0x01) << 3); }
+// Select 4-bit or 6-bit palette indexes (for "page" switching of colors) void -stdvga_select_video_dac_color_page(u8 flag, u8 data) +stdvga_set_palette_pagesize(u8 pal_pagesize) { - if (!(flag & 0x01)) { - // select paging mode - stdvga_attr_mask(0x10, 0x80, data << 7); - return; - } - // select page + stdvga_attr_mask(0x10, 0x80, pal_pagesize << 7); +} + +// Set palette index offset (enables color switching via "pages") +void +stdvga_set_palette_page(u8 pal_page) +{ + // Check if using 4-bit or 6-bit "palette index pages" u8 val = stdvga_attr_read(0x10); if (!(val & 0x80)) - data <<= 2; - data &= 0x0f; - stdvga_attr_write(0x14, data); + pal_page <<= 2; + // select page + pal_page &= 0x0f; + stdvga_attr_write(0x14, pal_page); }
+// Report current pallete index pagesize and current page void -stdvga_read_video_dac_state(u8 *pmode, u8 *curpage) +stdvga_get_palette_page(u8 *pal_pagesize, u8 *pal_page) { u8 val1 = stdvga_attr_read(0x10) >> 7; u8 val2 = stdvga_attr_read(0x14) & 0x0f; if (!(val1 & 0x01)) val2 >>= 2; - *pmode = val1; - *curpage = val2; + *pal_pagesize = val1; + *pal_page = val2; }
diff --git a/vgasrc/stdvga.h b/vgasrc/stdvga.h index 6ce6a90..e9cd2f0 100644 --- a/vgasrc/stdvga.h +++ b/vgasrc/stdvga.h @@ -52,8 +52,9 @@ u8 stdvga_get_overscan_border_color(void); void stdvga_set_all_palette_reg(u16 seg, u8 *data_far); void stdvga_get_all_palette_reg(u16 seg, u8 *data_far); void stdvga_set_palette_blinking(u8 enable_blink); -void stdvga_select_video_dac_color_page(u8 flag, u8 data); -void stdvga_read_video_dac_state(u8 *pmode, u8 *curpage); +void stdvga_set_palette_pagesize(u8 pal_pagesize); +void stdvga_set_palette_page(u8 pal_page); +void stdvga_get_palette_page(u8 *pal_pagesize, u8 *pal_page); void stdvga_perform_gray_scale_summing(u16 start, u16 count); void stdvga_set_text_block_specifier(u8 spec); void stdvga_planar4_plane(int plane); diff --git a/vgasrc/vgabios.c b/vgasrc/vgabios.c index b55a4db..00325f5 100644 --- a/vgasrc/vgabios.c +++ b/vgasrc/vgabios.c @@ -583,7 +583,10 @@ handle_101012(struct bregs *regs) static void handle_101013(struct bregs *regs) { - stdvga_select_video_dac_color_page(regs->bl, regs->bh); + if (!(regs->bl & 0x01)) + stdvga_set_palette_pagesize(regs->bh); + else + stdvga_set_palette_page(regs->bh); }
static void noinline @@ -617,7 +620,7 @@ handle_101019(struct bregs *regs) static void handle_10101a(struct bregs *regs) { - stdvga_read_video_dac_state(®s->bl, ®s->bh); + stdvga_get_palette_page(®s->bl, ®s->bh); }
static void