aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorFranklin Wei <frankhwei536@gmail.com>2015-02-11 17:47:02 -0500
committerFranklin Wei <frankhwei536@gmail.com>2015-02-11 17:47:02 -0500
commita03f4e798eba196b614024f814e6db7f6795c2f8 (patch)
tree84554ff37b55bf2d32186acf10422d59f25f976a /drivers
parente3305e8f7c119c83fd04f1995e07ff71a1110887 (diff)
downloadkappa-a03f4e798eba196b614024f814e6db7f6795c2f8.zip
kappa-a03f4e798eba196b614024f814e6db7f6795c2f8.tar.gz
kappa-a03f4e798eba196b614024f814e6db7f6795c2f8.tar.bz2
kappa-a03f4e798eba196b614024f814e6db7f6795c2f8.tar.xz
stuff
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gfx-as.S5
-rw-r--r--drivers/gfx.c26
-rw-r--r--drivers/include/gfx.h3
3 files changed, 29 insertions, 5 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);