Index: arch/mips32/src/console.c
===================================================================
--- arch/mips32/src/console.c	(revision fe050b782a8daa5c00ef507564f23db6dc0704cc)
+++ arch/mips32/src/console.c	(revision 95c75262a10964a8280315b2442fb1ec9665f26a)
@@ -43,5 +43,5 @@
 		msim_console();
 #ifdef CONFIG_FB
-	fb_init(0xb2000000, 640, 480);
+	fb_init(0xb2000000, 640, 480, 3); // gxemul framebuffer
 #endif
 }
Index: genarch/include/fb/fb.h
===================================================================
--- genarch/include/fb/fb.h	(revision fe050b782a8daa5c00ef507564f23db6dc0704cc)
+++ genarch/include/fb/fb.h	(revision 95c75262a10964a8280315b2442fb1ec9665f26a)
@@ -33,5 +33,5 @@
 #include <arch/types.h>
 
-void fb_init(__address addr, int x, int y);
+void fb_init(__address addr, int x, int y, int bytes);
 
 #endif
Index: genarch/src/fb/fb.c
===================================================================
--- genarch/src/fb/fb.c	(revision fe050b782a8daa5c00ef507564f23db6dc0704cc)
+++ genarch/src/fb/fb.c	(revision 95c75262a10964a8280315b2442fb1ec9665f26a)
@@ -35,55 +35,73 @@
 SPINLOCK_INITIALIZE(fb_lock);
 
-static unsigned char *fbaddress=NULL;
+static __u8 *fbaddress=NULL;
 static int xres,yres;
 static int position=0;
 static int columns=0;
 static int rows=0;
+static int pixelbytes=0;
 
 #define COL_WIDTH   8
 #define ROW_HEIGHT  (FONT_SCANLINES)
-#define ROW_PIX     (xres*ROW_HEIGHT*3)
+#define ROW_PIX     (xres*ROW_HEIGHT*pixelbytes)
 
 #define BGCOLOR   0x000080
 #define FGCOLOR   0xffff00
 
-#define RED(x)    ((x >> 16) & 0xff)
-#define GREEN(x)  ((x >> 8) & 0xff)
-#define BLUE(x)   (x & 0xff)
-
-#define POINTPOS(x,y,colidx)   ((y*xres+x)*3+colidx)
+#define RED(x,bits)    ((x >> (16+8-bits)) & ((1<<bits)-1))
+#define GREEN(x,bits)  ((x >> (8+8-bits)) & ((1<<bits)-1))
+#define BLUE(x,bits)   ((x >> (8-bits)) & ((1<<bits)-1))
+
+#define POINTPOS(x,y)   ((y*xres+x)*pixelbytes)
+
+/***************************************************************/
+/* Pixel specific fuctions */
 
 /** Draw pixel of given color on screen */
 static inline void putpixel(int x,int y,int color)
 {
-	fbaddress[POINTPOS(x,y,0)] = RED(color);
-	fbaddress[POINTPOS(x,y,1)] = GREEN(color);
-	fbaddress[POINTPOS(x,y,2)] = BLUE(color);
-}
-
-/** Fill line with color BGCOLOR */
-static void clear_line(int y)
-{
-	int x;
-	for (x=0; x<xres;x++)
-		putpixel(x,y,BGCOLOR);
-}
-
-/** Fill screen with background color */
-static void clear_screen(void)
-{
-	int y;
-
-	for (y=0; y<yres;y++)
-		clear_line(y);
-}
-
-static void invert_pixel(int x, int y)
-{
-	fbaddress[POINTPOS(x,y,0)] = ~fbaddress[POINTPOS(x,y,0)];
-	fbaddress[POINTPOS(x,y,1)] = ~fbaddress[POINTPOS(x,y,1)];
-	fbaddress[POINTPOS(x,y,2)] = ~fbaddress[POINTPOS(x,y,2)];
-}
-
+	int startbyte = POINTPOS(x,y);
+
+	if (pixelbytes == 3) {
+		fbaddress[startbyte] = RED(color,8);
+		fbaddress[startbyte+1] = GREEN(color,8);
+		fbaddress[startbyte+2] = BLUE(color,8);
+	} else if (pixelbytes == 4) {
+		*((__u32 *)(fbaddress+startbyte)) = color;
+	} else {
+		int compcolor;
+		/* 5-bit, 5-bits, 5-bits */
+		compcolor = RED(color,5) << 10 \
+			| GREEN(color,5) << 5 \
+			| BLUE(color,5);
+		*((__u16 *)(fbaddress+startbyte)) = compcolor;
+	}
+}
+
+/** Return pixel color */
+static inline int getpixel(int x,int y)
+{
+	int startbyte = POINTPOS(x,y);
+	int color;
+	int result;
+
+	if (pixelbytes == 3) {
+		result = fbaddress[startbyte] << 16 \
+			| fbaddress[startbyte+1] << 8 \
+			| fbaddress[startbyte+2];
+	} else if (pixelbytes == 4) {
+		result = *((__u32 *)(fbaddress+startbyte)) & 0xffffff;
+	} else {
+		int red,green,blue;
+		color = *((__u16 *)(fbaddress+startbyte));
+		red = (color >> 10) & 0x1f;
+		green = (color >> 5) & 0x1f;
+		blue = color & 0x1f;
+		result = (red << 16) | (green << 8) | blue;
+	}
+	return result;
+}
+
+static void clear_line(int y);
 /** Scroll screen one row up */
 static void scroll_screen(void)
@@ -91,5 +109,5 @@
 	int i;
 
-	for (i=0;i < (xres*yres*3)-ROW_PIX; i++)
+	for (i=0;i < (xres*yres*pixelbytes)-ROW_PIX; i++)
 		fbaddress[i] = fbaddress[i+ROW_PIX];
 
@@ -99,4 +117,31 @@
 	
 }
+
+
+/***************************************************************/
+/* Screen specific function */
+
+/** Fill line with color BGCOLOR */
+static void clear_line(int y)
+{
+	int x;
+	for (x=0; x<xres;x++)
+		putpixel(x,y,BGCOLOR);
+}
+
+/** Fill screen with background color */
+static void clear_screen(void)
+{
+	int y;
+
+	for (y=0; y<yres;y++)
+		clear_line(y);
+}
+
+static void invert_pixel(int x, int y)
+{
+	putpixel(x,y, ~getpixel(x,y));
+}
+
 
 /** Draw one line of glyph at a given position */
@@ -112,6 +157,9 @@
 }
 
+/***************************************************************/
+/* Character-console functions */
+
 /** Draw character at given position */
-static void draw_glyph(unsigned char glyph, int col, int row)
+static void draw_glyph(__u8 glyph, int col, int row)
 {
 	int y;
@@ -138,4 +186,7 @@
 }
 
+/***************************************************************/
+/* Stdout specific functions */
+
 static void invert_cursor(void)
 {
@@ -162,4 +213,10 @@
 		if (position % columns)
 			position--;
+	} else if (ch == '\t') {
+		invert_cursor();
+		do {
+			draw_char(' ');
+			position++;
+		} while (position % 8);
 	} else {
 		draw_char(ch);
@@ -185,6 +242,7 @@
  * @param x X resolution
  * @param y Y resolution
+ * @param bytes Bytes per pixel (2,3,4)
  */
-void fb_init(__address addr, int x, int y)
+void fb_init(__address addr, int x, int y, int bytes)
 {
 	fbaddress = (unsigned char *)addr;
@@ -192,4 +250,5 @@
 	xres = x;
 	yres = y;
+	pixelbytes = bytes;
 	
 	rows = y/ROW_HEIGHT;
