summaryrefslogtreecommitdiff
path: root/src/drivers/video/vga.c
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-06-24 13:25:29 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2017-06-24 13:25:29 +0200
commit3294c81695aedef0b59610fe4e0f0cd22f74d67c (patch)
tree5472608e21befc072da4d2176bf964d369547d6f /src/drivers/video/vga.c
parentc8f2689dbeca2bf51d41bbf861c495bb4b0c29ce (diff)
downloadabaos-3294c81695aedef0b59610fe4e0f0cd22f74d67c.tar.gz
abaos-3294c81695aedef0b59610fe4e0f0cd22f74d67c.tar.bz2
started to make some things in graphical VGA driver faster
Diffstat (limited to 'src/drivers/video/vga.c')
-rw-r--r--src/drivers/video/vga.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/drivers/video/vga.c b/src/drivers/video/vga.c
index 5da642a..e30fd19 100644
--- a/src/drivers/video/vga.c
+++ b/src/drivers/video/vga.c
@@ -322,11 +322,33 @@ 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)",
+ 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)",
+ x + w, y + h, vga->mode.x, vga->mode.y );
+ }
+
+ uint8_t color_idx = get_color_index( color );
+
+ for( int yy = y; yy < y + h; yy++ ) {
+ uint8_t *addr = vga->mode.segment + vga->mode.x * yy + x;
+ for( int xx = x; xx < x + w; xx++ ) {
+ *addr = color_idx;
+ addr++;
+ }
+ }
+
+ /* very slow, but educative version
for( int yy = y; yy < y + h; yy++ ) {
for( int xx = x; xx < x + w; xx++ ) {
vga_set_pixel( vga, xx, yy, color );
}
}
+ */
}
void vga_clear_screen( vga_t *vga, const vga_color_t color )