Many functions are passed a pointer to the current video mode vgamode_s struct. Use the name 'curmode_g' for these functions and use 'vmode_g' for functions that can accept an arbitrary video mode. Hopefully this will make the goals of the functions more clear.
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- vgasrc/bochsvga.c | 40 ++++++++++---------- vgasrc/bochsvga.h | 16 ++++---- vgasrc/cbvga.c | 16 ++++---- vgasrc/clext.c | 20 +++++----- vgasrc/stdvga.c | 24 ++++++------ vgasrc/stdvga.h | 16 ++++---- vgasrc/stdvgamodes.c | 12 +++--- vgasrc/swcursor.c | 16 ++++---- vgasrc/vbe.c | 51 ++++++++++++------------- vgasrc/vgabios.c | 6 +-- vgasrc/vgafb.c | 88 ++++++++++++++++++++++---------------------- vgasrc/vgafb.h | 4 +- vgasrc/vgahw.h | 76 +++++++++++++++++++------------------- vgasrc/vgautil.h | 28 +++++++------- 14 files changed, 206 insertions(+), 207 deletions(-)
diff --git a/vgasrc/bochsvga.c b/vgasrc/bochsvga.c index fd5e586..ab8f25e 100644 --- a/vgasrc/bochsvga.c +++ b/vgasrc/bochsvga.c @@ -93,20 +93,20 @@ bochsvga_dispi_enabled(void) }
int -bochsvga_get_window(struct vgamode_s *vmode_g, int window) +bochsvga_get_window(struct vgamode_s *curmode_g, int window) { if (!bochsvga_dispi_enabled()) - return stdvga_get_window(vmode_g, window); + return stdvga_get_window(curmode_g, window); if (window != 0) return -1; return dispi_read(VBE_DISPI_INDEX_BANK); }
int -bochsvga_set_window(struct vgamode_s *vmode_g, int window, int val) +bochsvga_set_window(struct vgamode_s *curmode_g, int window, int val) { if (!bochsvga_dispi_enabled()) - return stdvga_set_window(vmode_g, window, val); + return stdvga_set_window(curmode_g, window, val); if (window != 0) return -1; dispi_write(VBE_DISPI_INDEX_BANK, val); @@ -116,30 +116,30 @@ bochsvga_set_window(struct vgamode_s *vmode_g, int window, int val) }
int -bochsvga_get_linelength(struct vgamode_s *vmode_g) +bochsvga_get_linelength(struct vgamode_s *curmode_g) { if (!bochsvga_dispi_enabled()) - return stdvga_get_linelength(vmode_g); - return dispi_read(VBE_DISPI_INDEX_VIRT_WIDTH) * vga_bpp(vmode_g) / 8; + return stdvga_get_linelength(curmode_g); + return dispi_read(VBE_DISPI_INDEX_VIRT_WIDTH) * vga_bpp(curmode_g) / 8; }
int -bochsvga_set_linelength(struct vgamode_s *vmode_g, int val) +bochsvga_set_linelength(struct vgamode_s *curmode_g, int val) { - stdvga_set_linelength(vmode_g, val); + stdvga_set_linelength(curmode_g, val); if (bochsvga_dispi_enabled()) { - int pixels = (val * 8) / vga_bpp(vmode_g); + int pixels = (val * 8) / vga_bpp(curmode_g); dispi_write(VBE_DISPI_INDEX_VIRT_WIDTH, pixels); } return 0; }
int -bochsvga_get_displaystart(struct vgamode_s *vmode_g) +bochsvga_get_displaystart(struct vgamode_s *curmode_g) { if (!bochsvga_dispi_enabled()) - return stdvga_get_displaystart(vmode_g); - int bpp = vga_bpp(vmode_g); + return stdvga_get_displaystart(curmode_g); + int bpp = vga_bpp(curmode_g); int linelength = dispi_read(VBE_DISPI_INDEX_VIRT_WIDTH) * bpp / 8; int x = dispi_read(VBE_DISPI_INDEX_X_OFFSET); int y = dispi_read(VBE_DISPI_INDEX_Y_OFFSET); @@ -147,11 +147,11 @@ bochsvga_get_displaystart(struct vgamode_s *vmode_g) }
int -bochsvga_set_displaystart(struct vgamode_s *vmode_g, int val) +bochsvga_set_displaystart(struct vgamode_s *curmode_g, int val) { - stdvga_set_displaystart(vmode_g, val); + stdvga_set_displaystart(curmode_g, val); if (bochsvga_dispi_enabled()) { - int bpp = vga_bpp(vmode_g); + int bpp = vga_bpp(curmode_g); int linelength = dispi_read(VBE_DISPI_INDEX_VIRT_WIDTH) * bpp / 8; if (!linelength) return 0; @@ -162,19 +162,19 @@ bochsvga_set_displaystart(struct vgamode_s *vmode_g, int val) }
int -bochsvga_get_dacformat(struct vgamode_s *vmode_g) +bochsvga_get_dacformat(struct vgamode_s *curmode_g) { if (!bochsvga_dispi_enabled()) - return stdvga_get_dacformat(vmode_g); + return stdvga_get_dacformat(curmode_g); u16 en = dispi_read(VBE_DISPI_INDEX_ENABLE); return (en & VBE_DISPI_8BIT_DAC) ? 8 : 6; }
int -bochsvga_set_dacformat(struct vgamode_s *vmode_g, int val) +bochsvga_set_dacformat(struct vgamode_s *curmode_g, int val) { if (!bochsvga_dispi_enabled()) - return stdvga_set_dacformat(vmode_g, val); + return stdvga_set_dacformat(curmode_g, val); u16 en = dispi_read(VBE_DISPI_INDEX_ENABLE); if (val == 6) en &= ~VBE_DISPI_8BIT_DAC; diff --git a/vgasrc/bochsvga.h b/vgasrc/bochsvga.h index ae5f75d..93d1b38 100644 --- a/vgasrc/bochsvga.h +++ b/vgasrc/bochsvga.h @@ -42,14 +42,14 @@
struct vgamode_s *bochsvga_find_mode(int mode); void bochsvga_list_modes(u16 seg, u16 *dest, u16 *last); -int bochsvga_get_window(struct vgamode_s *vmode_g, int window); -int bochsvga_set_window(struct vgamode_s *vmode_g, int window, int val); -int bochsvga_get_linelength(struct vgamode_s *vmode_g); -int bochsvga_set_linelength(struct vgamode_s *vmode_g, int val); -int bochsvga_get_displaystart(struct vgamode_s *vmode_g); -int bochsvga_set_displaystart(struct vgamode_s *vmode_g, int val); -int bochsvga_get_dacformat(struct vgamode_s *vmode_g); -int bochsvga_set_dacformat(struct vgamode_s *vmode_g, int val); +int bochsvga_get_window(struct vgamode_s *curmode_g, int window); +int bochsvga_set_window(struct vgamode_s *curmode_g, int window, int val); +int bochsvga_get_linelength(struct vgamode_s *curmode_g); +int bochsvga_set_linelength(struct vgamode_s *curmode_g, int val); +int bochsvga_get_displaystart(struct vgamode_s *curmode_g); +int bochsvga_set_displaystart(struct vgamode_s *curmode_g, int val); +int bochsvga_get_dacformat(struct vgamode_s *curmode_g); +int bochsvga_set_dacformat(struct vgamode_s *curmode_g, int val); int bochsvga_save_restore(int cmd, u16 seg, void *data); int bochsvga_set_mode(struct vgamode_s *vmode_g, int flags); int bochsvga_setup(void); diff --git a/vgasrc/cbvga.c b/vgasrc/cbvga.c index b919137..9e3cc93 100644 --- a/vgasrc/cbvga.c +++ b/vgasrc/cbvga.c @@ -70,49 +70,49 @@ cbvga_list_modes(u16 seg, u16 *dest, u16 *last) }
int -cbvga_get_window(struct vgamode_s *vmode_g, int window) +cbvga_get_window(struct vgamode_s *curmode_g, int window) { return -1; }
int -cbvga_set_window(struct vgamode_s *vmode_g, int window, int val) +cbvga_set_window(struct vgamode_s *curmode_g, int window, int val) { return -1; }
int -cbvga_get_linelength(struct vgamode_s *vmode_g) +cbvga_get_linelength(struct vgamode_s *curmode_g) { return GET_GLOBAL(CBlinelength); }
int -cbvga_set_linelength(struct vgamode_s *vmode_g, int val) +cbvga_set_linelength(struct vgamode_s *curmode_g, int val) { return -1; }
int -cbvga_get_displaystart(struct vgamode_s *vmode_g) +cbvga_get_displaystart(struct vgamode_s *curmode_g) { return 0; }
int -cbvga_set_displaystart(struct vgamode_s *vmode_g, int val) +cbvga_set_displaystart(struct vgamode_s *curmode_g, int val) { return -1; }
int -cbvga_get_dacformat(struct vgamode_s *vmode_g) +cbvga_get_dacformat(struct vgamode_s *curmode_g) { return -1; }
int -cbvga_set_dacformat(struct vgamode_s *vmode_g, int val) +cbvga_set_dacformat(struct vgamode_s *curmode_g, int val) { return -1; } diff --git a/vgasrc/clext.c b/vgasrc/clext.c index da8b790..c89a47b 100644 --- a/vgasrc/clext.c +++ b/vgasrc/clext.c @@ -309,13 +309,13 @@ clext_list_modes(u16 seg, u16 *dest, u16 *last) ****************************************************************/
int -clext_get_window(struct vgamode_s *vmode_g, int window) +clext_get_window(struct vgamode_s *curmode_g, int window) { return stdvga_grdc_read(window + 9); }
int -clext_set_window(struct vgamode_s *vmode_g, int window, int val) +clext_set_window(struct vgamode_s *curmode_g, int window, int val) { if (val >= 0x100) return -1; @@ -324,26 +324,26 @@ clext_set_window(struct vgamode_s *vmode_g, int window, int val) }
int -clext_get_linelength(struct vgamode_s *vmode_g) +clext_get_linelength(struct vgamode_s *curmode_g) { u16 crtc_addr = stdvga_get_crtc(); u8 reg13 = stdvga_crtc_read(crtc_addr, 0x13); u8 reg1b = stdvga_crtc_read(crtc_addr, 0x1b); - return (((reg1b & 0x10) << 4) + reg13) * 8 / stdvga_vram_ratio(vmode_g); + return (((reg1b & 0x10) << 4) + reg13) * 8 / stdvga_vram_ratio(curmode_g); }
int -clext_set_linelength(struct vgamode_s *vmode_g, int val) +clext_set_linelength(struct vgamode_s *curmode_g, int val) { u16 crtc_addr = stdvga_get_crtc(); - val = DIV_ROUND_UP(val * stdvga_vram_ratio(vmode_g), 8); + val = DIV_ROUND_UP(val * stdvga_vram_ratio(curmode_g), 8); stdvga_crtc_write(crtc_addr, 0x13, val); stdvga_crtc_mask(crtc_addr, 0x1b, 0x10, (val & 0x100) >> 4); return 0; }
int -clext_get_displaystart(struct vgamode_s *vmode_g) +clext_get_displaystart(struct vgamode_s *curmode_g) { u16 crtc_addr = stdvga_get_crtc(); u8 b2 = stdvga_crtc_read(crtc_addr, 0x0c); @@ -352,14 +352,14 @@ clext_get_displaystart(struct vgamode_s *vmode_g) u8 b4 = stdvga_crtc_read(crtc_addr, 0x1d); int val = (b1 | (b2<<8) | ((b3 & 0x01) << 16) | ((b3 & 0x0c) << 15) | ((b4 & 0x80) << 12)); - return val * 4 / stdvga_vram_ratio(vmode_g); + return val * 4 / stdvga_vram_ratio(curmode_g); }
int -clext_set_displaystart(struct vgamode_s *vmode_g, int val) +clext_set_displaystart(struct vgamode_s *curmode_g, int val) { u16 crtc_addr = stdvga_get_crtc(); - val = val * stdvga_vram_ratio(vmode_g) / 4; + val = val * stdvga_vram_ratio(curmode_g) / 4; stdvga_crtc_write(crtc_addr, 0x0d, val); stdvga_crtc_write(crtc_addr, 0x0c, val >> 8); stdvga_crtc_mask(crtc_addr, 0x1d, 0x80, (val & 0x0800) >> 4); diff --git a/vgasrc/stdvga.c b/vgasrc/stdvga.c index 0e01275..9d8f556 100644 --- a/vgasrc/stdvga.c +++ b/vgasrc/stdvga.c @@ -264,59 +264,59 @@ stdvga_get_vde(void) }
int -stdvga_get_window(struct vgamode_s *vmode_g, int window) +stdvga_get_window(struct vgamode_s *curmode_g, int window) { return -1; }
int -stdvga_set_window(struct vgamode_s *vmode_g, int window, int val) +stdvga_set_window(struct vgamode_s *curmode_g, int window, int val) { return -1; }
int -stdvga_get_linelength(struct vgamode_s *vmode_g) +stdvga_get_linelength(struct vgamode_s *curmode_g) { u8 val = stdvga_crtc_read(stdvga_get_crtc(), 0x13); - return val * 8 / stdvga_vram_ratio(vmode_g); + return val * 8 / stdvga_vram_ratio(curmode_g); }
int -stdvga_set_linelength(struct vgamode_s *vmode_g, int val) +stdvga_set_linelength(struct vgamode_s *curmode_g, int val) { - val = DIV_ROUND_UP(val * stdvga_vram_ratio(vmode_g), 8); + val = DIV_ROUND_UP(val * stdvga_vram_ratio(curmode_g), 8); stdvga_crtc_write(stdvga_get_crtc(), 0x13, val); return 0; }
int -stdvga_get_displaystart(struct vgamode_s *vmode_g) +stdvga_get_displaystart(struct vgamode_s *curmode_g) { u16 crtc_addr = stdvga_get_crtc(); int addr = (stdvga_crtc_read(crtc_addr, 0x0c) << 8 | stdvga_crtc_read(crtc_addr, 0x0d)); - return addr * 4 / stdvga_vram_ratio(vmode_g); + return addr * 4 / stdvga_vram_ratio(curmode_g); }
int -stdvga_set_displaystart(struct vgamode_s *vmode_g, int val) +stdvga_set_displaystart(struct vgamode_s *curmode_g, int val) { u16 crtc_addr = stdvga_get_crtc(); - val = val * stdvga_vram_ratio(vmode_g) / 4; + val = val * stdvga_vram_ratio(curmode_g) / 4; stdvga_crtc_write(crtc_addr, 0x0c, val >> 8); stdvga_crtc_write(crtc_addr, 0x0d, val); return 0; }
int -stdvga_get_dacformat(struct vgamode_s *vmode_g) +stdvga_get_dacformat(struct vgamode_s *curmode_g) { return -1; }
int -stdvga_set_dacformat(struct vgamode_s *vmode_g, int val) +stdvga_set_dacformat(struct vgamode_s *curmode_g, int val) { return -1; } diff --git a/vgasrc/stdvga.h b/vgasrc/stdvga.h index 4184c60..5164ca1 100644 --- a/vgasrc/stdvga.h +++ b/vgasrc/stdvga.h @@ -66,14 +66,14 @@ void stdvga_set_cursor_shape(u16 cursor_type); void stdvga_set_cursor_pos(int address); void stdvga_set_scan_lines(u8 lines); u16 stdvga_get_vde(void); -int stdvga_get_window(struct vgamode_s *vmode_g, int window); -int stdvga_set_window(struct vgamode_s *vmode_g, int window, int val); -int stdvga_get_linelength(struct vgamode_s *vmode_g); -int stdvga_set_linelength(struct vgamode_s *vmode_g, int val); -int stdvga_get_displaystart(struct vgamode_s *vmode_g); -int stdvga_set_displaystart(struct vgamode_s *vmode_g, int val); -int stdvga_get_dacformat(struct vgamode_s *vmode_g); -int stdvga_set_dacformat(struct vgamode_s *vmode_g, int val); +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_get_linelength(struct vgamode_s *curmode_g); +int stdvga_set_linelength(struct vgamode_s *curmode_g, int val); +int stdvga_get_displaystart(struct vgamode_s *curmode_g); +int stdvga_set_displaystart(struct vgamode_s *curmode_g, int val); +int stdvga_get_dacformat(struct vgamode_s *curmode_g); +int stdvga_set_dacformat(struct vgamode_s *curmode_g, int val); int stdvga_save_restore(int cmd, u16 seg, void *data); void stdvga_enable_video_addressing(u8 disable); int stdvga_setup(void); diff --git a/vgasrc/stdvgamodes.c b/vgasrc/stdvgamodes.c index 173dd4f..3e6b575 100644 --- a/vgasrc/stdvgamodes.c +++ b/vgasrc/stdvgamodes.c @@ -431,19 +431,17 @@ stdvga_override_crtc(int mode, u8 *crtc) }
static void -clear_screen(struct vgamode_s *vmode_g) +clear_screen(struct vgamode_s *curmode_g) { - switch (GET_GLOBAL(vmode_g->memmodel)) { + switch (GET_GLOBAL(curmode_g->memmodel)) { case MM_TEXT: - memset16_far(GET_GLOBAL(vmode_g->sstart), 0, 0x0720, 32*1024); + memset16_far(GET_GLOBAL(curmode_g->sstart), 0, 0x0720, 32*1024); break; case MM_CGA: - memset16_far(GET_GLOBAL(vmode_g->sstart), 0, 0x0000, 32*1024); + memset16_far(GET_GLOBAL(curmode_g->sstart), 0, 0x0000, 32*1024); break; default: - // XXX - old code gets/sets/restores sequ register 2 to 0xf - - // but it should always be 0xf anyway. - memset16_far(GET_GLOBAL(vmode_g->sstart), 0, 0x0000, 64*1024); + memset16_far(GET_GLOBAL(curmode_g->sstart), 0, 0x0000, 64*1024); } }
diff --git a/vgasrc/swcursor.c b/vgasrc/swcursor.c index f2212d5..765a7c7 100644 --- a/vgasrc/swcursor.c +++ b/vgasrc/swcursor.c @@ -12,12 +12,12 @@
// Draw/undraw a cursor on the framebuffer by xor'ing the cursor cell static void -gfx_set_swcursor(struct vgamode_s *vmode_g, int enable, struct cursorpos cp) +gfx_set_swcursor(struct vgamode_s *curmode_g, int enable, struct cursorpos cp) { u16 cursor_type = get_cursor_shape(); u8 start = cursor_type >> 8, end = cursor_type & 0xff; struct gfx_op op; - init_gfx_op(&op, vmode_g); + init_gfx_op(&op, curmode_g); op.x = cp.x * 8; int cheight = GET_BDA(char_height); op.y = cp.y * cheight + start; @@ -42,8 +42,8 @@ set_swcursor(int enable) if (!!(flags & BF_SWCURSOR) == enable) // Already in requested mode. return; - struct vgamode_s *vmode_g = get_current_mode(); - if (!vmode_g) + struct vgamode_s *curmode_g = get_current_mode(); + if (!curmode_g) return; struct cursorpos cp = get_cursor_pos(GET_BDA(video_page)); if (cp.x >= GET_BDA(video_cols) || cp.y > GET_BDA(video_rows) @@ -53,16 +53,16 @@ set_swcursor(int enable)
SET_BDA_EXT(flags, (flags & ~BF_SWCURSOR) | (enable ? BF_SWCURSOR : 0));
- if (GET_GLOBAL(vmode_g->memmodel) != MM_TEXT) { - gfx_set_swcursor(vmode_g, enable, cp); + if (GET_GLOBAL(curmode_g->memmodel) != MM_TEXT) { + gfx_set_swcursor(curmode_g, enable, cp); return; }
// In text mode, swap foreground and background attributes for cursor void *dest_far = text_address(cp) + 1; - u8 attr = GET_FARVAR(GET_GLOBAL(vmode_g->sstart), *(u8*)dest_far); + u8 attr = GET_FARVAR(GET_GLOBAL(curmode_g->sstart), *(u8*)dest_far); attr = (attr >> 4) | (attr << 4); - SET_FARVAR(GET_GLOBAL(vmode_g->sstart), *(u8*)dest_far, attr); + SET_FARVAR(GET_GLOBAL(curmode_g->sstart), *(u8*)dest_far, attr); }
// Disable virtual cursor if a vgabios call accesses the framebuffer diff --git a/vgasrc/vbe.c b/vgasrc/vbe.c index d7ce941..3efb54f 100644 --- a/vgasrc/vbe.c +++ b/vgasrc/vbe.c @@ -260,18 +260,18 @@ vbe_104f05(struct bregs *regs) regs->ah = VBE_RETURN_STATUS_INVALID; return; } - struct vgamode_s *vmode_g = get_current_mode(); - if (! vmode_g) + struct vgamode_s *curmode_g = get_current_mode(); + if (! curmode_g) goto fail; if (regs->bh) { - int ret = vgahw_get_window(vmode_g, regs->bl); + int ret = vgahw_get_window(curmode_g, regs->bl); if (ret < 0) goto fail; regs->dx = ret; regs->ax = 0x004f; return; } - int ret = vgahw_set_window(vmode_g, regs->bl, regs->dx); + int ret = vgahw_set_window(curmode_g, regs->bl, regs->dx); if (ret) goto fail; regs->ax = 0x004f; @@ -285,21 +285,22 @@ vbe_104f06(struct bregs *regs) { if (regs->bl > 0x02) goto fail; - struct vgamode_s *vmode_g = get_current_mode(); - if (! vmode_g) + struct vgamode_s *curmode_g = get_current_mode(); + if (! curmode_g) goto fail; - int bpp = vga_bpp(vmode_g); + int bpp = vga_bpp(curmode_g);
if (regs->bl == 0x00) { - int ret = vgahw_set_linelength(vmode_g, DIV_ROUND_UP(regs->cx * bpp, 8)); + int ret = vgahw_set_linelength(curmode_g + , DIV_ROUND_UP(regs->cx * bpp, 8)); if (ret) goto fail; } else if (regs->bl == 0x02) { - int ret = vgahw_set_linelength(vmode_g, regs->cx); + int ret = vgahw_set_linelength(curmode_g, regs->cx); if (ret) goto fail; } - int linelength = vgahw_get_linelength(vmode_g); + int linelength = vgahw_get_linelength(curmode_g); if (linelength < 0) goto fail;
@@ -315,11 +316,11 @@ fail: static void vbe_104f07(struct bregs *regs) { - struct vgamode_s *vmode_g = get_current_mode(); - if (! vmode_g) + struct vgamode_s *curmode_g = get_current_mode(); + if (! curmode_g) goto fail; - int bpp = vga_bpp(vmode_g); - int linelength = vgahw_get_linelength(vmode_g); + int bpp = vga_bpp(curmode_g); + int linelength = vgahw_get_linelength(curmode_g); if (linelength < 0) goto fail;
@@ -328,12 +329,12 @@ vbe_104f07(struct bregs *regs) case 0x80: case 0x00: ret = vgahw_set_displaystart( - vmode_g, DIV_ROUND_UP(regs->cx * bpp, 8) + linelength * regs->dx); + curmode_g, DIV_ROUND_UP(regs->cx * bpp, 8) + linelength * regs->dx); if (ret) goto fail; break; case 0x01: - ret = vgahw_get_displaystart(vmode_g); + ret = vgahw_get_displaystart(curmode_g); if (ret < 0) goto fail; regs->dx = ret / linelength; @@ -351,10 +352,10 @@ fail: static void vbe_104f08(struct bregs *regs) { - struct vgamode_s *vmode_g = get_current_mode(); - if (! vmode_g) + struct vgamode_s *curmode_g = get_current_mode(); + if (! curmode_g) goto fail; - u8 memmodel = GET_GLOBAL(vmode_g->memmodel); + u8 memmodel = GET_GLOBAL(curmode_g->memmodel); if (memmodel == MM_DIRECT || memmodel == MM_YUV) { regs->ax = 0x034f; return; @@ -362,11 +363,11 @@ vbe_104f08(struct bregs *regs) if (regs->bl > 1) goto fail; if (regs->bl == 0) { - int ret = vgahw_set_dacformat(vmode_g, regs->bh); + int ret = vgahw_set_dacformat(curmode_g, regs->bh); if (ret < 0) goto fail; } - int ret = vgahw_get_dacformat(vmode_g); + int ret = vgahw_get_dacformat(curmode_g); if (ret < 0) goto fail; regs->bh = ret; @@ -385,11 +386,11 @@ vbe_104f09(struct bregs *regs) return; }
- struct vgamode_s *vmode_g = get_current_mode(); - if (! vmode_g) + struct vgamode_s *curmode_g = get_current_mode(); + if (! curmode_g) goto fail; - u8 memmodel = GET_GLOBAL(vmode_g->memmodel); - u8 depth = GET_GLOBAL(vmode_g->depth); + u8 memmodel = GET_GLOBAL(curmode_g->memmodel); + u8 depth = GET_GLOBAL(curmode_g->depth); if (memmodel == MM_DIRECT || memmodel == MM_YUV || depth > 8) { regs->ax = 0x034f; return; diff --git a/vgasrc/vgabios.c b/vgasrc/vgabios.c index 73ba1c3..2ca8c3d 100644 --- a/vgasrc/vgabios.c +++ b/vgasrc/vgabios.c @@ -114,14 +114,14 @@ set_active_page(u8 page) return;
// Get the mode - struct vgamode_s *vmode_g = get_current_mode(); - if (!vmode_g) + struct vgamode_s *curmode_g = get_current_mode(); + if (!curmode_g) return;
// Calculate memory address of start of page struct cursorpos cp = {0, 0, page}; int address = (int)text_address(cp); - vgahw_set_displaystart(vmode_g, address); + vgahw_set_displaystart(curmode_g, address);
// And change the BIOS page SET_BDA(video_pagestart, address); diff --git a/vgasrc/vgafb.c b/vgasrc/vgafb.c index f8f35c2..bb4f11e 100644 --- a/vgasrc/vgafb.c +++ b/vgasrc/vgafb.c @@ -98,7 +98,7 @@ gfx_planar(struct gfx_op *op) static void gfx_cga(struct gfx_op *op) { - int bpp = GET_GLOBAL(op->vmode_g->depth); + int bpp = GET_GLOBAL(op->curmode_g->depth); void *dest_far = (void*)(op->y / 2 * op->linelength + op->x / 8 * bpp); switch (op->op) { default: @@ -270,7 +270,7 @@ gfx_direct(struct gfx_op *op) void *fb = (void*)GET_GLOBAL(VBE_framebuffer); if (!fb) return; - int depth = GET_GLOBAL(op->vmode_g->depth); + int depth = GET_GLOBAL(op->curmode_g->depth); int bypp = DIV_ROUND_UP(depth, 8); void *dest_far = (fb + op->displaystart + op->y * op->linelength + op->x * bypp); @@ -314,19 +314,19 @@ gfx_direct(struct gfx_op *op)
// Prepare a struct gfx_op for use. void -init_gfx_op(struct gfx_op *op, struct vgamode_s *vmode_g) +init_gfx_op(struct gfx_op *op, struct vgamode_s *curmode_g) { memset(op, 0, sizeof(*op)); - op->vmode_g = vmode_g; - op->linelength = vgahw_get_linelength(vmode_g); - op->displaystart = vgahw_get_displaystart(vmode_g); + op->curmode_g = curmode_g; + op->linelength = vgahw_get_linelength(curmode_g); + op->displaystart = vgahw_get_displaystart(curmode_g); }
// Issue a graphics operation. void handle_gfx_op(struct gfx_op *op) { - switch (GET_GLOBAL(op->vmode_g->memmodel)) { + switch (GET_GLOBAL(op->curmode_g->memmodel)) { case MM_PLANAR: gfx_planar(op); break; @@ -346,11 +346,11 @@ handle_gfx_op(struct gfx_op *op)
// Move characters when in graphics mode. static void -gfx_move_chars(struct vgamode_s *vmode_g, struct cursorpos dest +gfx_move_chars(struct vgamode_s *curmode_g, struct cursorpos dest , struct cursorpos movesize, int lines) { struct gfx_op op; - init_gfx_op(&op, vmode_g); + init_gfx_op(&op, curmode_g); op.x = dest.x * 8; op.xlen = movesize.x * 8; int cheight = GET_BDA(char_height); @@ -363,11 +363,11 @@ gfx_move_chars(struct vgamode_s *vmode_g, struct cursorpos dest
// Clear area of screen in graphics mode. static void -gfx_clear_chars(struct vgamode_s *vmode_g, struct cursorpos win +gfx_clear_chars(struct vgamode_s *curmode_g, struct cursorpos win , struct cursorpos winsize, struct carattr ca) { struct gfx_op op; - init_gfx_op(&op, vmode_g); + init_gfx_op(&op, curmode_g); op.x = win.x * 8; op.xlen = winsize.x * 8; int cheight = GET_BDA(char_height); @@ -398,7 +398,7 @@ get_font_data(u8 c)
// Write a character to the screen in graphics mode. static void -gfx_write_char(struct vgamode_s *vmode_g +gfx_write_char(struct vgamode_s *curmode_g , struct cursorpos cp, struct carattr ca) { if (cp.x >= GET_BDA(video_cols)) @@ -406,7 +406,7 @@ gfx_write_char(struct vgamode_s *vmode_g
struct segoff_s font = get_font_data(ca.car); struct gfx_op op; - init_gfx_op(&op, vmode_g); + init_gfx_op(&op, curmode_g); op.x = cp.x * 8; int cheight = GET_BDA(char_height); op.y = cp.y * cheight; @@ -425,7 +425,7 @@ gfx_write_char(struct vgamode_s *vmode_g bgattr = op.pixels[7]; fgattr = bgattr ^ 0x7; } - } else if (fgattr & 0x80 && GET_GLOBAL(vmode_g->depth) < 8) { + } else if (fgattr & 0x80 && GET_GLOBAL(curmode_g->depth) < 8) { usexor = 1; fgattr &= 0x7f; } @@ -450,7 +450,7 @@ gfx_write_char(struct vgamode_s *vmode_g
// Read a character from the screen in graphics mode. static struct carattr -gfx_read_char(struct vgamode_s *vmode_g, struct cursorpos cp) +gfx_read_char(struct vgamode_s *curmode_g, struct cursorpos cp) { u8 lines[16]; int cheight = GET_BDA(char_height); @@ -459,7 +459,7 @@ gfx_read_char(struct vgamode_s *vmode_g, struct cursorpos cp)
// Read cell from screen struct gfx_op op; - init_gfx_op(&op, vmode_g); + init_gfx_op(&op, curmode_g); op.op = GO_READ8; op.x = cp.x * 8; op.y = cp.y * cheight; @@ -502,18 +502,18 @@ fail: void vgafb_write_pixel(u8 color, u16 x, u16 y) { - struct vgamode_s *vmode_g = get_current_mode(); - if (!vmode_g) + struct vgamode_s *curmode_g = get_current_mode(); + if (!curmode_g) return;
struct gfx_op op; - init_gfx_op(&op, vmode_g); + init_gfx_op(&op, curmode_g); op.x = ALIGN_DOWN(x, 8); op.y = y; op.op = GO_READ8; handle_gfx_op(&op);
- int usexor = color & 0x80 && GET_GLOBAL(vmode_g->depth) < 8; + int usexor = color & 0x80 && GET_GLOBAL(curmode_g->depth) < 8; if (usexor) op.pixels[x & 0x07] ^= color & 0x7f; else @@ -526,12 +526,12 @@ vgafb_write_pixel(u8 color, u16 x, u16 y) u8 vgafb_read_pixel(u16 x, u16 y) { - struct vgamode_s *vmode_g = get_current_mode(); - if (!vmode_g) + struct vgamode_s *curmode_g = get_current_mode(); + if (!curmode_g) return 0;
struct gfx_op op; - init_gfx_op(&op, vmode_g); + init_gfx_op(&op, curmode_g); op.x = ALIGN_DOWN(x, 8); op.y = y; op.op = GO_READ8; @@ -558,18 +558,18 @@ text_address(struct cursorpos cp) static void vgafb_move_chars(struct cursorpos dest, struct cursorpos movesize, int lines) { - struct vgamode_s *vmode_g = get_current_mode(); - if (!vmode_g) + struct vgamode_s *curmode_g = get_current_mode(); + if (!curmode_g) return;
- if (GET_GLOBAL(vmode_g->memmodel) != MM_TEXT) { - gfx_move_chars(vmode_g, dest, movesize, lines); + if (GET_GLOBAL(curmode_g->memmodel) != MM_TEXT) { + gfx_move_chars(curmode_g, dest, movesize, lines); return; }
int stride = GET_BDA(video_cols) * 2; void *dest_addr = text_address(dest), *src_addr = dest_addr + lines * stride; - memmove_stride(GET_GLOBAL(vmode_g->sstart), dest_addr, src_addr + memmove_stride(GET_GLOBAL(curmode_g->sstart), dest_addr, src_addr , movesize.x * 2, stride, movesize.y); }
@@ -578,18 +578,18 @@ static void vgafb_clear_chars(struct cursorpos win, struct cursorpos winsize , struct carattr ca) { - struct vgamode_s *vmode_g = get_current_mode(); - if (!vmode_g) + struct vgamode_s *curmode_g = get_current_mode(); + if (!curmode_g) return;
- if (GET_GLOBAL(vmode_g->memmodel) != MM_TEXT) { - gfx_clear_chars(vmode_g, win, winsize, ca); + if (GET_GLOBAL(curmode_g->memmodel) != MM_TEXT) { + gfx_clear_chars(curmode_g, win, winsize, ca); return; }
int stride = GET_BDA(video_cols) * 2; u16 attr = ((ca.use_attr ? ca.attr : 0x07) << 8) | ca.car; - memset16_stride(GET_GLOBAL(vmode_g->sstart), text_address(win), attr + memset16_stride(GET_GLOBAL(curmode_g->sstart), text_address(win), attr , winsize.x * 2, stride, winsize.y); }
@@ -625,21 +625,21 @@ vgafb_scroll(struct cursorpos win, struct cursorpos winsize void vgafb_write_char(struct cursorpos cp, struct carattr ca) { - struct vgamode_s *vmode_g = get_current_mode(); - if (!vmode_g) + struct vgamode_s *curmode_g = get_current_mode(); + if (!curmode_g) return;
- if (GET_GLOBAL(vmode_g->memmodel) != MM_TEXT) { - gfx_write_char(vmode_g, cp, ca); + if (GET_GLOBAL(curmode_g->memmodel) != MM_TEXT) { + gfx_write_char(curmode_g, cp, ca); return; }
void *dest_far = text_address(cp); if (ca.use_attr) { u16 dummy = (ca.attr << 8) | ca.car; - SET_FARVAR(GET_GLOBAL(vmode_g->sstart), *(u16*)dest_far, dummy); + SET_FARVAR(GET_GLOBAL(curmode_g->sstart), *(u16*)dest_far, dummy); } else { - SET_FARVAR(GET_GLOBAL(vmode_g->sstart), *(u8*)dest_far, ca.car); + SET_FARVAR(GET_GLOBAL(curmode_g->sstart), *(u8*)dest_far, ca.car); } }
@@ -647,14 +647,14 @@ vgafb_write_char(struct cursorpos cp, struct carattr ca) struct carattr vgafb_read_char(struct cursorpos cp) { - struct vgamode_s *vmode_g = get_current_mode(); - if (!vmode_g) + struct vgamode_s *curmode_g = get_current_mode(); + if (!curmode_g) return (struct carattr){0, 0, 0};
- if (GET_GLOBAL(vmode_g->memmodel) != MM_TEXT) - return gfx_read_char(vmode_g, cp); + if (GET_GLOBAL(curmode_g->memmodel) != MM_TEXT) + return gfx_read_char(curmode_g, cp);
u16 *dest_far = text_address(cp); - u16 v = GET_FARVAR(GET_GLOBAL(vmode_g->sstart), *dest_far); + u16 v = GET_FARVAR(GET_GLOBAL(curmode_g->sstart), *dest_far); return (struct carattr){v, v>>8, 0}; } diff --git a/vgasrc/vgafb.h b/vgasrc/vgafb.h index aae6b9b..d564427 100644 --- a/vgasrc/vgafb.h +++ b/vgasrc/vgafb.h @@ -3,7 +3,7 @@
// Graphics pixel operations. struct gfx_op { - struct vgamode_s *vmode_g; + struct vgamode_s *curmode_g; u32 linelength; u32 displaystart;
@@ -30,7 +30,7 @@ struct carattr {
// vgafb.c void memcpy_high(void *dest, void *src, u32 len); -void init_gfx_op(struct gfx_op *op, struct vgamode_s *vmode_g); +void init_gfx_op(struct gfx_op *op, struct vgamode_s *curmode_g); void handle_gfx_op(struct gfx_op *op); void *text_address(struct cursorpos cp); void vgafb_scroll(struct cursorpos win, struct cursorpos winsize diff --git a/vgasrc/vgahw.h b/vgasrc/vgahw.h index 8b64660..bd33e20 100644 --- a/vgasrc/vgahw.h +++ b/vgasrc/vgahw.h @@ -64,81 +64,81 @@ static inline int vgahw_setup(void) { return stdvga_setup(); }
-static inline int vgahw_get_window(struct vgamode_s *vmode_g, int window) { +static inline int vgahw_get_window(struct vgamode_s *curmode_g, int window) { if (CONFIG_VGA_CIRRUS) - return clext_get_window(vmode_g, window); + return clext_get_window(curmode_g, window); if (CONFIG_VGA_BOCHS) - return bochsvga_get_window(vmode_g, window); + return bochsvga_get_window(curmode_g, window); if (CONFIG_VGA_EMULATE_TEXT) - return cbvga_get_window(vmode_g, window); - return stdvga_get_window(vmode_g, window); + return cbvga_get_window(curmode_g, window); + return stdvga_get_window(curmode_g, window); }
-static inline int vgahw_set_window(struct vgamode_s *vmode_g, int window +static inline int vgahw_set_window(struct vgamode_s *curmode_g, int window , int val) { if (CONFIG_VGA_CIRRUS) - return clext_set_window(vmode_g, window, val); + return clext_set_window(curmode_g, window, val); if (CONFIG_VGA_BOCHS) - return bochsvga_set_window(vmode_g, window, val); + return bochsvga_set_window(curmode_g, window, val); if (CONFIG_VGA_EMULATE_TEXT) - return cbvga_set_window(vmode_g, window, val); - return stdvga_set_window(vmode_g, window, val); + return cbvga_set_window(curmode_g, window, val); + return stdvga_set_window(curmode_g, window, val); }
-static inline int vgahw_get_linelength(struct vgamode_s *vmode_g) { +static inline int vgahw_get_linelength(struct vgamode_s *curmode_g) { if (CONFIG_VGA_CIRRUS) - return clext_get_linelength(vmode_g); + return clext_get_linelength(curmode_g); if (CONFIG_VGA_BOCHS) - return bochsvga_get_linelength(vmode_g); + return bochsvga_get_linelength(curmode_g); if (CONFIG_VGA_EMULATE_TEXT) - return cbvga_get_linelength(vmode_g); - return stdvga_get_linelength(vmode_g); + return cbvga_get_linelength(curmode_g); + return stdvga_get_linelength(curmode_g); }
-static inline int vgahw_set_linelength(struct vgamode_s *vmode_g, int val) { +static inline int vgahw_set_linelength(struct vgamode_s *curmode_g, int val) { if (CONFIG_VGA_CIRRUS) - return clext_set_linelength(vmode_g, val); + return clext_set_linelength(curmode_g, val); if (CONFIG_VGA_BOCHS) - return bochsvga_set_linelength(vmode_g, val); + return bochsvga_set_linelength(curmode_g, val); if (CONFIG_VGA_EMULATE_TEXT) - return cbvga_set_linelength(vmode_g, val); - return stdvga_set_linelength(vmode_g, val); + return cbvga_set_linelength(curmode_g, val); + return stdvga_set_linelength(curmode_g, val); }
-static inline int vgahw_get_displaystart(struct vgamode_s *vmode_g) { +static inline int vgahw_get_displaystart(struct vgamode_s *curmode_g) { if (CONFIG_VGA_CIRRUS) - return clext_get_displaystart(vmode_g); + return clext_get_displaystart(curmode_g); if (CONFIG_VGA_BOCHS) - return bochsvga_get_displaystart(vmode_g); + return bochsvga_get_displaystart(curmode_g); if (CONFIG_VGA_EMULATE_TEXT) - return cbvga_get_displaystart(vmode_g); - return stdvga_get_displaystart(vmode_g); + return cbvga_get_displaystart(curmode_g); + return stdvga_get_displaystart(curmode_g); }
-static inline int vgahw_set_displaystart(struct vgamode_s *vmode_g, int val) { +static inline int vgahw_set_displaystart(struct vgamode_s *curmode_g, int val) { if (CONFIG_VGA_CIRRUS) - return clext_set_displaystart(vmode_g, val); + return clext_set_displaystart(curmode_g, val); if (CONFIG_VGA_BOCHS) - return bochsvga_set_displaystart(vmode_g, val); + return bochsvga_set_displaystart(curmode_g, val); if (CONFIG_VGA_EMULATE_TEXT) - return cbvga_set_displaystart(vmode_g, val); - return stdvga_set_displaystart(vmode_g, val); + return cbvga_set_displaystart(curmode_g, val); + return stdvga_set_displaystart(curmode_g, val); }
-static inline int vgahw_get_dacformat(struct vgamode_s *vmode_g) { +static inline int vgahw_get_dacformat(struct vgamode_s *curmode_g) { if (CONFIG_VGA_BOCHS) - return bochsvga_get_dacformat(vmode_g); + return bochsvga_get_dacformat(curmode_g); if (CONFIG_VGA_EMULATE_TEXT) - return cbvga_get_dacformat(vmode_g); - return stdvga_get_dacformat(vmode_g); + return cbvga_get_dacformat(curmode_g); + return stdvga_get_dacformat(curmode_g); }
-static inline int vgahw_set_dacformat(struct vgamode_s *vmode_g, int val) { +static inline int vgahw_set_dacformat(struct vgamode_s *curmode_g, int val) { if (CONFIG_VGA_BOCHS) - return bochsvga_set_dacformat(vmode_g, val); + return bochsvga_set_dacformat(curmode_g, val); if (CONFIG_VGA_EMULATE_TEXT) - return cbvga_set_dacformat(vmode_g, val); - return stdvga_set_dacformat(vmode_g, val); + return cbvga_set_dacformat(curmode_g, val); + return stdvga_set_dacformat(curmode_g, val); }
static inline int vgahw_save_restore(int cmd, u16 seg, void *data) { diff --git a/vgasrc/vgautil.h b/vgasrc/vgautil.h index dd1aa18..245a562 100644 --- a/vgasrc/vgautil.h +++ b/vgasrc/vgautil.h @@ -7,14 +7,14 @@ // cbvga.c struct vgamode_s *cbvga_find_mode(int mode); void cbvga_list_modes(u16 seg, u16 *dest, u16 *last); -int cbvga_get_window(struct vgamode_s *vmode_g, int window); -int cbvga_set_window(struct vgamode_s *vmode_g, int window, int val); -int cbvga_get_linelength(struct vgamode_s *vmode_g); -int cbvga_set_linelength(struct vgamode_s *vmode_g, int val); -int cbvga_get_displaystart(struct vgamode_s *vmode_g); -int cbvga_set_displaystart(struct vgamode_s *vmode_g, int val); -int cbvga_get_dacformat(struct vgamode_s *vmode_g); -int cbvga_set_dacformat(struct vgamode_s *vmode_g, int val); +int cbvga_get_window(struct vgamode_s *curmode_g, int window); +int cbvga_set_window(struct vgamode_s *curmode_g, int window, int val); +int cbvga_get_linelength(struct vgamode_s *curmode_g); +int cbvga_set_linelength(struct vgamode_s *curmode_g, int val); +int cbvga_get_displaystart(struct vgamode_s *curmode_g); +int cbvga_set_displaystart(struct vgamode_s *curmode_g, int val); +int cbvga_get_dacformat(struct vgamode_s *curmode_g); +int cbvga_set_dacformat(struct vgamode_s *curmode_g, int val); int cbvga_save_restore(int cmd, u16 seg, void *data); int cbvga_set_mode(struct vgamode_s *vmode_g, int flags); int cbvga_get_linesize(struct vgamode_s *vmode_g); @@ -30,12 +30,12 @@ int ramfb_setup(void); // clext.c struct vgamode_s *clext_find_mode(int mode); void clext_list_modes(u16 seg, u16 *dest, u16 *last); -int clext_get_window(struct vgamode_s *vmode_g, int window); -int clext_set_window(struct vgamode_s *vmode_g, int window, int val); -int clext_get_linelength(struct vgamode_s *vmode_g); -int clext_set_linelength(struct vgamode_s *vmode_g, int val); -int clext_get_displaystart(struct vgamode_s *vmode_g); -int clext_set_displaystart(struct vgamode_s *vmode_g, int val); +int clext_get_window(struct vgamode_s *curmode_g, int window); +int clext_set_window(struct vgamode_s *curmode_g, int window, int val); +int clext_get_linelength(struct vgamode_s *curmode_g); +int clext_set_linelength(struct vgamode_s *curmode_g, int val); +int clext_get_displaystart(struct vgamode_s *curmode_g); +int clext_set_displaystart(struct vgamode_s *curmode_g, int val); int clext_save_restore(int cmd, u16 seg, void *data); int clext_set_mode(struct vgamode_s *vmode_g, int flags); struct bregs;