From 83f79b299b7a099d877920e518f94dff11226c15 Mon Sep 17 00:00:00 2001 From: Laurent Vivier Date: Sun, 28 Aug 2005 21:39:54 +0000 Subject: [PATCH] Add vga_cursor_save(), vga_cursor_save() and correct backspace --- second/vga.c | 29 +++++++++++++++++++++++++---- second/vga.h | 2 ++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/second/vga.c b/second/vga.c index ab90800..ab40a22 100644 --- a/second/vga.c +++ b/second/vga.c @@ -60,8 +60,10 @@ static unsigned char bits_depth8[2] = { static vga_handler_t vga; -#define CURSOR_POS 14 -#define CURSOR_HIGH 2 +static unsigned long cursor_save_x, cursor_save_y; + +#define CURSOR_POS 0 +#define CURSOR_HIGH 16 static int cursor_on = 0; static int cursor_state = 0; @@ -122,6 +124,20 @@ void vga_cursor_off(void) vga_cursor(0); } +void vga_cursor_save(void) +{ + cursor_save_x = vga.pos_x; + cursor_save_y = vga.pos_y; +} + +void vga_cursor_restore(void) +{ + vga_cursor(0); + vga.pos_x = cursor_save_x; + vga.pos_y = cursor_save_y; + vga_cursor(1); +} + static void draw_byte_1(unsigned char *glyph, unsigned char *base) { @@ -380,7 +396,6 @@ vga_init() vga.siz_h = vga.height / 16; vga_clear(); - vga_cursor_on(); } void @@ -397,7 +412,13 @@ vga_put(char c) vga.pos_y++; break; case '\b': - vga.pos_x--; + if (vga.pos_x > 0) + vga.pos_x--; + else if (vga.pos_y > 0) + { + vga.pos_y--; + vga.pos_x = vga.siz_w - 1; + } break; default: draw_byte((unsigned char)c, vga.pos_x++, vga.pos_y); diff --git a/second/vga.h b/second/vga.h index e228554..f2c143c 100644 --- a/second/vga.h +++ b/second/vga.h @@ -14,6 +14,8 @@ extern void vga_print(char *s); extern void vga_cursor_refresh(void); extern void vga_cursor_on(void); extern void vga_cursor_off(void); +extern void vga_cursor_save(void); +extern void vga_cursor_restore(void); extern unsigned long vga_get_videobase(); extern unsigned long vga_get_row_bytes();