diff options
Diffstat (limited to 'vgasrc')
-rw-r--r-- | vgasrc/vga.c | 56 |
1 files changed, 21 insertions, 35 deletions
diff --git a/vgasrc/vga.c b/vgasrc/vga.c index c28d891..403f047 100644 --- a/vgasrc/vga.c +++ b/vgasrc/vga.c @@ -176,78 +176,62 @@ biosfn_set_active_page(u8 page) } static struct cursorpos -check_scroll(struct cursorpos cp) +write_teletype(struct cursorpos cp, struct carattr ca) { // Get the dimensions u16 nbrows = GET_BDA(video_rows) + 1; u16 nbcols = GET_BDA(video_cols); - // Do we need to wrap ? - if (cp.x == nbcols) { - cp.x = 0; - cp.y++; - } - // Do we need to scroll ? - if (cp.y == nbrows) { - struct cursorpos ul = {0, 0, cp.page}; - struct cursorpos lr = {nbcols-1, nbrows-1, cp.page}; - vgafb_scroll(1, -1, ul, lr); - cp.y--; - } - - return cp; -} - -static struct cursorpos -write_teletype(struct cursorpos cp, struct carattr ca) -{ switch (ca.car) { case 7: //FIXME should beep break; - case 8: if (cp.x > 0) cp.x--; break; - case '\r': cp.x = 0; break; - case '\n': cp.y++; break; - case '\t': do { struct carattr dummyca = {' ', ca.attr, ca.use_attr}; vgafb_write_char(cp, dummyca); cp.x++; - cp = check_scroll(cp); - } while (cp.x % 8); + } while (cp.x < nbcols && cp.x % 8); break; - default: vgafb_write_char(cp, ca); cp.x++; } - return check_scroll(cp); + // Do we need to wrap ? + if (cp.x == nbcols) { + cp.x = 0; + cp.y++; + } + // Do we need to scroll ? + if (cp.y == nbrows) { + struct cursorpos ul = {0, 0, cp.page}; + struct cursorpos lr = {nbcols-1, nbrows-1, cp.page}; + vgafb_scroll(1, -1, ul, lr); + cp.y--; + } + + return cp; } static void write_string(struct cursorpos cp, u8 flag, u8 attr, u16 count, u16 seg, u8 *offset_far) { - // if row=0xff special case : use current cursor position - if (cp.y == 0xff) - cp = get_cursor_pos(cp.page); - - while (count-- != 0) { + while (count--) { u8 car = GET_FARVAR(seg, *offset_far); offset_far++; - if ((flag & 0x02) != 0) { + if (flag & 0x02) { attr = GET_FARVAR(seg, *offset_far); offset_far++; } @@ -1006,8 +990,10 @@ handle_1012(struct bregs *regs) static void handle_1013(struct bregs *regs) { - // XXX - inline struct cursorpos cp = {regs->dl, regs->dh, regs->bh}; + // if row=0xff special case : use current cursor position + if (cp.y == 0xff) + cp = get_cursor_pos(cp.page); write_string(cp, regs->al, regs->bl, regs->cx , regs->es, (void*)(regs->bp + 0)); } |