From a03f4e798eba196b614024f814e6db7f6795c2f8 Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Wed, 11 Feb 2015 17:47:02 -0500 Subject: stuff --- drivers/gfx-as.S | 5 +++-- drivers/gfx.c | 26 ++++++++++++++++++++++++-- drivers/include/gfx.h | 3 ++- kernel/main.c | 33 ++++++++++++++++++++++++++++++++- 4 files changed, 61 insertions(+), 6 deletions(-) diff --git a/drivers/gfx-as.S b/drivers/gfx-as.S index df94c71..81744d5 100644 --- a/drivers/gfx-as.S +++ b/drivers/gfx-as.S @@ -1,11 +1,12 @@ - .global gfx_clear .extern fb_width .extern fb_height .extern fb_stride .extern fb_bpp .extern _gfx_bgcol .extern framebuffer -gfx_clear: + + .global gfx_clear_packed +gfx_clear_packed: movl framebuffer, %eax movzwl fb_stride, %ecx movzwl fb_height, %edx diff --git a/drivers/gfx.c b/drivers/gfx.c index babbf27..b6bcae3 100644 --- a/drivers/gfx.c +++ b/drivers/gfx.c @@ -24,6 +24,8 @@ const uint16_t *gfx_height = &fb_height; static int cursor_x, cursor_y; uint32_t _gfx_fgcol, _gfx_bgcol; +void (*gfx_clear)(void); + void gfx_set_background(uint32_t col) { _gfx_bgcol = col; @@ -118,7 +120,7 @@ void gfx_drawchar_bg(int x, int y, int c) void gfx_putchar(int ch) { - if(ch != '\n') + if(ch != '\n' && ch != '\b') { gfx_drawchar(cursor_x, cursor_y, ch); cursor_x += FONT_WIDTH; @@ -133,7 +135,7 @@ void gfx_putchar(int ch) } } } - else + else if(ch == '\n') { cursor_x = 0; cursor_y += FONT_HEIGHT; @@ -143,6 +145,21 @@ void gfx_putchar(int ch) cursor_y = 0; } } + else if(ch == '\b') + { + int temp_x = cursor_x - FONT_WIDTH; + if(temp_x < 0) + { + cursor_x = 0; + int temp_y = cursor_y - FONT_HEIGHT; + cursor_y = (temp_y < 0) ? 0 : temp_y; + } + else + { + cursor_x = temp_x; + } + gfx_drawchar_bg(cursor_x, cursor_y, ' '); + } } void gfx_puts(const char* str) @@ -247,6 +264,11 @@ bool gfx_init(struct vbe_info_t *vbe_mode_info) printf("WARNING: BPP != 32, falling back to text mode...\n"); return false; } + + void gfx_clear_packed(void); + + gfx_clear = &gfx_clear_packed; + gfx_reset(); set_putchar(gfx_putchar); set_puts(gfx_puts); diff --git a/drivers/include/gfx.h b/drivers/include/gfx.h index 50b84dc..81be70d 100644 --- a/drivers/include/gfx.h +++ b/drivers/include/gfx.h @@ -46,7 +46,8 @@ void gfx_putchar(int ch); void gfx_puts(const char* str); -void gfx_clear(void); +/* this function can be different from resolution to resolution */ +extern void (*gfx_clear)(void); void gfx_reset(void); diff --git a/kernel/main.c b/kernel/main.c index fc62a10..f0cc0d8 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -171,17 +171,48 @@ void main(struct multiboot_info_t *hdr, uint32_t magic) printf("Resolution: %dx%dx%d\n", *gfx_width, *gfx_height, *gfx_bpp * 8); } - printf("Testing keyboard LED's...\n"); + printf("Testing keyboard LED's..."); + + int n = 3; + int s = -1; while(1) { ps2_set_leds(PS2_NUM_LOCK); timer_delay(HZ/4); + if(s < 0) + putchar('\b'); + else + putchar('.'); + n+=s; + if(n<=0 || n>=3) + s=-s; ps2_set_leds(PS2_CAPS_LOCK); timer_delay(HZ/4); + if(s < 0) + putchar('\b'); + else + putchar('.'); + n+=s; + if(n<=0 || n>=3) + s=-s; ps2_set_leds(PS2_SCROLL_LOCK); timer_delay(HZ/4); + if(s < 0) + putchar('\b'); + else + putchar('.'); + n+=s; + if(n<=0 || n>=3) + s=-s; ps2_set_leds(PS2_CAPS_LOCK); timer_delay(HZ/4); + if(s < 0) + putchar('\b'); + else + putchar('.'); + n+=s; + if(n<=0 || n>=3) + s=-s; } } -- cgit v1.1