summaryrefslogtreecommitdiff
path: root/src/drivers/video/vga.c
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-06-16 17:10:48 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2017-06-16 17:10:48 +0200
commitb6f1311502f48a091dd51bd7443105963071af9a (patch)
tree150aacd5f67e2c53f811dd65112a6731d654b8cb /src/drivers/video/vga.c
parent066aeb4588db4e42e06d98cca7ceb8ae1e825cab (diff)
downloadabaos-b6f1311502f48a091dd51bd7443105963071af9a.tar.gz
abaos-b6f1311502f48a091dd51bd7443105963071af9a.tar.bz2
first character printed in graphics mode
Diffstat (limited to 'src/drivers/video/vga.c')
-rw-r--r--src/drivers/video/vga.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/drivers/video/vga.c b/src/drivers/video/vga.c
index c385bea..1ec7829 100644
--- a/src/drivers/video/vga.c
+++ b/src/drivers/video/vga.c
@@ -4,6 +4,8 @@
#include "kernel.h"
+#include "vga_font.h"
+
#undef DEBUG
static vga_vtable_t vga_vtable = {
@@ -269,3 +271,32 @@ void vga_clear_screen( vga_t *vga, const vga_color_t color )
memset( vga->mode.segment, get_color_index( color ),
vga->mode.x * vga->mode.y );
}
+
+void vga_draw_char( vga_t *vga, const unsigned char c, const int x, const int y, const vga_color_t background, const vga_color_t foreground )
+{
+
+//const struct bitmap_font font = {
+
+/* .Width = 8, .Height = 16,
+ .Chars = 2899,
+ .Widths = __font_widths__,
+ .Index = __font_index__,
+ .Bitmap = __vga_font_bitmap__,
+*/
+ // assuming font width is 8
+ int mask[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
+
+ // for now, the 34 entry, character height is 16, assuming A-Z
+ const unsigned char *bmap = &vga_font.Bitmap[(34+c-65)*16];
+
+ for( int xx = 0; xx < vga_font.Width; xx++ ) {
+ for( int yy = 0; yy < vga_font.Height; yy++ ) {
+ if( bmap[yy] & mask[xx] ) {
+ vga_set_pixel( vga, x + xx, y + yy, foreground );
+ } else {
+ vga_set_pixel( vga, x + xx, y + yy, background );
+ }
+ }
+ }
+}
+