Fix drawing glitches

- Use standard ASCII characters for window borders
- Fix color palette
- Fix "reverse" attribute emulation by having dedicated palette entries
- Fix usage of attr ram
diff --git a/contiki-vsmile/conf/ctk-conio-conf.h b/contiki-vsmile/conf/ctk-conio-conf.h
index f0fa209..da43c86 100644
--- a/contiki-vsmile/conf/ctk-conio-conf.h
+++ b/contiki-vsmile/conf/ctk-conio-conf.h
@@ -45,13 +45,13 @@
 #define BACKGROUNDCOLOR     1
 
 #define WINDOWCOLOR_FOCUS   5
-#define WINDOWCOLOR         8
+#define WINDOWCOLOR         2
 
 #define DIALOGCOLOR         5
 
 #define WIDGETCOLOR_HLINK   6
 #define WIDGETCOLOR_FWIN    5
-#define WIDGETCOLOR         8
+#define WIDGETCOLOR         2
 #define WIDGETCOLOR_DIALOG  5
 #define WIDGETCOLOR_FOCUS   7
 
diff --git a/contiki-vsmile/ctk/conio.c b/contiki-vsmile/ctk/conio.c
index 938cb62..63f1354 100644
--- a/contiki-vsmile/ctk/conio.c
+++ b/contiki-vsmile/ctk/conio.c
@@ -68,7 +68,7 @@
 	*PPU_BG1_SCROLL_X = 0;
 	*PPU_BG1_SCROLL_Y = 0;
 	*PPU_BG1_ATTR = 0;
-	*PPU_BG1_CTRL = 0x0a; // TODO 0x08 so that vram_attr is actually used for something. Once we can figure out how it works. There will be only 4 possible "colors" this way...
+	*PPU_BG1_CTRL = 0x08;
 	*PPU_BG2_CTRL = 0;
 	*PPU_SPRITE_CTRL = 0;
 	
@@ -76,8 +76,53 @@
 	*PPU_BG1_ATTR_ADDR = vram_attr;
 	*PPU_BG1_SEGMENT_ADDR = RES_FONT_BIN_SA >> 6;
 	
-	for (i = 0; i < 255; i++)
-		PPU_COLOR[i] = i;
+	PPU_COLOR[0] = make_color(0, 0, 0); // Border, unused?
+	PPU_COLOR[1] = make_color(31, 31, 31);
+	
+	PPU_COLOR[16] = make_color(0, 0, 0); // Screen
+	PPU_COLOR[17] = make_color(18, 18, 31);
+	
+	PPU_COLOR[32] = make_color(0, 0, 0); // Windows, widgets, menu
+	PPU_COLOR[33] = make_color(15, 15, 15);
+
+	PPU_COLOR[48] = make_color(0, 0, 0); // Open menu
+	PPU_COLOR[49] = make_color(31, 15, 15);
+
+	PPU_COLOR[64] = make_color(0, 0, 0); // Active menu item
+	PPU_COLOR[65] = make_color(30, 30, 30);
+	
+	PPU_COLOR[80] = make_color(12, 12, 31); // Focused window/dialog
+	PPU_COLOR[81] = make_color(31, 31, 15);
+
+	PPU_COLOR[96] = make_color(0, 0, 8); // Hyperlinks
+	PPU_COLOR[97] = make_color(24, 24, 31);
+
+	PPU_COLOR[112] = make_color(12, 12, 12); // Focused widget
+	PPU_COLOR[113] = make_color(24, 24, 24);
+	
+	PPU_COLOR[129] = make_color(0, 0, 0); // Border, unused?
+	PPU_COLOR[128] = make_color(31, 31, 31);
+	
+	PPU_COLOR[129+16] = make_color(0, 0, 0); // Screen
+	PPU_COLOR[128+16] = make_color(18, 18, 31);
+	
+	PPU_COLOR[129+32] = make_color(0, 0, 0); // Windows, widgets, menu
+	PPU_COLOR[128+32] = make_color(15, 15, 15);
+
+	PPU_COLOR[129+48] = make_color(0, 0, 0); // Open menu
+	PPU_COLOR[128+48] = make_color(31, 15, 15);
+
+	PPU_COLOR[129+64] = make_color(0, 0, 0); // Active menu item
+	PPU_COLOR[128+64] = make_color(30, 30, 30);
+	
+	PPU_COLOR[129+80] = make_color(12, 12, 31); // Focused window/dialog
+	PPU_COLOR[128+80] = make_color(31, 31, 15);
+
+	PPU_COLOR[129+96] = make_color(0, 0, 8); // Hyperlinks
+	PPU_COLOR[128+96] = make_color(24, 24, 31);
+
+	PPU_COLOR[129+112] = make_color(12, 12, 12); // Focused widget
+	PPU_COLOR[128+112] = make_color(24, 24, 24);
 	
 	PPU_COLOR[0] = make_color(0, 0, 0); // Border
 	PPU_COLOR[1] = make_color(18, 18, 31); // Screen
@@ -109,15 +154,15 @@
 void
 clrscr(void)
 {
-  memset(vram, 0, VRAM_WIDTH * LIBCONIO_SCREEN_HEIGHT);
+  memset(vram, 32, VRAM_WIDTH * LIBCONIO_SCREEN_HEIGHT);
   memset(vram_attr, 0, VRAM_WIDTH * LIBCONIO_SCREEN_HEIGHT / 2);
 }
 /*-----------------------------------------------------------------------------------*/
 void
 revers(unsigned char c)
 {
-	if (c != 0) color |= 16;
-	else color &= ~16;
+	if (c != 0) color |= 8;
+	else color &= ~8;
 }
 /*-----------------------------------------------------------------------------------*/
 void
@@ -139,16 +184,16 @@
 void
 cclear(unsigned char length)
 {
-	memset(vram + cursy * VRAM_WIDTH + cursx, 0, length);
-	memset(vram_attr + ((cursy * VRAM_WIDTH + cursx) >> 1), color, length >> 1);
+	memset(vram + cursy * VRAM_WIDTH + cursx, 32, length);
+	memset(vram_attr + ((cursy * VRAM_WIDTH + cursx) >> 1), (color | color << 8), length >> 1);
 	cursx += length;
 }
 /*-----------------------------------------------------------------------------------*/
 void
 chline(unsigned char length)
 {
-	memset(vram + cursy * VRAM_WIDTH + cursx, 196, length);
-	memset(vram_attr + ((cursy * VRAM_WIDTH + cursx) >> 1), color, length >> 1);
+	memset(vram + cursy * VRAM_WIDTH + cursx, '-', length);
+	memset(vram_attr + ((cursy * VRAM_WIDTH + cursx) >> 1), (color |color << 8), length >> 1);
 	cursx += length;
 }
 /*-----------------------------------------------------------------------------------*/
@@ -156,9 +201,18 @@
 cvline(unsigned char length)
 {
   int i;
-  for(i = 0; i < length; ++i) {
-    vram_attr[(cursy * VRAM_WIDTH + cursx) >> 1] = color;
-    vram[cursy++ * VRAM_WIDTH + cursx] = 179;
+  if (cursx & 1) {
+  	for(i = 0; i < length; ++i) {
+  		vram_attr[(cursy * VRAM_WIDTH + cursx) >> 1] &= 0xff;
+    	vram_attr[(cursy * VRAM_WIDTH + cursx) >> 1] |= color << 8;
+    	vram[cursy++ * VRAM_WIDTH + cursx] = '|';
+  	}
+  } else {
+  	for(i = 0; i < length; ++i) {
+  		vram_attr[(cursy * VRAM_WIDTH + cursx) >> 1] &= 0xff00;
+    	vram_attr[(cursy * VRAM_WIDTH + cursx) >> 1] |= color;
+    	vram[cursy++ * VRAM_WIDTH + cursx] = '|';
+  	}
   }
 }
 /*-----------------------------------------------------------------------------------*/
@@ -207,8 +261,7 @@
 void
 textcolor(unsigned char c)
 {
-  color &= 16;
-  color |= c;
+  color = c;
 }
 /*-----------------------------------------------------------------------------------*/
 void
diff --git a/contiki-vsmile/ctk/ctk-arch.c b/contiki-vsmile/ctk/ctk-arch.c
index 4a8481b..ff60d17 100644
--- a/contiki-vsmile/ctk/ctk-arch.c
+++ b/contiki-vsmile/ctk/ctk-arch.c
@@ -87,6 +87,9 @@
 		   unsigned char reversed,
 		   unsigned char color)
 {
+	if (reversed)
+		color ^= 8;
+
 	vram[y * VRAM_WIDTH + x] = c;
 	if (x & 1) {
 		vram_attr[(y * VRAM_WIDTH + x) / 2] &= 0xff;
diff --git a/contiki-vsmile/ctk/ctk-arch.h b/contiki-vsmile/ctk/ctk-arch.h
index 385db71..bb39abc 100644
--- a/contiki-vsmile/ctk/ctk-arch.h
+++ b/contiki-vsmile/ctk/ctk-arch.h
@@ -44,10 +44,10 @@
 #define CH_CURS_DOWN	'j'
 
 // FIXME use the semigraphics
-#define CH_ULCORNER	'\xDA'
-#define CH_URCORNER	'\xBF'
-#define CH_LLCORNER	'\xC0'
-#define CH_LRCORNER	'\xD9'
+#define CH_ULCORNER	'/'
+#define CH_URCORNER	'\\'
+#define CH_LLCORNER	'\\'
+#define CH_LRCORNER	'/'
 
 #include "ctk-conio.h"