Now that a pointer to the current video mode info struct is cached in memory, it's not necessary to pass the struct into the vgafb code. The vgafb code can lookup the struct itself.
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- vgasrc/vgabios.c | 22 +++++++--------------- vgasrc/vgabios.h | 4 ++-- vgasrc/vgafb.c | 12 ++++++++++-- 3 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/vgasrc/vgabios.c b/vgasrc/vgabios.c index fcc5b34..8ec6aa6 100644 --- a/vgasrc/vgabios.c +++ b/vgasrc/vgabios.c @@ -212,19 +212,15 @@ write_teletype(struct cursorpos *pcp, struct carattr ca) if (pcp->y > nbrows) { pcp->y--;
- struct vgamode_s *vmode_g = get_current_mode(); - if (!vmode_g) - return; - struct cursorpos dest = {0, 0, pcp->page}; struct cursorpos src = {0, 1, pcp->page}; struct cursorpos size = {GET_BDA(video_cols), nbrows}; - vgafb_move_chars(vmode_g, dest, src, size); + vgafb_move_chars(dest, src, size);
struct cursorpos clr = {0, nbrows, pcp->page}; struct carattr attr = {' ', 0, 0}; struct cursorpos clrsize = {GET_BDA(video_cols), 1}; - vgafb_clear_chars(vmode_g, clr, attr, clrsize); + vgafb_clear_chars(clr, attr, clrsize); } }
@@ -430,10 +426,6 @@ verify_scroll(struct bregs *regs, int dir) if (wincols <= 0 || winrows <= 0) return;
- struct vgamode_s *vmode_g = get_current_mode(); - if (!vmode_g) - return; - u8 page = GET_BDA(video_page); int clearlines = regs->al, movelines = winrows - clearlines; if (!clearlines || movelines <= 0) { @@ -441,7 +433,7 @@ verify_scroll(struct bregs *regs, int dir) struct cursorpos clr = {ulx, uly, page}; struct carattr attr = {' ', regs->bh, 1}; struct cursorpos clrsize = {wincols, winrows}; - vgafb_clear_chars(vmode_g, clr, attr, clrsize); + vgafb_clear_chars(clr, attr, clrsize); return; }
@@ -450,23 +442,23 @@ verify_scroll(struct bregs *regs, int dir) struct cursorpos dest = {ulx, uly, page}; struct cursorpos src = {ulx, uly + clearlines, page}; struct cursorpos size = {wincols, movelines}; - vgafb_move_chars(vmode_g, dest, src, size); + vgafb_move_chars(dest, src, size);
struct cursorpos clr = {ulx, uly + movelines, page}; struct carattr attr = {' ', regs->bh, 1}; struct cursorpos clrsize = {wincols, clearlines}; - vgafb_clear_chars(vmode_g, clr, attr, clrsize); + vgafb_clear_chars(clr, attr, clrsize); } else { // Scroll down struct cursorpos dest = {ulx, uly + clearlines, page}; struct cursorpos src = {ulx, uly, page}; struct cursorpos size = {wincols, movelines}; - vgafb_move_chars(vmode_g, dest, src, size); + vgafb_move_chars(dest, src, size);
struct cursorpos clr = {ulx, uly, page}; struct carattr attr = {' ', regs->bh, 1}; struct cursorpos clrsize = {wincols, clearlines}; - vgafb_clear_chars(vmode_g, clr, attr, clrsize); + vgafb_clear_chars(clr, attr, clrsize); } }
diff --git a/vgasrc/vgabios.h b/vgasrc/vgabios.h index d17b48f..fc8d45a 100644 --- a/vgasrc/vgabios.h +++ b/vgasrc/vgabios.h @@ -123,9 +123,9 @@ int vga_set_mode(int mode, int flags); void init_gfx_op(struct gfx_op *op, struct vgamode_s *vmode_g); void handle_gfx_op(struct gfx_op *op); void *text_address(struct cursorpos cp); -void vgafb_move_chars(struct vgamode_s *vmode_g, struct cursorpos dest +void vgafb_move_chars(struct cursorpos dest , struct cursorpos src, struct cursorpos movesize); -void vgafb_clear_chars(struct vgamode_s *vmode_g, struct cursorpos dest +void vgafb_clear_chars(struct cursorpos dest , struct carattr ca, struct cursorpos movesize); void vgafb_write_char(struct cursorpos cp, struct carattr ca); struct carattr vgafb_read_char(struct cursorpos cp); diff --git a/vgasrc/vgafb.c b/vgasrc/vgafb.c index 74ddc53..9652683 100644 --- a/vgasrc/vgafb.c +++ b/vgasrc/vgafb.c @@ -512,9 +512,13 @@ text_address(struct cursorpos cp)
// Move characters on screen. void -vgafb_move_chars(struct vgamode_s *vmode_g, struct cursorpos dest +vgafb_move_chars(struct cursorpos dest , struct cursorpos src, struct cursorpos movesize) { + struct vgamode_s *vmode_g = get_current_mode(); + if (!vmode_g) + return; + if (GET_GLOBAL(vmode_g->memmodel) != MM_TEXT) { gfx_move_chars(vmode_g, dest, src, movesize); return; @@ -528,9 +532,13 @@ vgafb_move_chars(struct vgamode_s *vmode_g, struct cursorpos dest
// Clear are of screen. void -vgafb_clear_chars(struct vgamode_s *vmode_g, struct cursorpos dest +vgafb_clear_chars(struct cursorpos dest , struct carattr ca, struct cursorpos clearsize) { + struct vgamode_s *vmode_g = get_current_mode(); + if (!vmode_g) + return; + if (GET_GLOBAL(vmode_g->memmodel) != MM_TEXT) { gfx_clear_chars(vmode_g, dest, ca, clearsize); return;