summaryrefslogtreecommitdiff
path: root/src/drivers/video/vga.c
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-06-30 16:45:12 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2017-06-30 16:45:12 +0200
commitc1bbac52d78b2e3e93fa43a5a7b3907073493216 (patch)
tree13ec009562358d01b1845dd08135f4ac8d384551 /src/drivers/video/vga.c
parent915dd4b023d0826166d4887100dbed64d46821a9 (diff)
downloadabaos-c1bbac52d78b2e3e93fa43a5a7b3907073493216.tar.gz
abaos-c1bbac52d78b2e3e93fa43a5a7b3907073493216.tar.bz2
text widget has a constant buffer and owns the string to draw now
(passing a const char * from a local stack context is not really a good idea!) added more efficiet draw method for characters in vga driver protected desktop for now against too often redraws (boolean global variable needs_redraw, this is later a soffisticated set-of-areas-to -redraw algorithm)
Diffstat (limited to 'src/drivers/video/vga.c')
-rw-r--r--src/drivers/video/vga.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/drivers/video/vga.c b/src/drivers/video/vga.c
index bcd4366..647456b 100644
--- a/src/drivers/video/vga.c
+++ b/src/drivers/video/vga.c
@@ -254,6 +254,7 @@ bool vga_set_mode( vga_t *vga, const vga_mode_t mode )
vga->mode.segment = get_frame_buffer_segment( vga );
vga_use_z_buffer( vga, false );
+ memset( vga->zbuffer, 0, sizeof( vga->zbuffer ) );
return true;
}
@@ -325,12 +326,12 @@ void vga_set_pixel( vga_t *vga, const int x, const int y, const vga_color_t colo
void vga_draw_rectangle( vga_t *vga, const int x, const int y, const int w, const int h, const vga_color_t color )
{
if( !params_ok( vga, x, y ) ) {
- kernel_panic( "Pixel coordinates are out of bounds: (%d, %d), resolution is only (%d, %d)",
+ kernel_panic( "Rectangle start coordinates are out of bounds: (%d, %d), resolution is only (%d, %d)",
x, y, vga->mode.x, vga->mode.y );
}
if( !params_ok( vga, x + w, y + h ) ) {
- kernel_panic( "Pixel coordinates are out of bounds: (%d, %d), resolution is only (%d, %d)",
+ kernel_panic( "Rectangle end coordinates are out of bounds: (%d, %d), resolution is only (%d, %d)",
x + w, y + h, vga->mode.x, vga->mode.y );
}
@@ -365,15 +366,35 @@ void vga_draw_char( vga_t *vga, const unsigned char c, const int x, const int y,
// for now, the 34 entry, character height is 16, assuming A-Z
const unsigned char *bmap = &vga_font.Bitmap[(c-32)*16];
+ uint8_t fg_color_idx = get_color_index( foreground );
+ uint8_t bg_color_idx = get_color_index( background );
+ // should be dynamic and vga_font.Width
+ uint8_t data[8];
+
+ for( int yy = 0; yy < vga_font.Height; yy++ ) {
+ memset( data, bg_color_idx, sizeof( data ) );
+ for( int xx = 0; xx < vga_font.Width; xx++ ) {
+ if( bmap[yy] & mask[xx] ) {
+ data[7-xx] = fg_color_idx;
+ }
+ }
+ uint8_t *addr = vga->base_addr + vga->mode.x * ( y + yy ) + x;
+ memcpy( addr, data, 8 );
+ }
+
+// amazingly slow
+/*
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 + 10 - xx, y + yy, foreground );
} else {
- vga_set_pixel( vga, x + 10 - xx, y + yy, background );
+// drawing only what's needed, the background is done by the widget
+// vga_set_pixel( vga, x + 10 - xx, y + yy, background );
}
}
}
+*/
}
void vga_wait_for_retrace( vga_t *vga )