summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-08-20 03:18:04 +0200
committerMiguel <m.i@gmx.at>2018-08-20 03:18:04 +0200
commite4febc5aac3006c3ef025b5f708ec51fdac63b94 (patch)
treee00149a611589520bd6c99e1fe043385df583f5c /driver
parent39100c30b7a16103e75187c9840a79c7df54f3da (diff)
vesa works beuatifullyy
Diffstat (limited to 'driver')
-rw-r--r--driver/mouse.c6
-rw-r--r--driver/vesa.c96
-rw-r--r--driver/vesa.h3
3 files changed, 94 insertions, 11 deletions
diff --git a/driver/mouse.c b/driver/mouse.c
index 23619a4..f585b99 100644
--- a/driver/mouse.c
+++ b/driver/mouse.c
@@ -128,10 +128,10 @@ void mouse_log()
if(mouse_x>800)mouse_x=800;
if(mouse_y>600)mouse_y=600;
- log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"%d / %d / %02x ",mouse_x, mouse_y,mouse_byte[2]);
+ //log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"%d / %d / %02x ",mouse_x, mouse_y,mouse_byte[2]);
if (mouse_byte[0] & 1)vesa_put_rect(mouse_x,600-mouse_y,10,10,0x00ffff);
- else vesa_put_rect(mouse_x,600-mouse_y,10,10,0x0000ff);
- //PutFont('X', mouse_x,600-mouse_y, 0xffffff);
+ //else vesa_put_rect(mouse_x,600-mouse_y,10,10,0x0000ff);
+ PutFont('X', mouse_x,600-mouse_y, 0xff0000);
}
diff --git a/driver/vesa.c b/driver/vesa.c
index 9b0dd55..b8c03ec 100644
--- a/driver/vesa.c
+++ b/driver/vesa.c
@@ -25,6 +25,60 @@ static uint8_t* physbase;
void PutConsoleNL();
void PutPixel(int x,int y, int color);
+//static char buf[80][24];
+
+void vesa_update_cursor(uint32_t col,uint32_t row)
+{
+ console_x=col;
+ console_y=row;
+}
+
+// helper_funcs
+static void vesa_print_char_col(int x, int y, char c, char col_fg, char col_bg)
+{
+ // uint16_t attrib = (col_bg << 4) | (col_fg & 0x0F);
+ // uint16_t* video_mem=(uint16_t *)SCR_VIDEOMEM+(x+y*SCR_REAL_WIDTH);
+ // *video_mem=c | (attrib << 8) ;
+}
+
+// same colors as in screen.h
+static uint32_t cols[] = {
+ 0x0, // black
+ 0x0066cc, //blue
+ 0x009900, //green
+ 0x33ffff, //cyan
+ 0xff3333, //red
+ 0xcc00cc, //magenta
+ 0x994c00, //brown
+ 0xa0a0a0, //light gray
+ 0x404040, //dark gray
+ 0x3399ff, //light blue
+ 0x99ff33, //light green
+ 0x99ffff, //cyan light
+ 0xff9999, //red light
+ 0xff99ff, //magenta light
+ 0xffff00, //yellow
+ 0xffffff, //white
+};
+
+// glue func for terminal
+void vesa_console_put_char(uint8_t c,uint8_t color_bg, uint8_t color_fg, uint32_t x, uint32_t y)
+{
+// print_char_col(x,y,c, color_bg, color_fg);
+ //PutFont(c, console_x*10,console_y*12, cols[color_fg],cols[color_bg]);
+
+ //PutFont(c, x*10,y*12, cols[color_bg],cols[color_fg]);
+ PutFont(c, x*9,y*11, cols[color_bg],cols[color_fg]);
+
+// buf[console_x][console_y]=c;
+
+// console_x++;
+
+// #ifdef FOOLOS_CONSOLE_AUTOBREAK
+// if(console_x>=console_cols)PutConsoleNL();
+// #endif
+}
+
void vesa_switch_buffers()
{
for(int i=0;i<800*600*2;i++)physbase[i]=buffer[i];
@@ -79,6 +133,10 @@ uint32_t vesa_init(vbeinfo *info,vbemodeinfo *mode,foolfont *rawfont)
int col_width=10;
console_lines=mode->Yres/line_height;
console_cols=mode->Xres/col_width;
+
+ //TODO dynamic (but need to sync with terminal!)
+ console_cols=80;
+ console_lines=24;
// vesa info
log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"vbe version: 0x%x / video mode ptr: 0x%x 0x%x",
@@ -127,7 +185,7 @@ void PutPixel(int x,int y, int color)
}
-void PutFont(char c, int x,int y, int color)
+void PutFont(char c, int x,int y, int color_fg,int color_bg)
{
int fnt=0x126-0x20;
@@ -138,16 +196,25 @@ void PutFont(char c, int x,int y, int color)
for(posx=x;posx<x+sizex;posx++)
{
+ PutPixel(posx,y-1,color_bg);
+ }
+ for(posy=y;posy<y+sizey;posy++)
+ {
+ PutPixel(x-1,posy,color_bg);
+ }
+
+ for(posx=x;posx<x+sizex;posx++)
+ {
for(posy=y;posy<y+sizey;posy++)
{
if(deffont[fnt].line[posy-y]&1<<(7-(posx-x)))
{
- PutPixel(posx,posy,color);
+ PutPixel(posx,posy,color_fg);
}
else
{
- PutPixel(posx,posy,0);
+ PutPixel(posx,posy,color_bg);
}
}
@@ -165,7 +232,7 @@ void PutString(char *str, int x,int y, int color, va_list va)
int i=x;
while((*str)!=0)
{
- PutFont(*str, i,y, color);
+ //PutFont(*str, i,y, color);
i+=9; // spacing
str++;
}
@@ -179,7 +246,7 @@ void PutConsoleChar(char c, int color)
PutConsoleNL();
return;
}
- PutFont(c, console_x*10,console_y*12, color);
+ //PutFont(c, console_x*10,console_y*12, color);
console_x++;
@@ -200,14 +267,27 @@ void PutConsole(char *str, int color)
}
void PutConsoleNL()
{
- console_x=0;
console_y++;
- if(console_y>=console_lines-5)console_y=0;
+ if(console_y<console_lines)return;
+
+ for(int line=0;line<24;line++)
+ {
+ for(int j=0;j<console_cols;j++)
+ {
+// buf[j][line]=buf[j][line+1];
+// PutFont(buf[j][line],j*10,line*12,0x33ff66,0);
+// PutFont(buf[j][line+1],j*10,line*12,0x33ff66,0);
+ }
+ }
for(int i=0;i<console_cols;i++)
{
- PutFont(' ',i*10,(console_y)*12,0);
+ PutFont(' ',i*10,23*12,0x33ff66,0);
+ //buf[i][23]=' ';
}
+
+ console_x=0;
+ console_y--;
}
static int boxx;
diff --git a/driver/vesa.h b/driver/vesa.h
index f6e3eaf..ec98e84 100644
--- a/driver/vesa.h
+++ b/driver/vesa.h
@@ -1,5 +1,8 @@
#include <stdint.h>
+void vesa_update_cursor(uint32_t col,uint32_t row);
+void vesa_console_put_char(uint8_t c,uint8_t color_bg, uint8_t color_fg, uint32_t x, uint32_t y);
+
typedef struct foolfont_struct
{
uint8_t line[10]; //every single fool font consists of 10 lines a 8 bit