From 45ce8728224caa44d31dca3117992b193fa3cd98 Mon Sep 17 00:00:00 2001 From: Miguel Date: Fri, 19 Oct 2018 02:41:53 +0200 Subject: window manager continued --- userspace/xterm/vesa.c | 126 ++++++++++++++++++------------------------------- 1 file changed, 45 insertions(+), 81 deletions(-) (limited to 'userspace/xterm/vesa.c') diff --git a/userspace/xterm/vesa.c b/userspace/xterm/vesa.c index 6d61498..16c8649 100644 --- a/userspace/xterm/vesa.c +++ b/userspace/xterm/vesa.c @@ -4,11 +4,6 @@ #include #include #include "vesa.h" -#include "../newcalls.h" - -void PutFont(char c, int x,int y, int color_fg,int color_bg); - -#define VMEM_USER_FRAMEBUFFER 0xf5100000 // framebuffer info static uint32_t vesaXres; @@ -34,9 +29,12 @@ static uint8_t termdata[80*24]; static uint8_t termdata_bg[80*24]; static uint8_t termdata_fg[80*24]; +void PutFont(char c, int x,int y, uint32_t color_fg,uint32_t color_bg); + // same colors as in screen.h +/* static uint32_t cols[] = { - 0x0, // black + 0x0, //black 0x0066cc, //blue 0x009900, //green 0x33ffff, //cyan @@ -53,6 +51,28 @@ static uint32_t cols[] = { 0xffff00, //yellow 0xffffff, //white }; +*/ + +/** solarized theme */ + +static uint32_t cols[] = { + 0x073642, // S_base02 + 0xdc322f, // S_red + 0x859900, // S_green + 0xb58900, // S_yellow + 0x268bd2, // S_blue + 0xd33682, // S_magenta + 0x2aa198, // S_cyan + 0xeee8d5, // S_base2 + 0x002b36, // S_base03 + 0xcb4b16, // S_orange + 0x586e75, // S_base01 + 0x657b83, // S_base00 + 0x839496, // S_base0 + 0x6c71c4, // S_violet + 0x93a1a1, // S_base1 + 0xfdf6e3, // S_base3 +}; /** update cursor position */ void vesa_update_cursor(uint32_t col,uint32_t row) @@ -77,34 +97,13 @@ void vesa_console_put_char(uint8_t c,uint8_t color_bg, uint8_t color_fg, uint32_ if(x==console_x&&y==console_y)PutFont(c, x,y, cols[color_fg],cols[color_bg]); else PutFont(c, x,y, cols[color_bg],cols[color_fg]); } - - // - // We want to get output to the screen as fast as possible! - // - // Our Fool-Boot-Loader did set up VESA already for us. - // The desired VESA mode is hardcoded in [boot/mbr.asm]. - // - // The [vesa_init(...)] function requires: - // - // * the addresses of the vbeinfo struct - // * the address of the vbemodeinfo struct (for selected mode). - // * Fool Font loaded inside ramimage - // - // The first two paramters are hardcoded in [boot/mbr.asm], - // while the last one is set in the Makefile. The font binary - // is integrated in the kernel image. - // - // this function returns the physical base address of - // our video memory - // -uint32_t vesa_init(char *fontname) +uint32_t vesa_init(int w,int h, int fb, char *fontname) { // LOAD FONT FILE *f; - //if(fontname==NULL)f=fopen("/doc/fonts/binfont.bin","r"); - //if(fontname==NULL)f=fopen("/doc/fonts/tinyfont.bin","r"); if(fontname==NULL)f=fopen("/doc/fonts/envypn7x13.bin","r"); + else f=fopen("fontname","r"); fread(&font_width,1,1,f); fread(&font_height,1,1,f); @@ -116,13 +115,12 @@ uint32_t vesa_init(char *fontname) fread(foolfont,1,alloc_bytes,f); // virtual screen - vesaXres=640; - vesaYres=480; + vesaXres=w; + vesaYres=h; - vesaPitch=640*4; + vesaPitch=vesaXres*4; vesaBpp=4; //32bit - vesaAddr=VMEM_USER_FRAMEBUFFER; - // + vesaAddr=fb;//// TODOVMEM_USER_FRAMEBUFFER; // console_x=0; @@ -135,33 +133,15 @@ uint32_t vesa_init(char *fontname) return vesaAddr; } - -// TODO: what will happen in 24bit mode? -// TODO: optimize -void PutPixel(int x,int y, int color) +void PutPixel(int x,int y, uint32_t color) { - /* - //do not write memory outside the screen buffer, check parameters against the VBE mode info - if (x<0 || x>vesaXres|| y<0 || y>vesaYres) return; - if (x) x = (x*(vesaBpp>>3)); // get bytes (divide by 8) - if (y) y = (y*vesaPitch); - //uint8_t *cTemp=VbeModeInfoBlock->physbase; - uint8_t *cTemp=VMEM_USER_FRAMEBUFFER; - - cTemp[x+y] = (uint8_t)(color & 0xff); - cTemp[x+y+1] = (uint8_t)((color>>8) & 0xff); - cTemp[x+y+2] = (uint8_t)((color>>16) & 0xff); - */ - - uint8_t *p=VMEM_USER_FRAMEBUFFER+y*vesaPitch+x*vesaBpp; + uint8_t *p=vesaAddr+y*vesaPitch+x*vesaBpp; uint32_t *pix=p; *pix=color; } - static bool check_pixel(int idx,int x,int y) { -// x=font_width-x-1; int pixel_index=idx*font_width*font_height+y*font_width+x; return foolfont[pixel_index/8]&(1<<(7-(pixel_index%8))); } @@ -169,48 +149,32 @@ static bool check_pixel(int idx,int x,int y) /** * Put character C in column X of row Y using colors fg and bg */ -void PutFont(char c, int x,int y, int color_fg,int color_bg) +void PutFont(char c, int x,int y, uint32_t color_fg,uint32_t color_bg) { + static uint8_t opac=0xbb; int fnt; if(c>=0x20&&c<=0x126)fnt=c-0x20; else return; // any other fonts?? - //x=x*(1+font_width); - //y=y*(1+font_height); x=x*(font_width+1); y=y*(font_height+1); //fill broder with bg color - for(int posx=x;posx